« Back

Minimizing the ext environment

Company Blogs February 19, 2010 By Amos Fong Staff

There has been a lot of work trying to minimize the use of the ext environment to keep your site more maintainable and easier to customize. Here are some tips that has helped me keep my ext small and more maintainable/manageable which will also make upgrades more smooth.

 

Move anything possible in ext to hooks.

1. Do you need to override a *ServiceImpl.java class? (v6.0 or later)

For example, to override the UserLocalServiceImp class put this in your liferay-hook.xml

<hook>
    <service>
        <service-type>com.liferay.portal.service.UserLocalService</service-type>
        <service-impl>com.liferay.testhook.hook.service.impl.TestUserLocalServiceImpl</service-impl>
    </service>
</hook>

Then in your class just extend the UserLocalServiceWrapper and override any methods you want.

public class TestUserLocalServiceImpl extends UserLocalServiceWrapper {

Check out the test-hook portlet located in svn://svn.liferay.com/repos/public/plugins/trunk/portlets/test-hook-portlet/ for more info.

 

2. Do you need to override any classes listed in the liferay-hook.dtd or do you need to add event actions?

For example, do you need to override the ScreennameValidator, ScreennameGenerator, Document library hook, or add postLoginActions, servicePreActions, etc.? These can be overriden through portal.properties in a hook and even allow hot deploy overriding! That means you don't need to restart tomcat to test a new change, you can just redeploy your hook. See the full list in lifeary-hook_6_0_0.dtd. New properties will continually be added so keep an eye for new ways to minimize your ext.

 

Use custom attributes.

1. Do you need to customize user attributes?

Instead of modifying service.xml to add a new column and regenerating all the services, use a custom attribute. There is practically no performance difference, String attributes (only string!) are indexed, and you can do it through the admin GUI. One thing you need to keep in mind is to give view or update permissions apprpriately.

They are even picked up automatically in the create account form! You don't even need to modify any java classes to add a new attribute for registering. Just create a JSP hook and add this easy taglib to the create_account.jsp.

        <liferay-ui:custom-attribute
            className="com.liferay.portal.model.User"
            classPK="<%= 0 %>"
            editable="<%= true %>"
            label="<%= true %>"
            name="favoriteColor"
        />

