When setting values into a backing bean, can bean name be a variable

477 views Asked by At

Is there a way to use a variable to define the backing bean when setting parameters. In our application, we allow multiple filtering criteria on most if not all columns on a table. We have developed a section of code that is copied into each column definition implementing this. Example column definition:

<p:column styleClass="dataTableColumnAlignLeft" id="c0"
   style="width: 200px" exportable="false">
   <ui:include src="/html/common/dataTableColumnHeader5_2.xhtml">
      <ui:param name="programId" value="backingBeanName" />
      <ui:param name="fieldName" value="depositName" />
      <ui:param name="displayLessThanFilter" value="false" />
      <... several more ui:include parameters />
   </ui:include>
   <h:outputText value="#{cashReceiptsDeposList.depositName}" />
</p:column>

The included code builds column headings and has command buttons to sort columns and display user help text, all of which works fine. But it also contained a command button that executed a dialog to obtain from the user, multiple filtering parameters for each column. This worked fine in PF 3.2, but in converting to 5.2, it stopped working. In looking at the documentation, I see that a dialog should not be included in a table definition, so we are attempting to move the dialog outside of the table definition. This, however, means that the parameters that were set for the code brought in with ui:include are not visible to the dialog. I can overcome this by setting the parameters specific to the column being filtered into the backing bean with the following:

<p:commandLink tabindex="-1" rendered="#{displayFilters}"
   update=":filterDialogForm:filterDialog"
   oncomplete="PF('filterDialog').show();" id="#{fieldName}FPL"
   title="#{label}">
   <f:setPropertyActionListener target="#{backingBeanName.label}" value="#{label}" />
   <f:setPropertyActionListener target="#{backingBeanName.fieldName}" value="#{fieldName}" />
   <f:setPropertyActionListener target="#{backingBeanName.displayContainsFilter}" value="#{displayContainsFilter}" />
   <p:graphicImage rendered="#{displayFilters}" tabindex="-1"
      style="border:0px;" width="20" height="20"
      value='#{empty filtersHandler..../>
</p:commandLink>

The dialog can then pick up the contents of these backing bean elements so it will know which filters to request. If I could specify the bean name as a variable, I would only need a single copy of the copied in snippet, but if I have to enter the actual bean name, I will need a copy for every page that has a table, over 1000 at present. I have tried several ways to use a variable, such as target="#{#{programId}.field}", but so far they have all either failed to parse or been interpreted as static bean names rather than variables. Is it possible to specify the bean name with a variable?

environment: PF 5.2, jBoss 7.1.3, jdk-7, jsf 2.2

0

There are 0 answers