0

从 jsf 页面单击“添加”按钮时,我无法调用支持 bean 方法“addProperty”。任何机构都可以帮忙吗???

我的 JSF 页面代码是

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            template="layout/layout.xhtml">

<ui:define name="body">
    <h:panelGrid columns="2">
    <h:form>
        <ui:repeat  id="paramList" value="#{patchingBean.propertyList}" var="prop">
            <h:outputLabel value="Name:"></h:outputLabel>
        <h:inputText id="inputName" value="#{prop.name}"></h:inputText>
            <h:outputLabel value="Value:"></h:outputLabel>
            <h:inputText id="inputValue" value="#{prop.value}"/>
        </ui:repeat>

        <h:commandButton value ="Add"  action  ="#{patchingBean.addProperty}"/>
        <!--<h:commandButton update="paramList" type="submit" value="Add more" rendered="true">-->
            <!--<f:ajax render="paramList" listener="#{patchingBean.addProperty}" />-->
        <!--</h:commandButton>-->
    </h:form>
    </h:panelGrid>
</ui:define>

我的支持 Bean 代码是

@Named("patchingBean")
@ViewScoped
public class PatchingBackingBean implements Serializable {


ObjectFactory objFactory= new ObjectFactory();
private List<Property> propertyList=null;


@PostConstruct
public  void init(){
   System.out.println("Creating the initial data once, don't repeat");
   propertyList=new ArrayList<Property>();
   Property prop=objFactory.createProperty();
   prop.setName(CommandParamName.PLAN.toString());
   propertyList.add(prop);
   System.out.println("Size of the list " + propertyList.size());
  }
 public List<Property> getPropertyList() {
    return propertyList;
 }

 public void setPropertyList(List<Property> propertyList) {
    this.propertyList = propertyList;
  }
 public String addProperty() {
    System.out.println("Adding the data into the list************************");
    propertyList.add(objFactory.createProperty());
    System.out.println("size of list after getting added "+ propertyList.size());
    return "AddedProperty";
 }

我没有在服务器日志上获得 addProperty() 方法的 System.out.println() ,即当我单击添加按钮时没有调用我的 addProperty 方法。

请帮助....

4

0 回答 0