 In the action class, it will pick any custom attributes and update them accordingly. The same is true for most all other models too (ie Documents, Images, Web content).

 

Extend rather than override.

1. Do you need to override any *Action.java classes?

Any classes in struts-config.xml or liferay-portlet.xml should be extended rather than overrided. This will hopefully make upgrading less painfulby keeping the current code and just adding your own or tweaking variables so you get the behaviour you want.

For example, say you created a custom attribute "Favorite Color" and you want to make it required to be filled out.


<struts-config>
    <action-mappings>
        <action path="/login/create_account" type="com.liferay.test.ext.portlet.login.action.TestCreateAccountAction">
            <forward name="portlet.login.create_account" path="portlet.login.create_account" />
        </action>
</struts-config>

Then in your class:

public class TestCreateAccountAction extends CreateAccountAction {
    protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {

        Map<String, Serializable> expandoBridgeAttributes =
            PortalUtil.getExpandoBridgeAttributes(
                ExpandoBridgeFactoryUtil.getExpandoBridge(User.class.getName()), actionRequest);

         String favoriteColor = (String)expandoBridgeAttributes.get("favoriteColor");

         if (Validator.isNull(favoriteColor)) {
                throw new RequiredFieldException("favoriteColor", "favoriteColorLabel"); // v6.0/EE specific code
         
         }

        super.addUser(actionRequest, actionResponse);  // Don't touch current code to make upgrades painless =)
    }
}

 

2. Do you need to override JSPs?

Use a JSP hook. (See www.liferay.com/community/wiki/-/wiki/Main/Portal+Hook+Plugins)

And use the buffer util taglib to achieve a similar affect to what I did with CreateAccountAction.java class above. Let's say we want to remove the javascript on the bottom, change the word "save" to "create" and add the custom attribute favorite color to the registration form after the last name.

 

<%@ include file="/html/portlet/login/init.jsp" %>

<liferay-util:buffer var="html">
    <liferay-util:include page="/html/portlet/login/create_account.portal.jsp" />
</liferay-util:buffer>

<liferay-util:buffer var="customHtml">
   <liferay-ui:custom-attribute
        className="com.liferay.portal.model.User"
        classPK="<%= 0 %>"
        editable="<%= true %>"
        label="<%= true %>"
        name="favoriteColor"
    />
</liferay-util:buffer>

<%
int x = html.lastIndexOf("<script type=\"text/javascript\"");

if (x != -1) {
    y = html.indexOf("</script>", x);

    html = html.substring(0, x) + html.substring(y + 9);
}

html = html.replace(LanguageUtil.get(pageContext, "save"), LanguageUtil.get(pageContext, "create"));

x = html.indexOf(LanguageUtil.get(pageContext, "last-name"));

if (x != -1) {
    y = html.indexOf("</div>", x);

    html = html.substring(0, y) + customHtml + html.substring(y);
}
%>

<%= html %>

 

Conclusion

Hopefully that was useful to you. Of course, this isn't always possible and you'll have to resort to direct overwriting. But I hope this can minimize the pain of upgrading for some people.

If there are commonly overrided classes, let's see if we can figure out ways to make it easier, make it possible to use a technique mentioned above, or be moved to a hook =). Or...contribute to trunk if it's useful, that way we maintain it for you and others also benefit from it.

If you guys have any other methods you like to use or if I missed anything, please leave a comment.

Threaded Replies Author Date
Thanks for writing this Amos :) Brian Chan February 19, 2010 11:38 PM
Very nice. Thank you, Amos. Jonas Yuan February 20, 2010 2:17 PM
Great summary Amos, this is very helpful! Julio Camarero February 21, 2010 3:24 PM
Really helpful!! Tina Agrawal February 21, 2010 10:25 PM
Sir, Thanks for this helpful feature :) Bavithra Rajendran February 22, 2010 10:52 PM
That is very useful ... thank you! Gwenaël Gourevich February 23, 2010 12:38 AM
Nice job Amos. Shagul Khajamohideen February 23, 2010 9:26 AM
Really helpful amos, Thanks Jignesh Vachhani February 25, 2010 1:40 AM
Very nice article :) I was trying to use your... Joao Sequeira March 3, 2010 4:44 AM
Hi Joao, Sorry I didn't specify versions.... Amos Fong March 9, 2010 9:52 AM
Hi Amos, Thanks for the article I have couple... Anand Barhate March 9, 2010 12:27 AM
Hi Anand, Making changes to struts-config.xml... Amos Fong March 9, 2010 9:54 AM
Hi Team, You need to edit the... Deepak Kenchamba October 26, 2010 1:30 AM
Hi Deepak, Is there any way of doing this... Henrique Fernandes January 21, 2011 7:52 AM
Hi Henrique, I have tried overriding the... Luis Rodríguez Fernández March 9, 2011 12:06 AM
Nice article, thank you. I would like to ask... Peter Pastrnak June 12, 2010 9:27 AM
Hello if I want to override the... Alessandro Cosenza July 22, 2010 7:03 AM
See... Brian Chan July 22, 2010 2:09 PM
Hi! I'm triying to override a method in... Fernando Ordás August 12, 2010 9:09 AM
Finally I found the problem, there were some... Fernando Ordás August 16, 2010 6:48 AM
Hi All, I need some solution on user... Prasanna Kumar September 14, 2010 3:57 AM
Hi Prasana, There a couple ways to do this,... Amos Fong September 14, 2010 9:45 AM
Hi Amos, regarding the hint about overriding... Jakub Liska October 18, 2010 10:37 AM
I got it, we can do it. It's like a list of... Jakub Liska October 18, 2010 11:07 AM
Amos Fong, Thanks for your reply... I am very... Prasanna Kumar September 14, 2010 10:35 AM
There is a short tutorial in this wiki: ... Amos Fong September 14, 2010 11:05 AM
Thanks Amos... We are using openSSO ... we... Prasanna Kumar September 14, 2010 11:18 AM
Hi Amos, Can you give me some instructions to... PRAKASH HARIGOPAL October 7, 2010 9:56 AM
In sample wrapper user of type SampleUserImpl... Sandeep Nair October 28, 2010 11:30 PM
Hello, i use a hook to extend a jsp page and i... Brahim TARNAOUI November 8, 2010 3:59 AM
Hi. Does anyone know if it is possible to... Peter Davison November 10, 2010 6:41 AM
Hi Peter, If i listen correctly , you want to... PRAKASH HARIGOPAL November 10, 2010 8:59 AM
Thanks for your reply. Yeah, I've created my... Peter Davison November 10, 2010 10:54 AM
Thanks Amos, great post, really useful!!! 1.... Luis Rodríguez Fernández March 9, 2011 12:01 AM
Hi Amos If I define new method in... Nguyen Trung Kien March 17, 2011 10:35 AM
No you cannot define a new method using a hook... Amos Fong March 21, 2011 8:37 PM
[...] Shahin Ali: Can i change the sorting... Anonymous May 23, 2011 2:06 PM
I'm wondering what is the best way to implement... Jakub Liska August 25, 2011 6:15 AM
I implemented it with Ext, no other means... Jakub Liska August 25, 2011 9:48 AM
@Jakub, do you mean another Document Library... Amos Fong August 25, 2011 7:19 PM
I want to extend the EditPagesAction class of... Rajesh Chaurasia September 18, 2011 7:41 AM
Hi Rajesh, You cannot override struts action... Amos Fong September 18, 2011 11:51 PM
No, you can now. See... Brian Chan September 19, 2011 10:47 AM
[...] The below blog may help on how to extend... Anonymous October 17, 2011 9:02 AM
Thanks Amos! Suraj Bihari November 15, 2011 1:41 PM
Hi Amos, how to make user can post comment ? In... Abu Muhammad November 24, 2011 1:12 AM
In your code you write: throw new... Carlo G. February 13, 2012 9:40 AM
I believe since writing the post it has been... Amos Fong February 13, 2012 10:04 PM
[...] This article will share two cool features... Anonymous May 9, 2012 1:01 PM
Hello Liferay Community, I am very new to... Elijah "Ellie" Mangason May 14, 2012 10:42 AM
@Elijah Yes, you can override... Amos Fong May 16, 2012 3:16 AM
Hello Amos, Thank you for your response. I've... Elijah "Ellie" Mangason May 15, 2012 9:02 AM
Following this post, you would use ext plugin... Amos Fong May 16, 2012 3:25 AM
Thanks, Amos, for your response. I may have to... Elijah "Ellie" Mangason May 16, 2012 8:34 AM
It may not be obvious that it is possible to... Amos Fong May 18, 2012 1:32 AM
It wasn't obvious to me, but I am new to... Elijah "Ellie" Mangason May 22, 2012 11:58 AM
Hi Amos, I have add a custom field in liferay... Sujay Kumar Paul January 21, 2013 2:47 AM
Sujay, Probably the best way to add some... Amos Fong January 24, 2013 3:31 PM
hi amos . how to disable session created after... emad darvishi June 2, 2013 4:25 AM

