I pass one request parameter to the 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>
The method is initialized correctly and the page is displayed normally. I have a commandLink (RichFaces component) that shows a modal panel through 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>
Modal panel fragment:
<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 added to the h:inputTextArea , but when the corresponding Accept button is pressed instead of calling the #{essayDetails.saveComment} method, the feedback request is not executed when checking the f:viewParam id parameter, which says that these fields are needed value.
If we do not make any changes to the source code, but add an additional 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 behavior will be as expected. What am I doing wrong when using f: viewParam and / or preRenderView events?
Thanks in advance!
source share