Foren
<f:viewParam> not setting value to bean
Anand Shankar, geändert vor 9 Jahren.
<f:viewParam> not setting value to bean
New Member Beiträge: 2 Beitrittsdatum: 24.08.14 Neueste Beiträge
I want to implement a simple PRG approach which for some reason is not working as per my expectation. Please help.
1) I do a POST from firstpage.xhtml
2) Here, I am handling the action and making redirect.
3) In page editCourse.xhtml, I am reading the request parameters.
My expectation on 3rd step was that first setCourseId() of courseModelBean would have got called followed by courseDesignerBackingBean.updateModelBeanByCourseId. But, setCourseId() of courseModelBean is not getting called.
Any hints?
Best regards, Anand.
1) I do a POST from firstpage.xhtml
<p:column>
<p:menubutton value="#{i18n['actions']}">
<p:menuitem value="#{i18n['edit-course']}" icon="ui-icon-pencil" ajax="false" action="#{courseDesignerBackingBean.navigateToEditCourse(course.courseId)}" />
<p:menuitem value="#{i18n['delete-course']}" icon="ui-icon-trash" ajax="false" />
</p:menubutton>
</p:column>
2) Here, I am handling the action and making redirect.
public String navigateToEditCourse(long courseId){
String outcome = "editCourse?faces-redirect=true" + "&courseId=" + courseId;
System.out.println(outcome);
return outcome;
}
3) In page editCourse.xhtml, I am reading the request parameters.
<f:metadata>
<f:viewparam name="courseId" value="#{courseModelBean.courseId}" />
<f:event listener="#{courseDesignerBackingBean.updateModelBeanByCourseId}" type="preRenderView" />
</f:metadata>
My expectation on 3rd step was that first setCourseId() of courseModelBean would have got called followed by courseDesignerBackingBean.updateModelBeanByCourseId. But, setCourseId() of courseModelBean is not getting called.
Any hints?
Best regards, Anand.
Anand Shankar, geändert vor 9 Jahren.
RE: <f:viewParam> not setting value to bean
New Member Beiträge: 2 Beitrittsdatum: 24.08.14 Neueste Beiträge
Not so nice discovery, but found the reason why <f:viewParam> wasn't working.
Looks like LR Faces Bridge doesnt support PRG in non-ajax actions.
After turning on Ajax, everything worked as expected.
Here's something interesting, I found on developer documentation
Looks like LR Faces Bridge doesnt support PRG in non-ajax actions.
After turning on Ajax, everything worked as expected.
<p:column>
<p:menuButton value="#{i18n['actions']}">
<p:menuitem value="#{i18n['edit-course']}" icon="ui-icon-pencil" ajax="true"
action="#{courseDesignerBackingBean.navigateToEditCourse(course.courseId)}" />
<p:menuitem value="#{i18n['delete-course']}" icon="ui-icon-trash" ajax="true"/>
</p:menuButton>
</p:column>
Here's something interesting, I found on developer documentation
As result, Liferay Faces Bridge was designed for JSF 2.x, and keeps Ajax in mind. The Liferay Faces Bridge makes the following assumptions:
Developers are not primarily concerned about the re-rendering of portlets use-case mentioned above.
Developers don’t want any of the drawbacks mentioned above.
Developers are making heavy use of the f:ajax tag and submitting forms via Ajax with their modern-day portlets.
Developers want to do as little configuration as possible and don’t want to be forced to add anything to the WEB-INF/web.xml descriptor.
Neil Griffin, geändert vor 9 Jahren.
RE: <f:viewParam> not setting value to bean
Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Anand,
This problem should be fixed in FACES-1557. The fix was quite simple, found in this commit.
Kind Regards,
Neil
This problem should be fixed in FACES-1557. The fix was quite simple, found in this commit.
Kind Regards,
Neil