Thanks for writing this Amos emoticon
Posted on 2/19/10 11:38 PM.
Very nice. Thank you, Amos.
Posted on 2/20/10 2:17 PM.
Great summary Amos, this is very helpful!
Posted on 2/21/10 3:24 PM.
Really helpful!!
Posted on 2/21/10 10:25 PM.
Sir, Thanks for this helpful feature emoticon
Posted on 2/22/10 10:52 PM.
That is very useful ... thank you!
Posted on 2/23/10 12:38 AM.
Nice job Amos.
Posted on 2/23/10 9:26 AM.
Really helpful amos,

Thanks
Posted on 2/25/10 1:40 AM.
Very nice article emoticon

I was trying to use your example but the class "UserLocalServiceWrapper" or "UserWrapper" are not on the liferay distribution (5.2.3), only on SVN, is it possible to use this with the official distribution?

Best Regards,
Joao Sequeira
Posted on 3/3/10 4:44 AM.
Hi Amos,
Thanks for the article I have couple of questions. I am using 5.2.2 in the first half it says about using plugin for extending the user attributes. When I added that in hooks I am getting error about service tags.
Secondly in later part it talks about changing struts xml. Does it need to be done in plugin/hooks?
Please let me know.
Thanks
Posted on 3/9/10 12:27 AM.
Hi Joao,

