单击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>
我的Backing 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";
}
我没有在Server Log上获取addProperty()方法的System.out.println(),即当我点击Add按钮时我的addProperty方法没有被调用。
请帮助....