Search code examples
javajsfcrudtomahawk

JSF 1.1 Datatable CRUD operation


We have a old application running with JSF 1.1, cannot upgrade due to client specification.

I would like to know is it possible to have a datatable with JSF 1.1 and upon clicking a button or link in datatable row open a dialog popup and do CRUD operation?

Thanks

Edit 1

I guess Apache Trinidad supports JSF 1.1. Can I do CRUD operation with Trinidad?


Solution

  • I think using Richfaces 3.1.6 (JSF 1.1 compatible) with the great A4J, will help you doing so:

    <h:form id="myForm">
    <rich:dataTable width="100%" style="border:none;margin-left:15px;" id="tableId" columnClasses="colClass"
                value="#{managedBean.someList}" var="someVar">
    
        <h:column> some content for this column </h:column>
        <h:column>
               <a4j:commandLink styleClass="linkClass" value="Delete" reRender="myForm:myModal" ajaxSingle="true" oncomplete="#{rich:component('myForm:myModal')}.show()" actionListener="#{managedBean.someMethodToUpdateDTO}">
                  <a4j:actionparam value="#{someVar.idForExample}" name="someName"  assignTo="#{managedBean.someDTOObjectToBeUpdated.id}"/>
               </a4j:commandLink>
    
        </h:column>
    </rich:dataTable>
    
    <rich:modalPanel id="panel" width="350" height="100">
        <f:facet name="header">
        <h:panelGroup>
            <h:outputText value="Are you really, really sure to delete this one!!! #{managedBean.someDTOObjectToBeUpdated.name}"></h:outputText>
        </h:panelGroup>
        </f:facet>
        <a4j:commandButton styleClass="btnClass" value="Oui" ajaxSingle="true" oncomplete="#{rich:component('myForm:myModal')}.hide()" reRedner="myForm:tableId" action="#{managedBean.deleteIt}">
    </rich:modalPanel>
    
    </h:form>
    

    someMethodToUpdateDTO is a method, in your managed bean that looks like this:

    public void someMethodToUpdateDTO(ActionEvent event){
        //In this method I just load the object from somewhere else
        someDTOObjectToBeUpdated = someDAO.getObject(someDTOObjectToBeUpdated.getId()); 
        //someDTOObjectToBeUpdated is an attribute of your managed bean, of course with its     getter and setter
    }
    

    Hope this helps,

    Cheers