Sorry I didn't specify versions. Number 1 is only available in 6.0, 5.2 EE SP 2, 5.1 EE SP 5 or later.
Posted on 3/9/10 9:52 AM in reply to Joao Sequeira.
Hi Anand,

Making changes to struts-config.xml has to be done in ext environment.
Posted on 3/9/10 9:54 AM in reply to Anand Barhate.
Nice article, thank you.

I would like to ask you, how is possible to use the extended User object (TestUserImpl) from the test-hook example in a JSP code - f.e. in the portlet/blogs/view.jsp.
It seems the JSP compiler does not see the class, so I cannot import it:

<%@ page import="com.liferay.testhook.hook.model.impl.TestUserImpl" %>

Only a type can be imported. com.liferay.testhook.hook.model.impl.TestUserImpl resolves to a package

Is there an easy way, how to do it?

Thanks.
Posted on 6/12/10 9:27 AM.
Hello
if I want to override the AssetEntryLocalServiceImpl.updateEntry method in a hook, what I have to do?

Extending AssetEntryLocalServiceWrapper seems to be very tricky, because I have to substitute all the *persistence variables with corresponding *LocalServiceUtil class. And it still doesn't work, because how can I replace assetEntryPersistence.setAssetCategories? Does anyone help me?
Posted on 7/22/10 7:03 AM.
See svn://svn.liferay.com/repos/public/plugins/trunk

There's one called /hooks/sample-wrapper-hook

We'll be releasing that soon.
Posted on 7/22/10 2:09 PM in reply to Alessandro Cosenza.
Hi!

I'm triying to override a method in com.liferay.portal.service.LayoutLocalService.

I use this code in liferay-hook.xml:

<service>
<service-type>com.liferay.portal.service.LayoutLocalSe­rvice</service-type>
<service-impl>com.prueba.portal.service.MyLayoutLocalService­</service-impl>
</service>

and override the method in this class (MyLayoutLocalService) (it extends LayoutLocalServiceWrapper).

But when I deploy the hook and use the method, it doesn't use the new method and stills using the old one.

How can I made this work? Where could I find lifeary-hook_6_0_0.dtd?

Kind regards! and thank you for the blog entry!
Posted on 8/12/10 9:09 AM.
Finally I found the problem, there were some code that was executed before tue function I wanted to override, once I remove this wrong code everithing works as expected.
Posted on 8/16/10 6:48 AM in reply to Fernando O.
Hi All,

I need some solution on user management module.

When we create new user in liferay it will go to user_ table in lportal database. But our requirement is we want to store the userdetails to be stored in our database as well.

I mean.. When we create new user, details should be stored in both the database (user_ table in lportal database and user table in our database).

Can anybody suggest where to write the code to do above task?
we are working in ext environment...

Thanks in advance....
Posted on 9/14/10 3:57 AM.
Hi Prasana,

There a couple ways to do this, the best way I can think of is to create a model listener for add user and update user that will update your own database.
Posted on 9/14/10 9:45 AM in reply to Prasanna Kumar.
Amos Fong, Thanks for your reply...

I am very new to liferay Can you explain in detail?
Posted on 9/14/10 10:35 AM.
There is a short tutorial in this wiki:

http://www.liferay.com/community/wiki/-/wiki/Main/Portal+Hook+Plugins

And there is a sample test hook here that has an example of a model listener:

http://svn.liferay.com/repos/public/plugins/trunk/portlets/test-hook-po­rtlet/

user: guest, no password
Posted on 9/14/10 11:05 AM in reply to Prasanna Kumar.
Thanks Amos...

We are using openSSO ... we need to sync openSSO data with liferay data. Can you suggest some solution?
Posted on 9/14/10 11:18 AM.
Hi Amos,
Can you give me some instructions to implement the custom services(which connects to a different database) in liferay action classes. Plz let me know the way to handle creating services through service builder and Spring and Hibernate configurations in the plugin hook.

thanks
prakash
Posted on 10/7/10 9:56 AM.
Hi Amos,
regarding the hint about overriding classes listed in liferay-hook.dtd, I suppose we can't change for example " login.events.post=com.liferay.portal.events.LoginPostAction " to " login.events.post=com.liferay.portal.events.MyOwnLoginPostAction "

