清除Spring Web流程中的表单

时间:2012-07-20 15:21:18

标签: jsf spring-webflow

任何人都可以帮助我在数据保存到数据库后清除表单中的数据。

   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>  

             

主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>

此处输入数据后,它将被保存,一旦保存,它将转换到同一页面。问题是我输入的值未被清除。

1 个答案:

答案 0 :(得分:0)

您有使用value="#{userInfo.username}"等属性定义的输入字段,因此我想您必须明确清除userInfo或其属性为空白?

或者仅为该一个页面/视图定义“本地”模型bean。虽然我承认从未做过JSF,所以我不知道WebFlow与JSF的确切结合。