我是Java和PrimeFaces的新手(我只使用过c#和visual sudio)。
当我尝试编辑行时,列值不会显示在模态对话框中。 我尝试过不同的解决方案,结果相同。 有人能帮助我吗?
<ui:include src="/includes/header.xhtml" />
<!-- Container -->
<div id="container">
<div class="shell">
<div id="main" style="vertical-align: middle;">
<br /> <br />
<form>
<p:dataTable var="loc" value="#{location.loc}" rowKey="#{loc.code}" id='loca'>
<p:column width="100">
<p:commandButton icon="ui-icon-plus" type="button" id="add" onclick="PF('newDialog').show()" update="Newform:NewLocation"/>
<p:commandButton icon="ui-icon-pencil" type="button" update="updForm:updDisplay" onclick="PF('updDialog').show()" id="edit" ajax="true">
</p:commandButton>
<p:commandButton icon="ui-icon-trash" />
</p:column>
<p:column headerText="Code">
<h:outputText value="#{loc.code}" />
</p:column>
<p:column headerText="Ip">
<h:outputText value="#{loc.address}" />
</p:column>
<p:column headerText="Descrizione">
<h:outputText value="#{loc.description}" />
</p:column>
</p:dataTable>
</form>
<p:dialog widgetVar="newDialog" header="Insert Location" width="430" height="220" modal="true">
<h:form id="Newform">
<p:outputPanel id="NewLocation">
<h:panelGrid columns="2">
<h:outputLabel value="Code" />
<p:inputText value="#{loc.Code}"></p:inputText>
<h:outputLabel value="description" />
<p:inputText value="#{loc.description}"></p:inputText>
<h:outputLabel value="Address" />
<p:inputText value="#{loc.address}"></p:inputText>
</h:panelGrid>
<p:commandButton value="Save" onclick="newDialog.close()">
</p:commandButton>
</p:outputPanel>
</p:dialog>
<p:dialog widgetVar="updDialog" header="Location" width="430" height="220" modal="true">
<h:form id="updForm">
<p:outputPanel id="updDisplay">
<h:inputHidden value="#{loc.code}" />
<h:panelGrid columns="2">
<h:outputLabel value="Description" />
<p:inputText value="#{loc.description}"></p:inputText>
<h:outputLabel value="Address" />
<p:inputText value="#{loc.address}"></p:inputText>
</h:panelGrid>
<p:commandButton value="Update" onclick="updDialog.close()">
</p:commandButton>
<p:commandButton value="Delete" onclick="updDialog.close()">
</p:commandButton>
<p:growl id="growl" showDetail="true" />
</p:outputPanel>
</h:form>
</p:dialog>
MangedBean:
@ManagedBean (name="Locations")
@SessionScoped
public class Locations {
@EJB
cslocationBeanRemote locationsBean;
private List<cslocationModel> ListLocations;
@SuppressWarnings({"unchecked", "rawtypes"})
@PostConstruct
public void init() {}
public List<cslocationModel> getListLocations() {
try {
ArrayList orderBy = new ArrayList();
orderBy.add(cslocationModel.ORDERcodASC);
setListLocations((List<cslocationModel>) locationsBean.find(null,
null, null, orderBy));
} catch (Exception ecc) {
ecc.printStackTrace();
}
return ListLocations;
}
public void setListLocations(List<cslocationModel> ListLocations) {
this.ListLocations = ListLocations;
}
}
谢谢。