in other words, we can override the properties, but the new classes that we need to use instead, like MyOwnLoginPostAction, must be added via ext, right? Overriding portal-impl or portal-service classes, can be done only via ext, except of the custom services that can be overridden by hook.
Posted on 10/18/10 10:37 AM in reply to Amos Fong.
I got it, we can do it. It's like a list of classes that can be overridden no matter if they are portal-impl. It's good to know, thank you Amos
Posted on 10/18/10 11:07 AM in reply to Jakub Liska.
Hi Team,

You need to edit the "struts-config-ext.xml" file to point to your custom Action class.
Assuming Liferay is deployed in "D:\liferay-portal-6.0.5" folder. A blank "struts-config-ext.xml" can be found at
D:\liferay-portal-6.0.5\tomcat-6.0.26\webapps\ROOT\WEB-INF\ folder
<action path="/login/create_account" type="ae.rak.hook.portlet.login.action.MyCreateAccountAction">
<forward name="portlet.login.create_account" path="portlet.login.create_account" />
</action>

Next add the custom action class into the classes folder of the portal.
D:\liferay-portal-6.0.5\tomcat-6.0.26\webapps\ROOT\WEB-INF\classes

It is easy to compile your custom Action java file.
1. Install Liferay IDE
2. Create a new 'Liferay Hook Plug-in Project'
3. Create your custom Action java file & compile
The IDE provides all help in compiling your .java file to a .class file
Posted on 10/26/10 1:30 AM in reply to Amos Fong.
In sample wrapper user of type SampleUserImpl is returned. How can it be accessed from other class??
Posted on 10/28/10 11:30 PM.
Hello,

i use a hook to extend a jsp page and i will use in my jsp a code like this <%@page import="my.packahe.my.classes"%>
where can'i put my jar file?
Posted on 11/8/10 3:59 AM in reply to Sandeep Nair.
Hi.

Does anyone know if it is possible to override a workflow handler via the hook mechanism, or does that need to be done via ext?

Thanks,
Pete
Posted on 11/10/10 6:41 AM.
Hi Peter,
If i listen correctly , you want to override the default workflow thats available in liferay. You can override that by selecting the workflow from controlpanel and paste the XML document thats available in Kaleo-web\web-inf\src\meta-inf\definitions\single-approver.xml. Liferay by default provided single approver workflow , you can override how ever you want by adding multiple tasks and transitions.

And you can add a new workflow using controlpanel also , just go to workflow and click on add and upload the xml document to that ....

thanks
Prakash.
Posted on 11/10/10 8:59 AM in reply to Peter Davison.
Thanks for your reply. Yeah, I've created my own workflow which is essentially the single approver workflow with an additional step added when the workflow is approved. I want to send an email notification out to all interested users that a new piece of content is available in the portal. In this case it happens to be a new document library document.

I want to include in the email a link to the new document. I'm struggling trying to build that URL given the data that is available in the velocity context that is available at the point that the email is generated.

I'd like to override the code that creates the starts the workflow so that the URL to the document (as well as some other data like the list of roles that have access to the folder in which the document lives) is pre-populated in the workflow context. The code I'd like to override is the DLFileEntryWorkflowHandler. This seemed like a good place to build the URL to the newly uploaded document given that the DLFileEntry is passed into the startWorkflowInstance method. The default behaviour of this method (inherited from BaseWorkflowHandler) is to ignore the the model object passed in. I'd like to override that method to do something useful like build the URL to the document and stick it in the workflowContext. I'm attempting to do this via the ext method of overriding but if it is at all possible to do this via a hook I would prefer that approach.

Pete
Posted on 11/10/10 10:54 AM in reply to prakash harigopal.
Hi Deepak,

Is there any way of doing this using the deploy process of a Hook Plug-in?
Posted on 1/21/11 7:52 AM in reply to Deepak Kenchamba.
Thanks Amos, great post, really useful!!!

1. Do you need to override any *Action.java classes?

For doing this couldn't you create a hook pluging?

Thanks in advance,

Luis
Posted on 3/9/11 12:01 AM.
Hi Henrique,

I have tried overriding the action class with a hook plugin, but it seems to be problems with the classloader: http://www.liferay.com/community/forums/-/message_boards/message/7817764#_19_mes­sage_7817764

