This content has been marked as final.
Show 3 replies
-
1. Re: init Page with @Factory, @Create, @Startup
nickarls Jun 11, 2008 11:37 AM (in response to nimo22)Well, @Factory(
foo
) should be called iffoo
is referenced and is found to be null so that's a starting point.You could check out ShowOrdersAction in the dvdstore example.
-
2. Re: init Page with @Factory, @Create, @Startup
gena Jun 11, 2008 11:52 AM (in response to nimo22)You did it already. Try
@Factory("showAllPersonsAtStartup") // not the best name for an entity collection
and use an entity converter for s:selectItems if you wish to know a selection.
-
3. Re: init Page with @Factory, @Create, @Startup
nimo22 Jun 12, 2008 12:22 PM (in response to nimo22)Okay the @Factory works well with that:
my view:
<s:label styleClass="label">Products: </s:label> <h:selectOneMenu > <s:selectItems value="#{initProducts}" var="product" label="#{product[1]}" /> </h:selectOneMenu>
my session bean:
private List <Product> listProduct; @Factory("initProducts") public List <Product> initProducts() { return listProduct = entityManager.createQuery("select id, description, price from Product").getResultList(); }
The
label="#{product[1]
put the data of the field 'description' in the 'selectOneMenu'. This works well.BUT this does not work:
my view:
<s:label styleClass="label">Products: </s:label> <h:selectOneMenu > <s:selectItems value="#{initProducts}" var="product" label="#{product.description}" /> <s:convertEntity /> </h:selectOneMenu>
my session bean:
private Product product; public void setProduct(Product product) { this.product = product; } public Product getProduct() { return product; } private List <Product> listProduct; @Factory("initProducts") public List <Product> initProducts() { return listProduct = entityManager.createQuery("select id, description, price from Product").getResultList(); }
This stacktrace occurs:
ERROR [viewhandler] Error Rendering View[/Product.xhtml] java.lang.NumberFormatException: For input string: "description"
Product is still an entity. What is wrong?