1

What I have right now is (file xhtml):

    <h:form>
    <h:dataTable value="#{userL.listUser}" var="o"
                 styleClass="order-table"
                 headerClass="order-table-header"
                 rowClasses="order-table-odd-row,order-table-even-row"
    >

        <h:column>
            <f:facet name = "header">Login</f:facet>
            <h:outputText value = "#{o.name}"/>
        </h:column>

        <h:column>
            <f:facet name = "header">Nom</f:facet>
            <h:outputText value = "#{o.nom}" />
        </h:column>

        <h:column>
            <f:facet name = "header">Age</f:facet>
            <h:outputText value = "#{o.age}"/>
        </h:column>

        <h:column>
            <f:facet name = "header">Email</f:facet>
            <h:outputText value = "#{o.email}"/>
        </h:column>
        <h:column>
            <f:facet name="header">Edit</f:facet>
            <h:commandButton value="Edit" action="#{o.editAction(o)}" >
                <f:ajax execute="@form" render=":form_modif" />
        </h:commandButton>
        </h:column>

        <h:column>
            <h:commandLink id="remove" value="delete" action="#{userLService.deleteStudent(o)}"
                           onclick="return confirm('Are you sure?')">
            </h:commandLink>
        </h:column>
    </h:dataTable>
</h:form>
<h:form id="form_modif">
    <h:outputLabel value="Enter your Login: " />
    <h:inputText value="#{userL.name}"/>
    <h:outputLabel value="Enter your Pass: " />
    <h:inputText value="#{userL.pass}"/>
    <h:outputLabel value="Enter your Age: " />
    <h:inputText value="#{userL.age}"/>
    <h:outputLabel value="Enter your email: " />
    <h:inputText value="#{userL.email}"/>
    <h:outputLabel value="Enter your nom: " />
    <h:inputText value="#{userL.nom}"/>
    <h:commandButton value="Submit" action="#{userL.submit}">
    </h:commandButton>
</h:form>

and (bean file):

@ManagedBean
@ApplicationScoped
public class UserL {
private UserL user;
private String name;
private String pass;
private String email;
private String nom;
private Integer age;
//Differents setter and getters

My first form get from the database the different user and print them, what I want is that by clicking the "Edit" button I get theses informations inside the inputtbox on the second form. How can I do it? I tried to set theses informations like that:

public String editAction(UserL order) {
    this.age=order.age;
    this.name=order.name;
    this.nom=order.nom;
    this.email=order.email;
    this.pass=order.pass;
    System.out.println(nom);
    return null;
}

But nothing happen. I do get the information on the first form but I can seem to pass them to the 2nd one and have them prefilled the differents inputtext.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Eric Godard
  • 179
  • 12
  • Thanks for your help, while I've seen what you meant I have trouble putting it on action. I've gave an ID to my second form. I don't see how I can update it, when I press edit I set the information of my list on an object user that the 2nd form call, the problem as you said is that my 2nd form isn't updated by the first. I've updated my question with my new modification. Sorry, I'm kinda new to this whole jsf stuff. – Eric Godard Jun 04 '17 at 09:29
  • Even with the different link marked as being the answer I just can't find the answer.. My whole page seem to be reloaded when I click the edit button but there isn't any value in my inputtext. – Eric Godard Jun 04 '17 at 11:08

0 Answers0