Forums de discussion

[Liferay 6.0.5] Extending CreateAccountAction

Christophe Schutz, modifié il y a 13 années.

[Liferay 6.0.5] Extending CreateAccountAction

New Member Publications: 6 Date d'inscription: 10/11/10 Publications récentes
Hello everyone.

I'm new to Liferay and i'm trying to extend the form for the creation of an user. What i'm trying to do is adding fields into the JSP file using hooks (that part is done already) and extending the CreateAccountAction.class. I've been working on Liferay 5.2.3 for some weeks but it's kind of different especially given there is no more ext environment.

Basically, all I need to do is to add some variables to the CreateAccountAction.class and some SQL functionnality which will add informations on an external database.

I've tried to do it with this link but it's just roughly explained and I don't really know where to put that class. I've put it in {Liferay}SDK\hooks\inscription-hook\docroot\WEB-INF\src\com\liferay\portlet\login\action and named it TestCreateAccountAction, but when I try to deploy it doesn't work (can't find all the references since it's in a totally different folder).

My class looks like this :
public class TestCreateAccountAction extends CreateAccountAction {

	

	protected void addUser(
			ActionRequest actionRequest, ActionResponse actionResponse)
		throws Exception {

		String userId = String.valueOf(user.getUserId());
		String refEnergie = ParamUtil.getString(actionRequest, "refClientEnergie");
		String com = ParamUtil.getString(actionRequest, "commune");
		String numV = ParamUtil.getString(actionRequest, "numVoie");
		String typeV = ParamUtil.getString(actionRequest, "typeVoie");
		String nomV = ParamUtil.getString(actionRequest, "nomVoie");
		System.out.println("\n\n\n\n\n\n"+com+"\n"+numV+"\n"+refEnergie);
		
		String requete = "INSERT INTO ext_user VALUES('" + userId + "','" + refEnergie + "','" + com + "','" + numV + "','" + typeV + "','" + nomV + "')";
		Statement opstmt = null;
    	try
    	{
    		opstmt = ConnexionLiferay.getInstanceLIFERAY().createStatement();
    		opstmt.executeUpdate(requete);
    	}
    	catch (SQLException e1) { e1.printStackTrace(); }
    	finally
    	{
    		try { opstmt.close(); }
			catch (SQLException ex) { Logger.getLogger(CreateAccountAction.class.getName()).log(Level.SEVERE, null, ex); }
    	}
		
		super.addUser(actionRequest, actionResponse);
	}
}




Any help regarding the way to customize those classes using the SDK would be appreciated.

Thanks a lot
Christophe Schutz, modifié il y a 13 années.

RE: [Liferay 6.0.5] Extending CreateAccountAction

New Member Publications: 6 Date d'inscription: 10/11/10 Publications récentes
Okay, i've actually found that I need to make a Ext Plugin to make this work. I created one and in \ext-impl\src i've put two classes (ConnexionLiferay which contains the code for connecting to the external database, and CreateAccountBDD which extends CreateAccountAction)

When I try to deploy the plugin though, i get 12 errors, mostly "cannot find symbol". Dunno how to link the necessary .jars so that it finds all the needed classes...

Any help about how to make this work ?
Christophe Schutz, modifié il y a 13 années.

RE: [Liferay 6.0.5] Extending CreateAccountAction

New Member Publications: 6 Date d'inscription: 10/11/10 Publications récentes
Fwiw I can't even find the CreateAccountAction.class in the Liferay portal 6.0... can anyone at least give me the directory ? Can't find com.liferay.portal.login anywhere, or even portal-impl.

There's something I gotta have misunderstood trough all those guides I think
thumbnail
prakash harigopal, modifié il y a 13 années.

RE: [Liferay 6.0.5] Extending CreateAccountAction

Regular Member Publications: 101 Date d'inscription: 23/06/10 Publications récentes
Hi Chris,

You are going in the correct way but few changes are needed. If you want to override the AddUser functionality , follow the below steps in Plugins EXT.

1 Create the Plugins EXT project using SDK
2 Create a class EXTCreateAccountAction which extends CreateAccountAction under ext-impl folder in plugins ext and have the new methods.
3 Add the EXTCreateAccountAction entry in struts-config-ext.xml in ext-web/docroot/web-inf

<action path="/login/create_account" type="com.liferay.portlet.login.action.EXTCreateAccountAction">
<forward name="portlet.login.create_account" path="portlet.login.create_account" />
</action>

