-
1. Re: Propagating Request Parameters
aravindkosuri Sep 24, 2009 3:32 AM (in response to mcohnen)Pass parameter like below. If you want to run in same workspace or conversation also conversationId.
<h:commandLink value="Open" action="#{commandLinkAction.getMetadata}">
<s:conversationId />
<f:param name="itemId" value="itemIdValue" />
</h:commandLink>
Let me know if you have any issues. -
2. Re: Propagating Request Parameters
mcohnen Sep 24, 2009 1:28 PM (in response to mcohnen)Hi,
Thank you for your answer, but it is still not working.
With your approach, what you manage is to pass the parameter so that it is available for your action#{commandLinkAction.getMetadata}
to use. But the resultant url after clicking that link is not containing itemId as paramter! I have made a simple example:
hello.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:s="http://jboss.com/products/seam/taglib" contentType="text/html"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Hello</title> </head> <body> <h:form> --#{helloAction.text}-- <h:commandLink action="#{helloAction.sayHello}" value="Say Hello"> <f:param name="helloId" value="#{helloAction.helloId}"/> </h:commandLink> </h:form> </body> </html> </f:view>
HelloAction.java
@Name("helloAction") @Scope(ScopeType.CONVERSATION) public class HelloAction { @RequestParameter private Long helloId; private String text = ""; public String getText(){ return text; } @Begin(join=true) public void sayHello(){ text = "Hello World - "+helloId; } public Long getHelloId() { return helloId; } public void setHelloId(Long helloId) { this.helloId = helloId; } }
If I call the url
http://SERVER/APP/hello.seam?helloId=10
, I receive this screen:
---- Say Hello
When I click in the link I get this one:
--Hello World - 10-- Say Hello
Which is fine, but the url is now
http://SERVER/APP/hello.seam
The paramter is missing!!! I need the url to be the same than before. Using s:link I have the same url, but it also appends some other info (actionMethod... cid...) That i don't want in my url.
Hope this clarifies my proble a bit.
-
3. Re: Propagating Request Parameters
fup Sep 24, 2009 2:06 PM (in response to mcohnen)You could perform a redirect to the same page after your action method is invoked to restore the URL plus helloId.
<navigation from-action="#{helloAction.sayHello}">
<redirect view-id="#{view.viewId}" />
</navigation>The helloId should be a page parameter.
-
4. Re: Propagating Request Parameters
mcohnen Sep 24, 2009 3:44 PM (in response to mcohnen)Thank you Frank. That worked great! Is this the recommended way doing this? I mean, is this the recommended way of doing redirect after post? Anyway, it is damn simple and clean. I like it!
Thank you VERY MUCH!
-
5. Re: Propagating Request Parameters
fup Sep 24, 2009 4:00 PM (in response to mcohnen)This approach to get bookmarkable URLs is described in the Seam Reference (1.9.2. Bookmarkable search results page). Perhaps, the redirect is a problem in some cases: page scoped components get lost, I think, page actions are executed again. At least for my use cases, it worked fine.