我有两个类,一个是普通bean,另一个是托管bean。我正尝试将aboutProduct(List)与我的数据表绑定在一起。但我无法看到价值。请参阅代码。无法从托管bean获取dataTable中的值
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;
}
}
/-----这里是我的DataTable的代码。/
<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
没有它没有工作。即使我试图从ProductInfoBean中获取任何变量的值(假设myvar与getter和setter),我也没有获得成功。如果你想要更多的解释,请告诉我。 – manas
我试图在我的.xhtm页面打印值使用 任何错误在这.. ..? –
manas
因此,您无法访问该bean。检查两次bean名称。你确定它可以用'@ Controller'定义吗? –