I am afraid that the EXT approach is going to be the best solution...

Hope it helps,

Luis
Posted on 3/9/11 12:06 AM in reply to Henrique Fernandes.
Hi Amos
If I define new method in TestUserLocalServiceImpl, can I use it in other portlet made by Liferay Plugin SDK?
Can I use hook plugin to define new method in userService?
Thanks.
Posted on 3/17/11 10:35 AM.
No you cannot define a new method using a hook because it doesn't override the Util class, only the Impl class. You should use ext to define a new method in a Liferay Service.
But it actually might be better to create your own service/class so there's better separation between your code and Liferay's.
Posted on 3/21/11 8:37 PM in reply to Nguyen Trung Kien.
[...] Shahin Ali: Can i change the sorting order of message thread posts in the message boards to 'last posted first' present order is first posted first using liferay 6 EE Thanks. Try a hook on the... [...] Read More
Posted on 5/23/11 2:06 PM.
I'm wondering what is the best way to implement custom Store. I'd need an alternative to JcrStore. I'm not using JackRabbit but ModeShape. And I'm wondering if I should use Hook or Ext.
Posted on 8/25/11 6:15 AM in reply to .
I implemented it with Ext, no other means possible I think...
Posted on 8/25/11 9:48 AM in reply to Jakub Liska.
@Jakub, do you mean another Document Library store using this property, (dl.store.impl)? I know it used to be possible and I think it should still be. Did you try specifying that property in your hook's portal.properties and making your store extend BaseStore?
Posted on 8/25/11 7:19 PM in reply to Jakub Liska.
I want to extend the EditPagesAction class of Lifreay I want to add a tab in look and feel section of edit_pages_look_and_feel.jsp.I want to know how I Can use hook here .

