Great to hear this for me, this philosophy is one of the main reason because I love forge !!<div><br></div><div>But I also need, on my side, to make it works under WebLogic and TomEE, so we need a solution to this problem.</div>
<div><br></div><div>I created and sent you a test case (forgive the package name, I was in a hurry !!), you can reproduce the problem this way:</div><div><br></div><div>1) Create a group</div><div>2) Go into the Account creation form and try to associate a group to the Account</div>
<div><br></div><div>The problem is recreated.</div><div><br></div><div>Thank you for your invaluable support.</div><div><br></div><div>L.<br><br><div class="gmail_quote">2012/8/6 Richard Kennard <span dir="ltr"><<a href="mailto:richard@kennardconsulting.com" target="_blank">richard@kennardconsulting.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Luca,<br>
<br>
> factory that hide that complexity<br>
<br>
One of the main challenges we have is that there *is* nowhere to 'hide that complexity'. Everything we generate is part of user's final project. They will<br>
see it, and therefore will need to understand and maintain it. We *did* originally try creating base classes/factories, but then we are essentially<br>
creating a Forge-specific, undocumented, unsupported framework on top of EE.<br>
<br>
Could you please ZIP up your sample app and send it to me at <a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>? Then I can try and reproduce the errors you're seeing.<br>
<br>
Regards,<br>
<br>
Richard.<br>
<div class="im"><br>
On 6/08/2012 6:56 PM, Luca Masini wrote:<br>
> Thank you for your feedback Richard.<br>
><br>
> I tried your proposal and it breaks something else because the annotated class is used everywhere to convert the POJO, and on the log I can find this line:<br>
><br>
> 10:45:46,485 INFO [javax.enterprise.resource.webcontainer.jsf.renderkit] (http--127.0.0.1-8080-2) WARNING: FacesMessage(s) have been enqueued, but may<br>
> not have been displayed.<br>
> sourceId=create:accountBeanAccountGroupsSelect[severity=(ERROR 2), summary=(create:accountBeanAccountGroupsSelect: Validation Error: Value is not valid),<br>
> detail=(create:accountBeanAccountGroupsSelect: Validation Error: Value is not valid)]<br>
><br>
> Regarding the solution I proposed, I agree that generated code must be simple, but I really can't figure another way to inject an extended persistence<br>
> context inside a client object.<br>
><br>
> In case we factor out the converter and write an util class with a factory that hide that complexity.<br>
><br>
> What do you think ?<br>
><br>
><br>
><br>
</div>> 2012/8/6 Richard Kennard <<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a> <mailto:<a href="mailto:richard@kennardconsulting.com">richard@kennardconsulting.com</a>>><br>
<div><div class="h5">><br>
> Luca,<br>
><br>
> Thanks for your time and help debugging this. I think we need to proceed with caution.<br>
><br>
> We're basically talking about hacks to work around bugs in the app server/shortcomings in the EE spec. The problem is these hacks are going to get<br>
> re-generated for every domain entity (potentially dozens of times). It's critical we try to keep our generated code as clean as possible. In<br>
> particular, we<br>
> must keep the 'semantic complexity' low.<br>
><br>
> The solution you're suggesting (injecting a SessionContext, taking EJBObject using getBusinessInterface etc) sounds like a lot of 'semantic<br>
> complexity' for<br>
> new users to understand?<br>
><br>
> It's really important we try to find the cleanest approach. We tried/rejected a lot of variations when developing the current code. Here's one that's not<br>
> quite as nice as the current one, but may work properly across TomEE/Weblogic/JBoss. Could you try it for me?<br>
><br>
> 1. Remove all references in the generated Facelets code to: converter="#{foo.converter}"<br>
> 2. Remove the 'getConverter()' method inside each xxxBean and replace with a static inner class that looks like:<br>
><br>
> @FacesConverter( forClass = xxx.class )<br>
> public static class xxxConverter<br>
> implements Converter {<br>
><br>
> @Override<br>
> public Object getAsObject( FacesContext context, UIComponent component, String value ) {<br>
><br>
> // EntityManager injection not reliable on all platforms<br>
><br>
> xxx entity = new xxx();<br>
> entity.setId( Long.valueOf( value ) );<br>
> return entity;<br>
> }<br>
><br>
> @Override<br>
> public String getAsString( FacesContext context, UIComponent component, Object value ) {<br>
><br>
> ...<br>
> }<br>
> }<br>
><br>
> Here's a complete example:<br>
><br>
> <a href="https://github.com/metawidget/metawidget/blob/master/integration-tests/faces/forge/src/main/java/com/test/view/PersonBean.java" target="_blank">https://github.com/metawidget/metawidget/blob/master/integration-tests/faces/forge/src/main/java/com/test/view/PersonBean.java</a><br>
><br>
> Regards,<br>
><br>
> Richard.<br>
><br>
> On 3/08/2012 9:17 PM, Luca Masini wrote:<br>
> > The fact is that we have an extended persistente unit bound to the stateful ejb, so can't be injected or looked up.<br>
> ><br>
> > I've found a solution working on my three target App Server (TomEE, Weblogic, JBoss).<br>
> ><br>
> > Inject a SessionContext and take the EJBObject using the getBusinessInterface method.<br>
> ><br>
> > For some strange reason SessionContext and his Ejb have different lifecycle so we need to take it before it is returned to the jsf client.<br>
> ><br>
> > This way it works.<br>
> ><br>
> > Il giorno venerdė 3 agosto 2012, Richard Kennard ha scritto:<br>
> ><br>
> > Yes, you could try that. The history to this decision was:<br>
> ><br>
> > 1. The Converter needs to use an EntityManager to load the entity<br>
> > 2. For some reason you cannot (yet) inject EntityManagers into FacesConverters<br>
> ><br>
> > So I made the Converter an inner class of the xxxBean, so that it could access the bean's EntityManager. However there would be other<br>
> approaches, such as<br>
> > looking up the EntityManager via JNDI or something.<br>
> ><br>
> > Regards,<br>
> ><br>
> > Richard.<br>
> ><br>
> > On 3/08/2012 8:15 PM, Thomas Frühbeck wrote:<br>
> > > Did you think of separating Converter and backing bean implementation?<br>
> > > AFAIK the backing bean _provides_ a converter e.g.: #{xxxxxBean.converter} but should not implement Converter itself?<br>
> > ><br>
> > > Thomas<br>
> > ><br>
> > > Am 03.08.2012 11:13, schrieb Luca Masini:<br>
> > >> I'm going crazy to let the generated faces scaffolding run on both WLS and JBoss.<br>
> > >><br>
> > >> Infact if I let the Bean implements the Converter interface then WLS works but JBoss complaints about missing method, it's like that the<br>
> implemented<br>
> > >> interface is the Local interface for the bean and no other method is found but those in the Converter interface itself.<br>
> > >><br>
> > >> So I remove the interface and everything work without the getConverter method, getAsObject and getAsString are method of the now interface bean.<br>
> > >><br>
> > >> On the counter side WLS is unable to call methods from the EL into faces files that are not part of the Converter interface.<br>
> > >><br>
> > >> So I'm in a deadlock. I'm unable to let it works on both the Java EE 6 server. I'm sure that a solution exist, but whichi ?<br>
> > >><br>
> > >> --<br>
> > >> ****************************************<br>
> > >> <a href="http://www.lucamasini.net" target="_blank">http://www.lucamasini.net</a><br>
> > >> <a href="http://twitter.com/lmasini" target="_blank">http://twitter.com/lmasini</a><br>
> > >> <a href="http://www.linkedin.com/pub/luca-masini/7/10/2b9" target="_blank">http://www.linkedin.com/pub/luca-masini/7/10/2b9</a><br>
> > >> ****************************************<br>
> > >><br>
> > >><br>
> > >> _______________________________________________<br>
> > >> forge-dev mailing list<br>
</div></div>> > >> <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> <mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>> <javascript:;><br>
<div class="im">> > >> <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > _______________________________________________<br>
> > > forge-dev mailing list<br>
</div>> > > <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> <mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>> <javascript:;><br>
<div class="im">> > > <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
> ><br>
> > _______________________________________________<br>
> > forge-dev mailing list<br>
</div>> > <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> <mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>> <javascript:;><br>
<div class="im">> > <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > ****************************************<br>
> > <a href="http://www.lucamasini.net" target="_blank">http://www.lucamasini.net</a><br>
> > <a href="http://twitter.com/lmasini" target="_blank">http://twitter.com/lmasini</a><br>
> > <a href="http://www.linkedin.com/pub/luca-masini/7/10/2b9" target="_blank">http://www.linkedin.com/pub/luca-masini/7/10/2b9</a><br>
> > ****************************************<br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > forge-dev mailing list<br>
</div>> > <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> <mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>><br>
<div class="im">> > <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
><br>
> _______________________________________________<br>
> forge-dev mailing list<br>
</div>> <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a> <mailto:<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>><br>
<div class="HOEnZb"><div class="h5">> <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
><br>
><br>
><br>
><br>
> --<br>
> ****************************************<br>
> <a href="http://www.lucamasini.net" target="_blank">http://www.lucamasini.net</a><br>
> <a href="http://twitter.com/lmasini" target="_blank">http://twitter.com/lmasini</a><br>
> <a href="http://www.linkedin.com/pub/luca-masini/7/10/2b9" target="_blank">http://www.linkedin.com/pub/luca-masini/7/10/2b9</a><br>
> ****************************************<br>
><br>
><br>
> _______________________________________________<br>
> forge-dev mailing list<br>
> <a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>****************************************<br><a href="http://www.lucamasini.net">http://www.lucamasini.net</a><br><a href="http://twitter.com/lmasini">http://twitter.com/lmasini</a><br>
<a href="http://www.linkedin.com/pub/luca-masini/7/10/2b9">http://www.linkedin.com/pub/luca-masini/7/10/2b9</a><br>****************************************<br>
</div>