You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by 梁炳場 <pc...@gmail.com> on 2005/10/07 17:03:30 UTC

set different attribute according to the change of parameter

Can I do the following?

Same action class sets different attribute
according to the change of parameter?

Thanks

<action path="/userProfileMaint"
	type="com.erp.struts.SetRoleHref"
	parameter="userProfileMaint"

<action path="/quotationMaint"
	type="com.erp.struts.SetRoleHref"
	parameter="quotationMaint"

public class SetRoleHref extends Action {
	    String myValue = request.getParameter("parameter");
	    session.setAttribute("rolehref", myValue);

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: set different attribute according to the change of parameter

Posted by 梁炳場 <pc...@gmail.com>.
My action class like this

public ActionForward userProfileMaint (ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) throws Exception {
		HttpSession session = request.getSession();	
		session.setAttribute("rolehref", "userProfileMaint");
		return mapping.findForward("success");
	}

my struts-config.xml

	<action path="/userProfileMaint"
	type="com.erp.struts.SetRoleHref"
	parameter="userProfileMaint"
	scope="request">
	<forward name="success" path="user.showRoleProgram" />
	</action>

The result is
javax.servlet.ServletException: Request[/userProfileMaint] does not
contain handler parameter named 'userProfileMaint'. This may be caused
by whitespace in the label text.

What can I do?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: set different attribute according to the change of parameter

Posted by 梁炳場 <pc...@gmail.com>.
Should the parameter be passed into Action class by
http://xxx/foo?a=b ?

Can the Action class get the parameter value
and the link is http://xxx/foo only?

I do not want the parameter appear in the URL.

Thanks

2005/10/8, Laurie Harper <la...@holoweb.net>:
> 梁炳場 wrote:
> > Can I do the following?
> >
> > Same action class sets different attribute
> > according to the change of parameter?
> >
> > Thanks
> >
> > <action path="/userProfileMaint"
> >       type="com.erp.struts.SetRoleHref"
> >       parameter="userProfileMaint"
> >
> > <action path="/quotationMaint"
> >       type="com.erp.struts.SetRoleHref"
> >       parameter="quotationMaint"
> >
> > public class SetRoleHref extends Action {
> >           String myValue = request.getParameter("parameter");
> >           session.setAttribute("rolehref", myValue);
>
> Sure, you can do that, except that the 'parameter' attribute in the
> action mapping isn't exposed as a request parameter (those come from the
>  HTTP request). You need to call getParameter() on the ActionMapping
> instance instead.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: set different attribute according to the change of parameter

Posted by Laurie Harper <la...@holoweb.net>.
梁炳場 wrote:
> Can I do the following?
> 
> Same action class sets different attribute
> according to the change of parameter?
> 
> Thanks
> 
> <action path="/userProfileMaint"
> 	type="com.erp.struts.SetRoleHref"
> 	parameter="userProfileMaint"
> 
> <action path="/quotationMaint"
> 	type="com.erp.struts.SetRoleHref"
> 	parameter="quotationMaint"
> 
> public class SetRoleHref extends Action {
> 	    String myValue = request.getParameter("parameter");
> 	    session.setAttribute("rolehref", myValue);

Sure, you can do that, except that the 'parameter' attribute in the 
action mapping isn't exposed as a request parameter (those come from the 
  HTTP request). You need to call getParameter() on the ActionMapping 
instance instead.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org