1 Reply Latest reply on Nov 23, 2007 4:16 AM by Techie Exchange

    JSF and updating hidden field

    whafrog Newbie

      Hi, this is probably more of a JSF question, but maybe Seam has a workaround:

      I have a simple table where each row is a component. If the user has this component in the database, the hidden field has a value and the box is checked. If they do not, they can always check the box and that component will be added to the database. The problem is that the value of "lenderBenefitId" is handled on the server side. If they check the box and click Save, the row is persisted to the database and the lenderBenefitId is populated. If they uncheck the box that has a lenderBenefitId that is not null, that record will be deleted from the database and lenderBenefitId set to null. But these changes are not propagated back to the view. How can I get this propagation to happen?

      <h:panelGrid columns="2">
       <h:selectBooleanCheckbox value="#{benefitMap.getBenefit('ORIGINATION_FEE').selected}"/>
       <h:inputHidden value="#{benefitMap.getBenefit('ORIGINATION_FEE').lenderBenefitId}"/>
       <h:outputLabel for="originationFee">Origination Fee:</h:outputLabel>
       <h:inputText value="#{benefitMap.getBenefit('ORIGINATION_FEE').percentReduction}" size="5"/>%
       <h:selectBooleanCheckbox value="#{benefitMap.getBenefit('FEDERAL_DEFAULT_FEE').selected}"/>
       <h:inputHidden value="#{benefitMap.getBenefit('FEDERAL_DEFAULT_FEE').lenderBenefitId}"/>
       <h:outputLabel for="federalDefaultFee">Federal Default Fee:</h:outputLabel>
       <h:inputText value="#{benefitMap.getBenefit('FEDERAL_DEFAULT_FEE').percentReduction}" size="5"/>%
      <div class="actionButtons">
      <h:commandButton type="submit" value="Save" action="#{lenderbenefits.processLenderBenefits}"/>

      Many thanks in advance!


        • 1. Re: JSF and updating hidden field
          Techie Exchange Newbie

          This is nothing to do with Seam.

          Here's the solution:

          <h:inputHidden value="" binding="#{managedBean.hiddenValue}" />
          private HtmlInputHidden hiddenValue = new HtmlInputHidden();
          // Have getter setter

          I use this trick only to populate hidden values thru client side Javascript.
          In your case you don't need any hiddenfields you could use just String properties (binded to ManagedBean) to get dynamic values.

          If this is not the solution what you want, then plz explain your question properly.