public class NPPEditPagesAction extends EditPagesAction {

public void processAction(ActionMapping mapping, ActionForm form,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {

System.out.println("Inside processAction...createTheme()");
String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

try {
if (cmd.equals("createtheme")) {
createTheme(actionRequest);
}

super­.processAction(mapping, form, portletConfig, actionRequest,actionResponse);

} catch (Exception e) {

}
}

public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
RenderRequest renderRequest, RenderResponse renderResponse)
throws Exception {

return super.render(mapping, form, portletConfig, renderRequest, renderResponse);
//return mapping.findForward(getForward(renderRequest, "portlet.communities.edit_pages"));

}

@SuppressWarnings("static-access")
publ­ic static void createTheme(ActionRequest actionRequest) {

System.out.println("Inside createTheme...");
ThemeUtil themeUtil = new ThemeUtil();
final String themeZipFilePath = ThemeUtil.SAMPLE_THEMES_PATH;
final String themeConfigFilePath = ThemeUtil.THEMES_CONFIG_PATH;
try{
//To Modify liferay-look-and-feel.xml
themeUtil.getXMLDetails(themeConfigFilePath);
­
//To Extract the sample themes zip folder to tomcat location
themeUtil.extractFolder(themeZipFilePath);

} catch (Exception ex) {
ex.printStackTrace();
}

}

<custom-jsp-dir>/WEB-INF</custom-jsp-dir>
<­struts-action>
<struts-action-path>/layout_management/edit_pages</struts-actio­n-path>
<struts-action-impl>com.liferay.portlet.communities.action.NPPEditPage­sAction</struts-action-impl>
</struts-action>

I am unable to execute my java code.please let me know where I am going wrong
Posted on 9/18/11 7:41 AM.
Hi Rajesh,

You cannot override struts action in a hook. You'll need to use the ext-plugin/environment to do that.
Posted on 9/18/11 11:51 PM in reply to Rajesh Chaurasia.
No, you can now.

See http://www.liferay.com/web/mika.koivisto/blog/-/blogs/overriding-and-adding-stru­ts-actions-from-hook-plugins
Posted on 9/19/11 10:47 AM in reply to Amos Fong.
[...] The below blog may help on how to extend a services via hook. http://www.liferay.com/web/amos.fong/blog/-/blogs/minimizing-the-ext-environment­ Mark as an Answer [...] Read More
Posted on 10/17/11 9:02 AM.
Thanks Amos!
Posted on 11/15/11 1:41 PM.
Hi Amos, how to make user can post comment ? In my liferay, error "Blogs in temporarily unavailable" when submit comment.
Posted on 11/24/11 1:12 AM in reply to Suraj Bihari.
In your code you write:

throw new RequiredFieldException("favoriteColor", "favoriteColorLabel"); // v6.0/EE specific code

Is there a suitable exception in the Community Edition (6.1) ?
Posted on 2/13/12 9:40 AM in reply to Abu Muhammad.
I believe since writing the post it has been added to CE so it should be in 6.1.
Posted on 2/13/12 10:04 PM in reply to Carlo G..
[...] This article will share two cool features - Hooks and Plugins Ext - in Liferay portal 6. Speciall thanks to Amos Fong, so that we could minimize the ext environment by using hooks. A lot of thanks to... [...] Read More
Posted on 5/9/12 1:01 PM.
Hello Liferay Community,

I am very new to Liferay, and am trying to program a Hook using 6.1 that will override CreateAccountAction as shown in this post. Is it possible??? If not, in what type of Liferay project would one include the code shown in this post (i.e. ext, new portlet, etc.)
Thanks in advance for your response. I'm really stuck!

E.
Posted on 5/14/12 10:42 AM.
@Elijah
Yes, you can override CreateAccountAction in hook now, not by methods in this post, but see this post:
http://www.liferay.com/web/mika.koivisto/blog/-/blogs/overriding-and-adding­-struts-actions-from-hook-plugins
Posted on 5/16/12 3:16 AM in reply to Elijah Mangason.
Hello Amos,

Thank you for your response.

I've read link on overriding struts actions several times. It is mentioned in the link that only two interfaces can be overridden: BaseStrutsPortletAction and BaseStrutsAction. Neither of these allows for directly extending CreateAccountAction, which is in portal-impl.jar.

I need to validate existing users on login by simply comparing their input with what is already in the database. I would like to extend and override CreateAccountAction.java to do this, as you have shown above in THIS post. To implement as above, where would I place the code, in a hook, ext? Your help would be greatly appreciated.

E.
Posted on 5/15/12 9:02 AM in reply to Amos Fong.
Following this post, you would use ext plugin and edit struts-action-ext.xml to point to your own implementation.
Posted on 5/16/12 3:25 AM in reply to Elijah Mangason.
Thanks, Amos, for your response. I may have to do my implementation as an ext plugin rather than a hook. I'm wondering, however, how what you have shown in this post minimizes the ext environment if it needs to be implemented as an ext anyway. Could you please clarify?
Posted on 5/16/12 8:34 AM in reply to Amos Fong.
It may not be obvious that it is possible to extend struts action classes through struts-config-ext.xml rather than having override the entire class which is more work and less maintainable. So this was just a tip for those who weren't already aware of it.
Posted on 5/18/12 1:32 AM in reply to Elijah Mangason.
It wasn't obvious to me, but I am new to Liferay, so that may be the reason why.
Is there a tutorial or working example I could reference on how to extend or access methods within a struts action class such as CreateAccountAction without overriding the entire class? I've reference the post from Mika Koivisto (http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115) several times.... what am I missing?
Posted on 5/22/12 11:58 AM in reply to Amos Fong.
Hi Amos,

I have add a custom field in liferay 6.1 create account screen .
the new field is "Phone Number"
But i can not add validation for this custom field such as the Phone number should start with 9 ,8 or 7 as well as the length should not more than 10 digit etc.
In future i will add more custom field with validation.
How can i do it?

I had create a hook for it & modify the create_account.jsp page & add this chunk of code to display it
<!-- add for phone -->
<liferay-ui:custom-attribute className="com.liferay.portal.model.User"
classPK="<%= 0l %>"
editable="<%= true %>"
label="<%= true %>"
name="Phone No"
/>
Posted on 1/21/13 2:47 AM.
Sujay,

Probably the best way to add some validation is to use a struts-action hook for createAccountAction.java using the methods from Mika's blog: http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115
Posted on 1/24/13 3:31 PM in reply to sujay paul.
hi amos .

how to disable session created after logout? please help me.
Posted on 6/2/13 4:25 AM.