0

this question is "extending" the following post

Handling view parameters in JSF after post

Asume that I'm creating an custom URL that I'm opening in a dialog. URL example "test.html?id=123"

I want to insert the "id=123" part into the h:form action so that it returns back to the same view with the extra parameter "id=123" part.

I have followed the above post and worked on the third solution, the custom ViewHandler that extends ViewHandlerWrapper.

I'm modifying the action and the form gets redirected to the same origin (until now it works).

First issue Lets say I have the following xhtml page.

<f:metadata>
    <f:event type="preRenderView" listener="#{bean.init}" />
    <f:viewParam name="id" value="#{bean.id}"/>
</f:metadata>

<h:form>
    ...
    ...
</h:form>
  1. When i post the above i get the correct id value on the back end.
  2. If i resubmit the post i get null values, the url however stays the same (test.html?id=xxx)
  3. Cant figure out why i'm getting null values on the second submit

Second issue is that when I have validated the form and everything is fine, my submit method returns back a new url "test.html?force-redirect=true..." but this does not happen, instead the URL is the same as the one entered in the h:form action, (if i make a custom redirect with the new URL then it works and i get redirected to "test.html?faces-redirect=true...").

My question, I guess is a theoretical one, is this the supposed behavior?

Thanks, Dimman

Community
  • 1
  • 1
Dimman
  • 1,186
  • 4
  • 14
  • 21
  • Your first problem is unclear. Please elaborate. Your second problem has a typo in the parameter name. You should be using `faces-redirect=true`. Is this an oversight? – BalusC Oct 18 '12 at 11:09
  • @BalusC thanks for your quick comment, i edited my question, i typed it wrong, it's faces-redirect=true – Dimman Oct 18 '12 at 11:49
  • I can't reproduce your problem based on the information provided so far (Mojarra 2.1.13 + Tomcat 7.0.30). Perhaps your dialog is actually in a different view? – BalusC Oct 18 '12 at 12:16
  • The dialog opens up in a new window, but is redirected on the same again and again (by saying the same i mean the newly opened one). I will past the code when i get home, if that helps. Thanks once again – Dimman Oct 18 '12 at 12:57

0 Answers0