This content has been marked as final.
Show 5 replies
-
1. Re: To get the parameter values from Http Request
ericjava.eric.chiralsoftware.net Jul 28, 2008 9:02 AM (in response to knhsinbad)Very easily! In your bean, put something like:
@RequestParameter private String myParameter;
and your URL looks like:
http://localhost:8080/my-page.seam?myParameter=Hello
and it will work as expected.
-
2. Re: To get the parameter values from Http Request
edrusiani2009 Sep 23, 2008 11:05 AM (in response to knhsinbad)<blockquote>
_Eric H wrote on Jul 28, 2008 09:02:_<br/>
Very easily! In your bean, put something like:
`@RequestParameter private String myParameter;`
and your URL looks like:
`http://localhost:8080/my-page.seam?myParameter=Hello`
and it will work as expected.
</blockquote>
hi!
sorry to disturb, but that doesn't work for me.
i've got my page at http://localhost:8080/app/home.seam
and i access it as http://localhost:8080/app/home.seam?skin=testskin
my pages.xml defines
<page view-id="/home.xhtml" action="#{startup.test}" />
startup is
@Name("startup")
@Scope(ScopeType.SESSION)
public class StartupAction extends MyAction {
public static Logger logger;
@RequestParameter private String skin;
...
public String test(){
logger.info("calling startupAction.test");
javax.faces.context.FacesContext facesContext = javax.faces.context.FacesContext.getCurrentInstance();
ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
Enumeration enumer = request.getParameterNames();
while(enumer.hasMoreElements()){
logger.error("Request Parameters: "+ enumer.nextElement());
}
param2 = request.getParameter("skin");
logger.error("Parameter : " + param2);
logger.error("Injected Parameter: " + skin);
return "";
}
but i can't get the parameter in either way. Any suggestion?
Thanks a lot for your time -
3. Re: To get the parameter values from Http Request
nickarls Sep 23, 2008 11:42 AM (in response to knhsinbad)not sure if you can have the var private.
You could also use ServletContexts.getInstance().getRequest()...
-
4. Re: To get the parameter values from Http Request
edrusiani2009 Sep 23, 2008 2:52 PM (in response to knhsinbad)ServletContexts seems something from Seam 2.x, i'm planning to upgrade my application, but i've got some deadlines before doing that :)
is there a Seam 1.x equivalent?
-
5. Re: To get the parameter values from Http Request
edrusiani2009 Oct 14, 2009 6:21 PM (in response to knhsinbad)<blockquote>
_Nicklas Karlsson wrote on Sep 23, 2008 11:42:_<br/>
not sure if you can have the var private.
You could also use ServletContexts.getInstance().getRequest()...
</blockquote>
hi!
i've upgraded to Seam 2 and your suggestion works perfectly. But if i change the parameter on the URL and hit the enter button, the page doesn't reload. it doesn't even enter the action method.
i tried adding " on-postback="true" " to the action in pages.xml but nothing changed.
any suggestion?