-
1. Re: Strange error passing object in EL
blabno Mar 18, 2010 9:41 AM (in response to wachtda.scsi.gmx.ch)Absolutely not a Tomcat problem. Show full source code of bean containing showPoisitons method. Especially scopes are interesting. My guess is that condition in your
if
changes over postback resulting in different list size.
Please do caching of your positions list and put your bean to at leas PAGE scope.private List<Position> positions; public List<Position> showPositions() { if(positions == null) { String query = "SELECT p FROM Product p"; List<Product> products = em.createQuery(query).getResultList(); positions = new LinkedList<Position>(); for (Product product : products) { positions.add(new Position(product, 1)); } } return positions; }
-
2. Re: Strange error passing object in EL
wachtda.scsi.gmx.ch Mar 18, 2010 10:03 AM (in response to wachtda.scsi.gmx.ch)hi bernard
thanks for the quick reply!
sadly i don't have the code at my site, but the bean is in conversation scope!
but i spotted some problems with plain tomcat and conversations (i don't have a ejb container),
the conversation seams not to work!my bean is named and configured like this:
@Name("myBean") @Scope(ScopeType.CONVERSATION) public class MyBeanImpl implements MyBean { //... }
maybe i give the @Page scpe a try...
-
3. Re: Strange error passing object in EL
blabno Mar 18, 2010 1:51 PM (in response to wachtda.scsi.gmx.ch)Daniel, it is absolutely impossible that conversations do not work, because of Tomcat. You must have not used them properly. Having bean put in CONVERSATION scope does not guarantee postback survival. By default conversation is not long-running and thus almost equal to EVENT scope. This may be your case.
-
4. Re: Strange error passing object in EL
wachtda.scsi.gmx.ch Mar 18, 2010 2:31 PM (in response to wachtda.scsi.gmx.ch)hm, strange, i annotated my functions inside the conversation scoped bean with
@Begin(join=true)
and it doesn't work. if i make this the same way on a bean runned inside my ejb container (jboss as) then it works like a charme...
-
5. Re: Strange error passing object in EL
blabno Mar 18, 2010 2:54 PM (in response to wachtda.scsi.gmx.ch)How do you invoke those methods ? In order for anotations to work, invocations must be done on proxies, and not on the bean itself. Note that EL expressions work on proxies, injected beans are proxies in fact, Component.getInstance also returns proxies. But :
@Name("foo") public class Foo { public void bar() { bar2(); } @Begin public void bar2(){} }
If you call #{foo.bar} then no conversation will be started because bar is invoked on proxy, but bar2 is invoked directly on bean.
-
6. Re: Strange error passing object in EL
wachtda.scsi.gmx.ch Mar 18, 2010 3:12 PM (in response to wachtda.scsi.gmx.ch)ok, this is correct. but my bean looks like this:
@Name("myBean") @Scope(ScopeType.CONVERSATION) public class MyBeanImpl implements MyBean { @Begin(join=true) public List<Position> showPositions() { String query = "SELECT p FROM Product p"; List<Product> products = em.createQuery(query).getResultList(); List<Position> positions = new LinkedList<Position>(); for (Product product : products) { positions.add(new Position(product, 1)); } } }
and the function in my bean is called in the el like this,
so i don't see the problems:<h:form> <h:dataTable value="#{myBean.showPositions()}" var="position"> <h:column> #{position.name} </h:column> <h:column> <h:commandButton value="Get it" action="#{myBean.addPosition(position)}" /> </h:column> </h:dataTable> </h:form>
what is could be the problem?
thanks for your effort, bernard!
:-) -
7. Re: Strange error passing object in EL
wachtda.scsi.gmx.ch Mar 19, 2010 10:15 PM (in response to wachtda.scsi.gmx.ch)I found the problem!
The problem is not the access of the bean, but the request parameter which i use to check the property.@RequestParameter(value="cat") private String productGroupLabel;
If i check the property with a common String, the problem does not occur.
I have seam url rewriting configured like this:<page view-id="/products.xhtml"> <rewrite pattern="/wunschbuch" /> <rewrite pattern="/wunschbuch/{cat}" /> <rewrite pattern="/wunschbuch/{cat}/" /> <navigation from-action="#{basketAction.addProductToBasket(position)}"> <redirect view-id="/basket.xhtml"/> </navigation> </page>
Could the problem be my url rewriting configuration?
(Beside this problem, I don't got the conversation to run, only session works)
Any hints? Thank you...