1
我的編輯頁面不顯示bean的值時,它是由一個JDBC搜索填充DataList控件調用,但工作得很好,如果列表不從JDBC搜索。編輯commandLink進入編輯頁面,但不填充值到輸入字段
的刪除鏈接工作得很好,但編輯鏈接只是在田裏沒有填充值返回編輯頁面。
我bean是一個ViewScoped豆。
DataList的顯示頁面:
<h:form rendered="#{not empty usersManagedBean.usersList}" id="form">
<div class="table-responsive">
<h:dataTable value="#{usersManagedBean.userModel}"
var="showUser"
styleClass="table table-striped table-bordered table-hover">
<h:column>
<f:facet name="header">
Username
</f:facet>
<h:outputText value="#{showUser.username}"/>
</h:column>
<h:column>
<f:facet name="header">
First Name
</f:facet>
<h:outputText value="#{showUser.firstname}"/>
</h:column>
<h:column>
<f:facet name="header">
Last Name
</f:facet>
<h:outputText value="#{showUser.lastname}"/>
</h:column>
<h:column>
<f:facet name="header">
Security Level
</f:facet>
<h:outputText value="#{showUser.groupname}"/>
</h:column>
<h:column rendered="false">
<f:facet name="header">
Security Level
</f:facet>
<h:outputText value="#{showUser.id}"/>
</h:column>
<h:column>
<h:commandLink value="Edit"
action="#{usersManagedBean.updateUser()}">
</h:commandLink>
||
<h:commandLink value="Delete"
onclick="if (!confirm('Are you sure, you want to delete #{showUser.username}?')) {
return false;
}
;
return true;
" action="#{usersManagedBean.deleteUser(showUser)}">
</h:commandLink>
</h:column>
</h:dataTable>
<h:link outcome="AddUser.xhtml" value="Add New User"/>
</div>
編輯頁面:
<h:form>
<div class="form-group">
<label>First Name:</label>
<h:inputText id="firstname" styleClass="form-control" value="#{usersManagedBean.user.firstname}"></h:inputText>
<label>Last Name:</label>
<h:inputText id="lastname" styleClass="form-control" value="#{usersManagedBean.user.lastname}"></h:inputText>
<label>Username:</label>
<h:inputText id="username" styleClass="form-control" value="#{usersManagedBean.user.username}"></h:inputText>
<div class="form-group">
<label>Security Level:</label>
<h:selectOneMenu id="roleSelect" value="#{usersManagedBean.user.groupname}" styleClass="form-control">
<f:selectItem itemLabel="----" itemValue="----"/>
<f:selectItem itemLabel="Administator" itemValue="admin"/>
<f:selectItem itemLabel="User" itemValue="user"/>
</h:selectOneMenu>
</div>
<label>Password:</label>
<h:inputSecret id="password" styleClass="form-control" value="#{usersManagedBean.user.password}" required="true" requiredMessage="Enter Password"/>
<h:message for="password" style="color:red"/>
<label>Confirm Password:</label>
<h:inputSecret id="password2" styleClass="form-control" required="true" requiredMessage="Re-enter Password"/>
<h:message for="password2" style="color:red" />
<o:validateEqual components="password password2" message="Passwords don't match" showMessageFor="password2"/>
</div>
<h:commandButton value="Update" type="submit" styleClass="btn btn-default" action="#{usersManagedBean.saveUser()}"></h:commandButton>
||
<h:commandButton value="Cancel" onclick="history.back(-1);return false" styleClass="btn btn-default"></h:commandButton>
</h:form>
調用編輯頁面的方法:
public String updateUser(){
user = userModel.getRowData();
return "EditUser.xhtml";
}
沒有異常拋出在所有。
我如何可以去選擇2/3,請進一步說明?只是大約3個星期新的jsf @tt_emrah – ollaollu 2014-10-10 20:19:11
經過這麼多的進步性錯誤和不斷的搜索之後,我瘋狂的理解了真實當我離開時,JSF創建新實例的原因。這個http://stackoverflow.com/questions/8459903/correct-usage-of-session-scope-in-two-page-master-detail-user-interface/8464636#8464636幫助我成功地解決了它。感謝BalusC以清晰的方式回答了這兩個帖子,並感謝tt_emrah的回答。 – ollaollu 2014-10-23 03:12:59
我沒有機會詳細解釋它,對此感到遺憾。我希望至少我指出你正確的方向。謝謝... – 2014-10-23 06:01:21