掲示板

Access built-in MVCActionCommand from a fragment.

7年前 に Csaba Meszaros によって更新されました。

Access built-in MVCActionCommand from a fragment.

Junior Member 投稿: 42 参加年月日: 13/10/10 最新の投稿
Hello! I have a quite difficult task to accomplish: I need to change the registration form and add a new fields.
What I've done is I made a fragment, which successfully overrides the create_account.jsp.
Then, I modified this jsp, added some extra fields and tried to change the form's submit command, from the built-in CreateAccountMVCActionCommand to something else, which is also an MVCActionCommand, but resides in an other CustomLoginPortlet module. It looks like this:

@Component(
	    immediate = true,
	    property = {
	        "javax.portlet.name=CustomLoginPortlet",
	        "javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet",
	        "javax.portlet.name=my.fragment.project",
	        "mvc.command.name=/com/msz/mylogin",
	        "service.ranking:Integer=100" 
	    },
	    service = MVCActionCommand.class
	)

public class CustomLoginActionCommand extends BaseMVCActionCommand {	
	
	
	@Override
	protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
		
			String cmd = ParamUtil.getString(actionRequest, "adoszam");
			System.out.println("Called: "+cmd);
		 mvcActionCommand.processAction(actionRequest, actionResponse);
	}
	public MVCActionCommand getMvcActionCommand() {
		return mvcActionCommand;	}
	@Reference(target = "(&(mvc.command.name=/login/create_account)(javax.portlet.name=com_liferay_login_web_portlet_LoginPortlet))")
	
	public void setMvcActionCommand(MVCActionCommand mvcActionCommand) {
		this.mvcActionCommand = mvcActionCommand;
	}	
	
	protected MVCActionCommand mvcActionCommand;
	
	protected MVCActionCommand myCommand;

}


Of course it throws an error: javax.portlet.PortletException: javax.portlet.PortletException: processAction method not implemented
since it really isn't implemented in MVCActionCommand class.
I would like to hijack the process, to get this CreateAccountMVCActionCommand class' instance in my portlet containing this command, in order to forward the parameters to original command, after I extract the custom parameters from request.

Can you help me how to achieve this goal?