Discussions

Web tier: servlets, JSP, Web frameworks: JSF:Loading a dataTable on a Form load using an ActionListener

  1. Q. How do I load data in a h:dataTable on a form load when I need to invoke a class which implements an javax.faces.event.ActionListener

    e.g
    public class TableListController implements ActionListener{
         public void processAction(ActionEvent arg0)
    throws AbortProcessingException {
                 
              //My logic goes here

           }

    }

    Currently I have a button on the page which calls the above class, the question how do I do this on form load
    //JSP Page has
       <h:commandButton id="cmdGetTableList" value="Get Table List" actionListener="#{tableListController.processAction}" >
    followed by
       <h:form styleClass="form" id="frmTableList">

           <h:dataTable width="100%" headerClass="headerRow"
    rowClasses="searchoddRow, searchevenRow"
            id="ctlItems2" rendered="#{TableListBean.viewTableList}"
            value="#{TableListBean.tableListDTO}"
    var="tableListDTO" >
        <h:column>
    <f:facet name="header"> <h:outputText value="Table Name" />
    </f:facet>
    <h:outputText value="#{tableListDTO.tableName}" />
         </h:column>
          <h:dataTable>
        </h:form>

    If someone has done this before please let me know.
  2. You need to override the afterphase( ) method in the RESTORE_VIEW phase listener.
  3. Using afterPhase() method[ Go to top ]

    Could you give me an example of using the afterPhase() method.
  4. Q. How do I load data in a h:dataTable on a form load when I need to invoke a class which implements an javax.faces.event.ActionListenere.g public class TableListController implements ActionListener{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public void processAction(ActionEvent arg0) throws AbortProcessingException {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//My logic goes here&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}}Currently I have a button on the page which calls the above class, the question how do I do this on form load//JSP Page has &nbsp;&nbsp;&nbsp;<h:commandButton id="cmdGetTableList" value="Get Table List" actionListener="#{tableListController.processAction}" > followed by &nbsp;&nbsp;&nbsp;<h:form styleClass="form" id="frmTableList">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h:dataTable width="100%" headerClass="headerRow" rowClasses="searchoddRow, searchevenRow" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id="ctlItems2" rendered="#{TableListBean.viewTableList}" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value="#{TableListBean.tableListDTO}" var="tableListDTO" > &nbsp;&nbsp;&nbsp;&nbsp;<h:column> <f:facet name="header"> <h:outputText value="Table Name" /> </f:facet> <h:outputText value="#{tableListDTO.tableName}" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</h:column>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<h:dataTable>&nbsp;&nbsp;&nbsp;&nbsp;</h:form>If someone has done this before please let me know.

    Or better, use Struts Shale :)