Mar 302011
 

things inside my dataTable aren’t displayed at all?
use a <h:column> tag and put the items to display inside of it..

    <h:dataTable value="#{controller.claim.diagnosisCodeMeta}" var="m"
       id="dataTableDiagCodesMeta" rowClasses="color1,color2">
 
        <h:column>
... content ...
</h:column>
 
</h:dataTable>
Mar 302011
 

Don’t reload a page when a commandButton is clicked and the button is only meant to do an ajax request, use immediate=”true” and return null from the action method.

<h:commandButton immediate="true"
    value="Add Charges Section" action="#{controller.claim.addChargesSection}">
   
   <f:ajax render="dataTableDiagCodesMeta dataTableDiagCodes" execute="@form" />
</h:commandButton>
Mar 302011
 

If a user decides to delete text that was entered in an inputTextbox, it magically reappears when the component is re-rendered.

     <!-- this allows a user to delete the value in an inputText and have that
            saved instead of the previous value magically disappearing. -->
     <context-param>
           <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
           <param-value>true</param-value>
     </context-param>
Mar 302011
 

The f:ajax render attribute doesn’t work if the component specified is the component holding the f:ajax component – the component specified has to have a different container/parent. The solution is to add an extra wrapper around the component. The wrapper must be referred to with the full id (including the form id).

   <!-- this wrapper needs to be here for the f:ajax to re-render.
     from http://stackoverflow.com/questions/2424757/ajax-render-attribute-dont-work-in-a-hdatatable-in-jsf2.
     the bad grammar is not my fault. -->
   <h:panelGroup id ="dataTableDiagCodesWrapper">
   <h:dataTable value="#{controller.claim.diagnosisCodes}" var="d"
       id="dataTableDiagCodes" rowClasses="color1,color2">
 
       <h:column>
           <h:outputText id="header_diagnosisCode" value="Diagnosis Code" />
           <h:inputText value="#{d.code}" escape="false" id="aDiagnosisCode">
                <f:ajax execute="@this @form" render=":form:dataTableDiagCodesWrapper" />
           </h:inputText>
       </h:column>
   </h:dataTable>
   </h:panelGroup>