0

データがデータベースに保存されたら、フォーム内のデータをクリアする方法を教えてください。

   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>

ここで、データが入力されると保存され、保存されると同じページに遷移します。問題は、入力した値がクリアされないことです。

4

1 に答える 1

0

のような属性で定義された入力フィールドがあるので、それらのフィールドを空白にするにvalue="#{userInfo.username}"は、明示的にクリアするか、その属性を指定する必要があると思いますか?userInfo

または、その 1 つのページ/ビューだけに「ローカル」モデル Bean を定義します。私は JSF をやったことがないことを認めますが、JSF で WebFlow がどのように見えるか正確にはわかりません。

于 2012-07-20T18:00:07.837 に答える