Deploy the plugins ext now , it will take the newly added class instead of CreateAccountAction and will execute the overridden functionality only.

And if you want to implement Custom Services in Plugins SDK and integrate them with LR functionality , see this link.

thanks
Prakash.
Christophe Schutz, modifié il y a 13 années.

RE: [Liferay 6.0.5] Extending CreateAccountAction

New Member Publications: 6 Date d'inscription: 10/11/10 Publications récentes
Sorry for the delay, I wasn't at work the whole end of last week and I just tried your suggestions.

Your solution didn't help, I guess I had to overwrite the struts-config-ext.xml anyways for the new class to take effect once it will be deployed, but the problem is there are compilation errors.


C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext&gt;ant deploy
Buildfile: C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\build.xml

compile:

compile-with-global-class-loader:

compile-java:

compile-with-global-class-loader:

compile-java:

compile-with-global-class-loader:

compile-java:

compile-with-portal-class-loader:

compile-java:

compile-with-portal-class-loader:

compile-java:
    [javac] Compiling 2 source files to C:\portail-6.0.5\SDK\ext\CreateAccountBD
D-ext\docroot\WEB-INF\ext-impl\classes
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:1: cannot find sym
bol
    [javac] symbol: class CreateAccountAction
    [javac] public class CreateAccountBDD extends CreateAccountAction {
    [javac]                                       ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:4: cannot find sym
bol
    [javac] symbol  : class ActionRequest
    [javac] location: class CreateAccountBDD
    [javac]                     ActionRequest actionRequest, ActionResponse acti
onResponse)
    [javac]                     ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:4: cannot find sym
bol
    [javac] symbol  : class ActionResponse
    [javac] location: class CreateAccountBDD
    [javac]                     ActionRequest actionRequest, ActionResponse acti
onResponse)
    [javac]                                                  ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:7: cannot find sym
bol
    [javac] symbol  : variable user
    [javac] location: class CreateAccountBDD
    [javac]             String userId = String.valueOf(user.getUserId());
    [javac]                                            ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:8: cannot find sym
