XHTML h:form代码
<h:form id="dataForm">
First Name:<h:inputText id="firstname" value="#{obj.firstname}"></h:inputText><br></br>
Last Name:<h:inputText id="lastname" value="#{obj.lastname}"></h:inputText><br></br>
Age:<p:inputText id="age" value="#{obj.age}"/><br></br>
Phone No:<p:inputText id="phonenumber" value="#{obj.phonenumber}"/><br></br>
Date:
<!--<f:convertDateTime pattern = "dd-mm-yyyy" />-->
<p:calendar id="calendar" widgetVar="pdate" value="#{obj.date}" pattern="dd-mm-yyyy"/><br></br>
Country:<h:selectOneMenu id="country" value = "#{obj.country}">
<f:selectItem itemValue = "India" itemLabel = "India" />
<f:selectItem itemValue = "Australia" itemLabel = "Australia" />
<f:selectItem itemValue = "Pakistan" itemLabel = "Pakistan" />
<f:selectItem itemValue = "NewZealand" itemLabel = "NewZealand" />
<f:selectItem itemValue = "SouthAfrica" itemLabel = "SouthAfrica" />
</h:selectOneMenu>
<h:inputHidden id="dbfirstname" value="#{obj.dbfirstname}" />
<h:inputHidden id="dblastname" value="#{obj.dblastname}" />
<h:inputHidden id="dbage" value="#{obj.dbage}" />
<h:inputHidden id="dbphonenumber" value="#{obj.dbphonenumber}" />
<h:inputHidden id="dbcalendar" value="#{obj.dbcalendar}" />
<h:inputHidden id="dbcountry" value="#{obj.dbcountry}" />
<h:inputHidden id="dbid" value="#{obj.dbid}" />
<h:inputHidden id="flag" value="#{obj.flag}" />
<h:commandButton id="submitbutton" value="Submit" actionListener="#{obj.save}" action="#{obj.indexDbSave}" onclick="saveInDb()"/><br></br>
<h:commandButton id="showbutton" value="Show Records" action="showRecords" actionListener="#{obj.show}"/><br></br>
</h:form>
我试图通过我的js文件在inputHidden字段中设置值,然后通过托管bean将数据保存在数据库中
我面临的问题是我的action和actionListener不能与inputHidden字段一起使用。