0

I am using the following update method in the bean class:

public String updateAction() {


 for ( Login lis: list){
     lis.setEditable(false);
     setEditable(false); 
     } 
         return null;
 }

the xhtml file looks like:

    <h:dataTable value="#{loginBean.list}"  var="list" border="1" >
         <h:column>                 
            <f:facet name="header">Name</f:facet>  
            <h:inputText value="#{list.UName}" size="10" rendered="#{loginBean.editable}" />                
            <h:outputText value="#{list.UName}" rendered="#{not loginBean.editable}" />
         </h:column>
         <h:column>
            <f:facet name="header">Email</f:facet>
            <h:inputText value="#{list.emailAdd}" size="10" rendered="#{loginBean.editable}" />                 
            <h:outputText value="#{list.emailAdd}" rendered="#{not loginBean.editable}" />
         </h:column>
          <h:column>
            <f:facet name="header">Password</f:facet>
            <h:inputText value="#{list.pword}" size="10" rendered="#{loginBean.editable}" />                
            <h:outputText value="#{list.pword}" rendered="#{not loginBean.editable}" />
         </h:column>

         <h:column>
            <f:facet name="header">Edit</f:facet>
           <!-- <h:commandLink value="Edit" action="#{loginBean.editAction(list)}"/>  -->
            <h:commandLink value="Edit" action="#{loginBean.editAction(list)}" />
         </h:column>


       <h:column>
            <f:facet name="header">Delete</f:facet>
            <h:commandLink value="Delete" action="#{loginBean.deleteAction(list)}" />
       </h:column>


      </h:dataTable>
      <h:column>
            <f:facet name="header">Save</f:facet>
            <h:commandButton value="Save" action="#{loginBean.updateAction}"  />
         </h:column>
   </h:form>

When i make changes in a row, and press the update button , no data is updated. I am a beginner , please tell me simple.

kolossus
  • 20,559
  • 3
  • 52
  • 104
Hanya Idrees
  • 453
  • 1
  • 8
  • 24

1 Answers1

1

I have found the answer, and like to post here for newbies help.

The problem is , the datatable list is filled and used dynamically, so the data doesnot remain persistent, to be updated.

I need to update the list at runtime, and then finally persist it in database. For this i made an init method, to get the list into, and then used the getList() method to get the list.

I this way the updated, edited data is saved in the list. :)

Hanya Idrees
  • 453
  • 1
  • 8
  • 24