I'm passing one request parameter to a facelet page which is processed in the corresponding preRenderView
event/listener :
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="id" value="#{essayDetails.id}" />
<f:event type="preRenderView" listener="#{essayDetails.init}"/>
</f:metadata>
</ui:define>
Init method is properly accessed and the page is rendered normally. I have a commandLink (RichFaces component) that show a modal panel via an ajax request:
<a4j:commandLink rendered="#{essayDetails.comment}" render="create_comment_group" oncomplete="#{rich:component('create_comment_panel')}.show()">
<h:graphicImage library="images/icons" name="comment.png" />
</a4j:commandLink>
The modal panel snippet:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:utils="http://java.sun.com/jsf/composite/components/utils">
<rich:popupPanel id="create_comment_panel" autosized="true">
<f:facet name="header">
<utils:labeledIcon label="#{msg.action_comment}" image="icons/comment.png" />
</f:facet>
<h:form>
<h:panelGroup id="create_comment_group">
<h:inputTextarea cols="80" rows="8" value="#{essayDetails.userComment}" style="resize: none;" />
<table style="width: 100%">
<tr>
<td style="width: 50%;text-align: right;">
<a4j:commandButton value="#{msg.button_create}" action="#{essayDetails.saveComment}" execute="create_comment_panel_essay" render="essay_comments" oncomplete="#{rich:component('create_comment_panel')}.hide()" />
</td>
<td style="width: 50%;text-align: left;">
<a4j:commandButton value="#{msg.button_cancel}" execute="@none" oncomplete="#{rich:component('create_comment_panel')}.hide()" />
</td>
</tr>
</table>
</h:panelGroup>
</h:form>
</rich:popupPanel>
In this panel a comment is inserted in a h:inputTextArea
field, but when the corresponding Accept button is pressed instead of calling #{essayDetails.saveComment}
method the post-back request fails in validating f:viewParam
id parameter saying that this fields needs a value.
If we make no changes to original code but adds an extra f:viewParam
:
<ui:define name="metadata">
<f:metadata>
<f:viewParam name="id" value="#{essayDetails.id}" required="true" />
<f:viewParam name="v" value="#{essayDetails.v}" required="true" />
<f:event type="preRenderView" listener="#{essayDetails.init}"/>
</f:metadata>
</ui:define>
There is no validation error and the behaviour is as expected. What am I doing wrong in using f:viewParam and/or preRenderView event?
Thanks in advance!