3 Replies Latest reply on Jun 30, 2008 12:05 PM by Mikael Andersson

    Getting f:param in bean

    Per Lilja Newbie

      Hi all,


      I'm trying to get a f:param parameter in my backing bean, but I'm not able to find it.


      This is my



      <ui:define name="body">                
              <h:form id="ViewFormTypeForm">
                  <h2>Form Types : View</h2>
                  
                  <rich:contextMenu attached="false" id="menu" submitMode="ajax">
                      <rich:menuItem ajaxSingle="true">
                          Edit <b>{formTypeName}</b> details
                          <a4j:support event="onclick" action="#{editFormTypeAction.setFormTypeToEdit()}" oncomplete="Richfaces.showModalPanel('EditFormTypePanel')"/>
                      </rich:menuItem>
                  </rich:contextMenu> 
                  
                  <rich:dataTable value="#{formTypes}" 
                              var="_formType" 
                              onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                              onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                              submitMode="ajax">
                  <f:facet name="header">
                      <h:outputText value="#{messages.form_type}"/>
                  </f:facet>
                  <rich:column sortBy="#{_formType.formTypeName}" filterBy="#{_formType.formTypeName}" filterEvent="onkeyup"> 
                      <f:facet name="header">
                          <h:outputText value="#{messages.form_type_name}"/>
                      </f:facet>
                      <h:outputText value="#{_formType.formTypeName}"/>
                  </rich:column>
                  <rich:column sortBy="#{_formType.remainingFormCopies}"> 
                      <f:facet name="header">
                          <h:outputText value="#{messages.form_type_remaining}"/>
                      </f:facet>
                      <h:outputText value="#{_formType.remainingFormCopies}"/>
                  </rich:column>
                  <rich:column sortBy="#{_formType.nbrOfUsedFormCopies}"> 
                      <f:facet name="header">
                          <h:outputText value="#{messages.form_type_nbr_of_used_form_copies}"/>
                      </f:facet>
                      <h:outputText value="#{_formType.nbrOfUsedFormCopies}"/>
                  </rich:column>
                  <rich:column sortBy="#{_formType.maxNbrOfFormCopies}"> 
                      <f:facet name="header">
                          <h:outputText value="#{messages.form_type_max_nbr_of_form_copies}"/>
                      </f:facet>
                      <h:outputText value="#{_formType.maxNbrOfFormCopies}"/>
                  </rich:column>
                  <rich:column sortBy="#{_formType.creationDate}"> 
                      <f:facet name="header">
                          <h:outputText value="#{messages.form_type_creation_date}"/>
                      </f:facet>
                      <h:outputText value="#{_formType.creationDate}"/>
                  </rich:column>
                  <rich:column> 
                      <f:facet name="header">
                          <h:outputText value="#{messages.pdf}"/>
                      </f:facet>
                      <h:outputLink value="#{viewFormTypeAction.createPDF(_formType.formTypeName)}">
                          <h:graphicImage id="pdfimage"
                             alt="View PDF"
                             url="/images/pdf.jpg" width="15" height="15" style="border:0px">
                          </h:graphicImage>          
                      </h:outputLink>   
                  </rich:column>
                  
                  <rich:componentControl event="onRowClick" for="menu" operation="show">
                      <f:param value="#{_formType.formTypeName}" name="formTypeName"/>
                  </rich:componentControl>
              </rich:dataTable>
              </h:form>
              <a4j:form>
                  <a4j:outputPanel ajaxRendered="true" id>
                      <rich:panel>
                          <h:outputText value="#{editFormType.formTypeName}"></h:outputText>
                      </rich:panel>       
                  </a4j:outputPanel>
              </a4j:form>
      
          </ui:define>



      and in my bean



      formTypeName = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("ViewFormTypeForm.formTypeName");
      
      



      Any ideas?

        • 1. Re: Getting f:param in bean
          Mikael Andersson Master

          Hi


          Can you find it by getting the value via the key formTypeName ?


          You can also try the below, will automatically set the value on the backing bean without having to go via the request parameter map. Haven't tried this with rich:componentControl , but works if inside a a4j:support.


          <a4j:actionparam name="someName" value="#{_formType.formTypeName}" assignTo="#{backingBean.property}" />
          



          Cheers,
          micke

          • 2. Re: Getting f:param in bean
            Per Lilja Newbie

            Thanks, it works, but is there away to rerender a component inside the bean or after the property has been set?



            <a4j:support event="onRowClick" oncomplete="Richfaces.showModalPanel('EditFormType')" reRender="EditFormTypeDiv">
                            <a4j:actionparam name="formTypeName" value="#{_formType.formTypeName}" assignTo="#{editFormTypeAction.formTypeName}" />
                        </a4j:support>



            When I'm doing like this, it updates the area with the row data form my previous click, but I want to wait until the property has been updated (I'm using the parameter to retreive from my database and then I want to open a modal panel so that the user can edit the information).

            • 3. Re: Getting f:param in bean
              Mikael Andersson Master

              Hi


              Here is a RichFaces Cookbook entry about using a modal panel for editing details based on clicking a link in a table.


              If the EditFormTypeDiv is the content of the modal panel which contains the area with editing information then I would have thought that your code would work.


              It submits the value, reRenders the modal panel content and then shows the modal panel doesn't it.


              If it doesn't work, please post the modal panel related xhtml.


              Cheers,


              Micke