0

Can anyone help me how to clear the data in the form once the data is get saved in the database.

   add.xhtml

       <ui:define name="content">

       <h2 style="font-weight:bold;font-size:16px;margin-top:10px;">Register a new employee</h2>
       <p:panel header="Add a Employee" toggleable="true" toggleSpeed="100">
    <h:form style="background: 10px steelBlue;border-radius: 13px;">

        <h:panelGrid columns="3" id="leaveform" >
        <div>
        <div>
        <h:outputLabel for="employee">Select the Type employee</h:outputLabel>
        <h:selectOneMenu id="approveleavetype" value="#{userInfo.loginperson}" required="false" >
                        <f:selectItems value="#{referenceData.loginPersonType}"/>
                    </h:selectOneMenu> 
            </div>
                 <h:outputLabel for="firstname">First Name<em>*</em></h:outputLabel>



                <h:inputText id="firstname" value="#{userInfo.fname}" 
                 required="true" 
                label="fname" style="background-color:#FFF;">
            </h:inputText>


            <div>

                <h:outputLabel for="lastName">Last Name<em>*</em></h:outputLabel>



                    <h:inputText id="lastname" value="#{userInfo.lname}" 
                 required="true" 
                label="lname" style="background-color:#FFF;">
            </h:inputText>


            </div>
            <div>
                <h:outputLabel for="emailId">Email Id<em>*</em></h:outputLabel>



                    <h:inputText id="emailId" value="#{userInfo.emailId}" 
                 required="true" 
                label="emailId" style="background-color:#FFF;">
            </h:inputText>

            </div>
            <div>
                <h:outputLabel for="manager">Manager<em>*</em></h:outputLabel>



            <h:inputText id="manager" value="#{userInfo.manager}" 
                 required="true" 
                label="manager" style="background-color:#FFF;">
            </h:inputText>
            </div>

            <div>
                <h:outputLabel for="username">UserName<em>*</em></h:outputLabel>



            <h:inputText id="username" value="#{userInfo.username}" 
                 required="true" 
                label="username" style="background-color:#FFF;">
            </h:inputText>
            </div>
            <div>
                <h:outputLabel for="password">Password<em>*</em></h:outputLabel>



            <h:inputText id="password" value="#{userInfo.password}" 
                 required="true" 
                label="password" style="background-color:#FFF;" >
            </h:inputText>
            </div>






        <center><p:commandButton value="Add Employee" action="insertemployee" id="insertemployee" style="margin-left:250px;"/></center>
    </div>  

main-flow.xml

             <view-state id="addEmployee">
<on-entry>
<evaluate expression="leaveBo.getallUser()" result="viewScope.allUser"></evaluate>
</on-entry>
    <transition on="insertemployee" to="addEmployeeInfo"></transition>

</view-state>

    <action-state id="addEmployeeInfo">
    <evaluate
        expression="leaveBo.insertEmpolyee(userInfo.fname,userInfo.lname,userInfo.emailId,userInfo.manager,userInfo.loginperson,userInfo.username,userInfo.password)"></evaluate>
    <transition to="addEmployee"></transition>
</action-state>

Here Once the Data is get entered it is get saved and once it get saved it is transition to same page.The problem is the value I entered is not getting cleared.

4

1 回答 1

0

You have input fields defined with attributes like value="#{userInfo.username}", so I imagine you'll have to explicitly clear userInfo or its attributes for those fields to be blank?

Or define a "local" model bean for just that one page/view. Although I admit to having never done JSF, so I don't know exactly what WebFlow looks like with JSF.

于 2012-07-20T18:00:07.837 回答