任何人都知道分配 ap:inputText 值的方法,因此它可以在对话框窗口中正确显示,但仅更新来自 commandButton 操作的值更改,而不是支持 bean 中值的动态设置方法。让用户添加一个步骤并显示在环中,然后他们可以单击各个步骤,但我希望他们能够仅通过更新步骤按钮更新步骤信息,而不仅仅是更改字段并关闭对话框? 内置方法会更好,我知道我可以编码,但尽量不要。
提前致谢....
<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
<p:dialog modal="true" widgetVar="statusDialog" header="Status"
draggable="false" closable="false">
<p:graphicImage value="/resources/images/ajaxloadingbar.gif" />
</p:dialog>
<h:form id="form">
<p:panel header="Setup System" >
<p:selectOneMenu value="#{groups.selected_sys_code}" id="systems" rendered="#{utility.systemDD}">
<f:selectItem itemLabel="Choose System" itemValue="" />
<f:selectItems value="#{supportBean.access_system_codes}"/>
<p:ajax listener="#{groups.valueChanged}" event="valueChange" render="systemForm" execute="@all"/>
</p:selectOneMenu>
<h:panelGroup id="systemForm" >
<p:panel id="panel" header="Step Details">
<p:messages id="msgs"/>
<h:panelGrid columns="2" columnClasses="label, value" styleClass="grid">
<p:panelGrid columns="2" styleClass="veaGrid">
<h:outputLabel for="name" value="Name:"/>
<p:inputText id="name" value="#{setup.name}" label="Name" required="true"/>
<h:outputLabel for="desc" value="Description:"/>
<p:inputText id="desc" value="#{setup.description}" label="Description" required="true"/>
<h:outputLabel for="email" value="Email For Group Responsible:"/>
<p:inputText id="email" value="#{setup.emailResp}" label="Email" required="true"/>
<h:outputLabel for="process" value="Process:"/>
<p:inputText id="process" value="#{setup.process}" label="Process" required="true"/>
</p:panelGrid>
</h:panelGrid>
<p:commandButton value="Add Step" update="panel,stepsRing" actionListener="#{setup.setSteps}" process="@form" >
</p:commandButton>
<p:commandButton value="Submit All Steps" actionListener="setup.submitSteps">
</p:commandButton>
</p:panel>
</h:panelGroup>
<h:panelGroup id="stepsRing" >
<p:panel header="Steps">
<p:ring id="basic" value="#{setup.steps}" var="step" >
<p:column>
<p:outputPanel/>
<p:outputPanel style="text-align:center;" layout="block" >
Step #{step.sequence}
<br/>
<p:commandButton update=":form:detail" title="View" oncomplete="dlg.show()" value="Details" >
<f:setPropertyActionListener value="#{step}" target="#{setup.selectedStep}" />
</p:commandButton>
</p:outputPanel>
</p:column>
</p:ring>
</p:panel>
</h:panelGroup>
<p:dialog id="dialog" widgetVar="dlg" showEffect="fade" hideEffect="fade" modal="true" width="300" >
<p:outputPanel id="detail" style="text-align:center;" layout="block">
<h:panelGrid columns="2" cellpadding="5" rendered="#{not empty setup.selectedStep}">
<f:facet name="header">
Step #{setup.selectedStep.sequence}
</f:facet>
<h:outputText value="Name: " />
<p:inputText id="name2" value="#{setup.selectedStep.name}" />
<h:outputText value="Description: " />
<p:inputText id="desc2" value="#{setup.selectedStep.description}" />
<h:outputText value="Email: " />
<p:inputText id="email2" value="#{setup.selectedStep.emailResp}"/>
<h:outputText value="Process: " />
<p:inputText id="process2" value="#{setup.selectedStep.process}"/>
<p:commandButton update="stepsRing" actionListener="#{setup.removeStep}" title="Remove" oncomplete="dlg.hide()" value="Remove Step" >
<f:setPropertyActionListener value="#{step}" target="#{setup.selectedStep}" />
</p:commandButton>
<p:commandButton update="stepsRing" process="@form" actionListener="#{setup.updateStep}" title="Update" value="Update Step" >
<f:setPropertyActionListener value="#{step}" target="#{setup.selectedStep}" />
</p:commandButton>
</h:panelGrid>
</p:outputPanel>
</p:dialog>
</p:panel>
</h:form>
BackingBean
@ManagedBean(name="setup")
@ViewScoped
public class WorkStepSetupSystemBean implements Serializable{
private WorkSetup step;
public ArrayList <WorkSetup> steps=new ArrayList <WorkSetup> ();
private WorkSetup ws;
private String system="test1";
private String emailResp;
private String process;
private String name;
private String description;
private Integer sequence;
private String email2;
private String process2;
private String name2;
private String desc2;
private WorkSetup selectedStep;
public WorkStepSetupSystemBean(){
}
public String getDesc2() {
return desc2;
}
public String getEmail2() {
return email2;
}
public String getName2() {
return name2;
}
public String getProcess2() {
return process2;
}
public WorkSetup getSelectedStep() {
return selectedStep;
}
public ArrayList<WorkSetup> getSteps() {
return steps;
}
public WorkSetup getStep() {
return step;
}
public void setSteps(ActionEvent event) {
step= new WorkSetup();
step.setName(name);
step.setEmailResp(emailResp);
step.setDescription(description);
step.setSystem(system);
step.setProcess(process);
step.setSequence(steps.size()+1);
steps.add(step);
return;
}
public void setStep(ArrayList<WorkSetup> steps) {
this.steps = steps;
}
public Integer getSequence() {
return sequence;
}
public String getDescription() {
return description;
}
public String getEmailResp() {
return emailResp;
}
public String getName() {
return name;
}
public String getProcess() {
return process;
}
public String getSystem() {
return system;
}
public void setDescription(String description) {
this.description = description;
}
public void setEmailResp(String emailResp) {
this.emailResp = emailResp;
}
public void setName(String name) {
this.name = name;
}
public void setProcess(String process) {
this.process = process;
}
public void setSequence(Integer sequence) {
this.sequence = sequence;
}
public void setSystem(String system) {
this.system = system;
}
public void setDesc2(String desc2) {
this.desc2 = desc2;
}
public void setEmail2(String email2) {
this.email2 = email2;
}
public void setName2(String name2) {
this.name2 = name2;
}
public void setProcess2(String process2) {
this.process2 = process2;
}
public void setSelectedStep(WorkSetup selectedStep) {
this.selectedStep = selectedStep;
}
public void removeStep(ActionEvent event) {
steps.remove(steps.indexOf(this.selectedStep));
for(int i=0;i<steps.size();i++){
steps.get(i).setSequence(i+1);
}
}
public void updateStep(ActionEvent event) {
step=steps.get(steps.indexOf(this.selectedStep));
step.setName(name2);
step.setEmailResp(email2);
step.setDescription(desc2);
step.setSystem(system);
}
}