bol
    [javac] symbol  : variable ParamUtil
    [javac] location: class CreateAccountBDD
    [javac]             String refEnergie = ParamUtil.getString(actionRequest, "
refClientEnergie");
    [javac]                                 ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:9: cannot find sym
bol
    [javac] symbol  : variable ParamUtil
    [javac] location: class CreateAccountBDD
    [javac]             String com = ParamUtil.getString(actionRequest, "commune
");
    [javac]                          ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:10: cannot find sy
mbol
    [javac] symbol  : variable ParamUtil
    [javac] location: class CreateAccountBDD
    [javac]             String numV = ParamUtil.getString(actionRequest, "numVoi
e");
    [javac]                           ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:11: cannot find sy
mbol
    [javac] symbol  : variable ParamUtil
    [javac] location: class CreateAccountBDD
    [javac]             String typeV = ParamUtil.getString(actionRequest, "typeV
oie");
    [javac]                            ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:12: cannot find sy
mbol
    [javac] symbol  : variable ParamUtil
    [javac] location: class CreateAccountBDD
    [javac]             String nomV = ParamUtil.getString(actionRequest, "nomVoi
e");
    [javac]                           ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:16: cannot find sy
mbol
    [javac] symbol  : class Statement
    [javac] location: class CreateAccountBDD
    [javac]             Statement opstmt = null;
    [javac]             ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:19: cannot find sy
mbol
    [javac] symbol  : variable ConnexionLiferay
    [javac] location: class CreateAccountBDD
    [javac]                     opstmt = ConnexionLiferay.getInstanceLIFERAY().c
reateStatement();
    [javac]                              ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:22: cannot find sy
mbol
    [javac] symbol  : class SQLException
    [javac] location: class CreateAccountBDD
    [javac]             catch (SQLException e1) { e1.printStackTrace(); }
    [javac]                    ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:26: cannot find sy
mbol
    [javac] symbol  : class SQLException
    [javac] location: class CreateAccountBDD
    [javac]                     catch (SQLException ex) { Logger.getLogger(Creat
eAccountAction.class.getName()).log(Level.SEVERE, null, ex); }
    [javac]                            ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:26: cannot find sy
mbol
    [javac] symbol  : variable Level
    [javac] location: class CreateAccountBDD
    [javac]                     catch (SQLException ex) { Logger.getLogger(Creat
eAccountAction.class.getName()).log(Level.SEVERE, null, ex); }
    [javac]
                                    ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:26: cannot find sy
mbol
    [javac] symbol  : class CreateAccountAction
    [javac] location: class CreateAccountBDD
    [javac]                     catch (SQLException ex) { Logger.getLogger(Creat
eAccountAction.class.getName()).log(Level.SEVERE, null, ex); }
    [javac]                                                                ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:26: cannot find sy
mbol
    [javac] symbol  : variable Logger
    [javac] location: class CreateAccountBDD
    [javac]                     catch (SQLException ex) { Logger.getLogger(Creat
eAccountAction.class.getName()).log(Level.SEVERE, null, ex); }
    [javac]                                               ^
    [javac] C:\portail-6.0.5\SDK\ext\CreateAccountBDD-ext\docroot\WEB-INF\ext-im
pl\src\com\liferay\portlet\login\action\CreateAccountBDD.java:29: cannot find sy
mbol
    [javac] symbol  : variable super
    [javac] location: class CreateAccountBDD
    [javac]             super.addUser(actionRequest, actionResponse);
    [javac]             ^
    [javac] 17 errors

BUILD FAILED
C:\portail-6.0.5\SDK\ext\build-common-ext.xml:139: The following error occurred
while executing this line:
C:\portail-6.0.5\SDK\ext\build-common-ext.xml:188: The following error occurred
while executing this line:
C:\portail-6.0.5\SDK\build-common.xml:90: Compile failed; see the compiler error
 output for details.

Total time: 4 seconds


ConnexionLiferay is another Class which enables a connection to an external database.

Is there any config file to modify, like portal-ext or something like that, in the Ext Plugin ? Am I doing my deploy the right way ?

It looks like when he compiles, he can't find the CreateAccountAction.class, which then leads to all of the next errors since he doesn't have all the needed imports.
thumbnail
prakash harigopal, modifié il y a 13 années.

RE: [Liferay 6.0.5] Extending CreateAccountAction

Regular Member Publications: 101 Date d'inscription: 23/06/10 Publications récentes
Looks like your build is causing the issue. Check your build properties in SDK , whether its pointing to the exact App server and Liferay ROOT folder and able to pick the jars required.
It mainly requires portal-service.jar , other than that evything seems ok.


regds
Prakash.
Nicholas Tenczar, modifié il y a 13 années.

RE: [Liferay 6.0.5] Extending CreateAccountAction

Junior Member Publications: 53 Date d'inscription: 15/07/10 Publications récentes
Just a minor clarification: The CreateAccountAction is located under com.liferay.portlet.login.action and not com.liferay.portal.login.action.
thumbnail
Apoorva Prakash, modifié il y a 13 années.

RE: [Liferay 6.0.5] Extending CreateAccountAction

Liferay Master Publications: 658 Date d'inscription: 15/06/10 Publications récentes
Christophe Schutz:
Hello everyone.

I'm new to Liferay and i'm trying to extend the form for the creation of an user. What i'm trying to do is adding fields into the JSP file using hooks (that part is done already) and extending the CreateAccountAction.class. I've been working on Liferay 5.2.3 for some weeks but it's kind of different especially given there is no more ext environment.

Basically, all I need to do is to add some variables to the CreateAccountAction.class and some SQL functionnality which will add informations on an external database.

I've tried to do it with this link but it's just roughly explained and I don't really know where to put that class. I've put it in {Liferay}SDK\hooks\inscription-hook\docroot\WEB-INF\src\com\liferay\portlet\login\action and named it TestCreateAccountAction, but when I try to deploy it doesn't work (can't find all the references since it's in a totally different folder).

My class looks like this :
public class TestCreateAccountAction extends CreateAccountAction {

	

	protected void addUser(
			ActionRequest actionRequest, ActionResponse actionResponse)
		throws Exception {

		String userId = String.valueOf(user.getUserId());
		String refEnergie = ParamUtil.getString(actionRequest, "refClientEnergie");
		String com = ParamUtil.getString(actionRequest, "commune");
		String numV = ParamUtil.getString(actionRequest, "numVoie");
		String typeV = ParamUtil.getString(actionRequest, "typeVoie");
		String nomV = ParamUtil.getString(actionRequest, "nomVoie");
		System.out.println("\n\n\n\n\n\n"+com+"\n"+numV+"\n"+refEnergie);
		
		String requete = "INSERT INTO ext_user VALUES('" + userId + "','" + refEnergie + "','" + com + "','" + numV + "','" + typeV + "','" + nomV + "')";
		Statement opstmt = null;
    	try
    	{
    		opstmt = ConnexionLiferay.getInstanceLIFERAY().createStatement();
    		opstmt.executeUpdate(requete);
    	}
    	catch (SQLException e1) { e1.printStackTrace(); }
    	finally
    	{
    		try { opstmt.close(); }
			catch (SQLException ex) { Logger.getLogger(CreateAccountAction.class.getName()).log(Level.SEVERE, null, ex); }
    	}
		
		super.addUser(actionRequest, actionResponse);
	}
}




Any help regarding the way to customize those classes using the SDK would be appreciated.

Thanks a lot



Hello Schutz,

I've done the same task with some other task, hope this can help you...
See this link...

Thanks and Regards...
Christophe Schutz, modifié il y a 13 années.

RE: [Liferay 6.0.5] Extending CreateAccountAction

New Member Publications: 6 Date d'inscription: 10/11/10 Publications récentes
Hello.

I still can't get it to work, and it's making me lose a loooot of time. Here's what I've done :
-Create a hook for the new JSP page (works)
-Create a ExtPlugin for the new Classes (works)
-Modified the build.SCHUTZ.properties :

app.server.dir=C:/portal-6/liferay-portal-6.0.5/tomcat-6.0.26
ext.work.dir=C:/portal-6/work 

-Added the new class into C:\portal-6\SDK\ext\CreateAccount-ext\docroot\WEB-INF\ext-impl\src\com\liferay\portlet\login\action
-Modifier the struts-config-ext.xml in C:\portal-6\SDK\ext\CreateAccount-ext\docroot\WEB-INF\ext-web\docroot\WEB-INF to :
<!--?xml version="1.0"?-->


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


</struts-config>


My class is really easy, it's just to test :
public class CreateAccountBDD extends CreateAccountAction {
	protected void test(){}
}


And when I to ant deploy in C:\portal-6\SDK\ext\CreateAccount-ext it says :

C:\portal-6\SDK\ext\CreateAccount-ext&gt;ant deploy
Buildfile: C:\portal-6\SDK\ext\CreateAccount-ext\build.xml

compile:

compile-with-global-class-loader:

compile-java:

compile-with-global-class-loader:

compile-java:

compile-with-global-class-loader:

compile-java:

compile-with-portal-class-loader:

compile-java:

compile-with-portal-class-loader:

compile-java:
    [javac] Compiling 1 source file to C:\portal-6\SDK\ext\CreateAccount-ext\doc
root\WEB-INF\ext-impl\classes
    [javac] C:\portal-6\SDK\ext\CreateAccount-ext\docroot\WEB-INF\ext-impl\src\c
om\liferay\portlet\login\action\CreateAccountBDD.java:1: cannot find symbol
    [javac] symbol: class CreateAccountAction
    [javac] public class CreateAccountBDD extends CreateAccountAction {
    [javac]                                       ^
    [javac] 1 error

BUILD FAILED
C:\portal-6\SDK\ext\build-common-ext.xml:139: The following error occurred while
 executing this line:
C:\portal-6\SDK\ext\build-common-ext.xml:188: The following error occurred while
 executing this line:
C:\portal-6\SDK\build-common.xml:90: Compile failed; see the compiler error outp
ut for details.

Total time: 3 seconds
C:\portal-6\SDK\ext\CreateAccount-ext&gt;


So basically it can't find the class.


I've actually analyzed the liferay bundled with tomcat, and the structure is totally different to the portal source alone. Actually, there's no where something like "portal-imp" with the com.liferay.portlet.login.action.CreateAccountAction. So in my mind it's pretty obvious why it doesn't work, but everyone uses Liferay bundled with Tomcat, and it works Oo

Can someone explain me how it work given there's no portal-impl folder, which contais com.liferay.portlet.login.action like there is in the portal source alone (not bundled with tomcat), and try to explain what i'm doing wrong ??? for what it's worth, my portal-ext.properties in C:\portal-6\SDK\ext\CreateAccount-ext\docroot\WEB-INF\ext-impl\src is empty, maybe that's the problem ????

I'm really lost here...