我有两个类,一个是普通 bean,第二个是托管 bean。我正在尝试将 aboutProduct(List) 与我的数据表绑定。但我看不到这些值。请参考代码。
public class ProductInfoAttributes {
private String paramName;
private String paramValue;
public String getParamName() {
return paramName;
}
public void setParamName(String paramName) {
this.paramName = paramName;
}
public String getParamValue() {
return paramValue;
}
public void setParamValue(String paramValue) {
this.paramValue = paramValue;
}
public ProductInfoAttributes(String paramName, String paramValue) {
super();
this.paramName = paramName;
this.paramValue = paramValue;
}
}
//------ Managed Bean Class
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
@Controller("productInfoBean")
@Scope("session")
public class ProductInfoBean implements Serializable {
private static final long serialVersionUID = 1L;
List<ProductInfoAttributes> aboutProduct;
public List<ProductInfoAttributes> getAboutProduct() {
return aboutProduct;
}
public void setAboutProduct(List<ProductInfoAttributes> aboutProduct) {
this.aboutProduct = aboutProduct;
}
public List<ProductInfoAttributes> showDetails() {
aboutProduct = new ArrayList<ProductInfoAttributes>();
aboutProduct.add(new ProductInfoAttributes("Host Name", "localhost"));
aboutProduct.add(new ProductInfoAttributes("Folder", "newfolder"));
aboutProduct.add(new ProductInfoAttributes("App Server", "JBoss"));
return aboutProduct;
}
public static String getName() {
return name;
}
}
/ ----- 这是我的数据表代码。/
<h:dataTable value="#{productInfoBean.showDetails}" var="details"> /*----- my datatable */
<h:column>
<f:facet name="header">Feature</f:facet>
<h:outputText value="#{details.paramName}" rendered="true" />
</h:column>
<h:column>
<f:facet name="header">Description</f:facet>
<h:outputText value="#{details.paramValue}" rendered="true" />
</h:column>
</h:dataTable> /*----- data table ends.*/
请告诉我哪里错了。我没有在数据表中获取值。我正在使用 JSF 1.2