Fórumok

How to modify actionRequest parameter in processAction Login Strut?

Marco Núñez Arrieta, módosítva 10 év-val korábban

How to modify actionRequest parameter in processAction Login Strut?

New Member Bejegyzések: 10 Csatlakozás dátuma: 2012.09.03. Legújabb bejegyzések
Hi everyone!!!

I'm trying to modify a variable (login) in the actionRequest object parameter whith another parameter (idtype) before send it to the originalStrutsPortletAction.processAction, but after use the setAttribute method, it doesn't apply the change. There's a portion of my code:

public class LoginAction extends BaseStrutsPortletAction {

@Override
public void processAction(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {

String idtype = ParamUtil.getString(actionRequest, "idtype");
String login = ParamUtil.getString(actionRequest, "login");

actionRequest.setAttribute("login",idtype+"-"+login);

originalStrutsPortletAction.processAction(
originalStrutsPortletAction, portletConfig, actionRequest,
actionResponse);
}

Here I'm expecting a login attribute like: CI-205750539 but it doesn't work...

Any help please!!!
Michal R, módosítva 10 év-val korábban

RE: How to modify actionRequest parameter in processAction Login Strut?

Junior Member Bejegyzések: 25 Csatlakozás dátuma: 2012.05.28. Legújabb bejegyzések
You cannot change login directly as it is a parameter, not an attribute. Parameters of actionRequest instance are immutable.
However, you can wrap the original actionRequest with a DynamicActionRequest and then change the login.
And then pass the dynamicActionRequest to originalStrutsPortletAction.processAction().

	public void processAction(StrutsPortletAction originalStrutsPortletAction,
			PortletConfig portletConfig, ActionRequest actionRequest,
			ActionResponse actionResponse) throws Exception {

		String login = ParamUtil.getString(actionRequest, "login");

		DynamicActionRequest actionRequestNew = new DynamicActionRequest(actionRequest);
		actionRequestNew.setParameter("login", login + "++");

		originalStrutsPortletAction.processAction(originalStrutsPortletAction,
				portletConfig, actionRequestNew, actionResponse);
	}