tag:blogger.com,1999:blog-6868595312516376692.post8263133924575783954..comments2023-11-23T09:33:53.598+01:00Comments on Enterprise Software Development with Java: The Java EE 6 Example - Gracefully dealing with Errors in Galleria - Part 6Markus Eiselehttp://www.blogger.com/profile/16195673592300911244noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-6868595312516376692.post-46187064958806545342012-12-05T19:23:48.410+01:002012-12-05T19:23:48.410+01:00Amazing bolg.. keep it up.Amazing bolg.. keep it up.Tosha Shahhttps://www.blogger.com/profile/09290417837748253915noreply@blogger.comtag:blogger.com,1999:blog-6868595312516376692.post-37273291091789487982012-05-11T13:20:47.510+02:002012-05-11T13:20:47.510+02:00Correction to my original post- the JSF-Code did n...Correction to my original post- the JSF-Code did not show up. It should read...<br /><br />Then you can write your JSF CreateAlbum.xhtml like<br /><h:inputText id="albumName" value="#{petersCreate.name}" />Peter Huberhttps://www.blogger.com/profile/11027182887206691775noreply@blogger.comtag:blogger.com,1999:blog-6868595312516376692.post-81070668491389246052012-05-11T11:43:12.702+02:002012-05-11T11:43:12.702+02:00Hi y'all
I've read the tutorial and the b...Hi y'all<br /><br />I've read the tutorial and the blogs only a few days ago, so don't get bothered by my comments which actually are not concerned with exceptions and are a bit late ;-)<br /><br />I like the tutorial - big thumbs up for Vineet - especially the part about testing.<br /><br />What I would like to comment on is the use of CDI...or let's say the potential for improvement. <br /><br />@EJB vs @Inject<br />---------------------------------- <br />I would try to get rid of @EJB annotations completely. This is why JEE6 is sort of horrible - you have two or more ways to do the same thing (@EJB vs. @Inject). But I think CDIs annotations are more powerful than @EJB and should therefore be preferd.<br />What makes the situation complicated is that there are even Name-clashes (@Produces), so be carefull with the annotation you use actually - to an outsider this looks like JSR-Teams try to avoid to talk to each other sometimes ;-) But that is another storry.<br /><br /><br />@JSF powered by CDI<br />---------------------------------- <br />However, there are other use cases where you can use CDI, i.e. @Producer and @Inject to tie things together in a clever way. Let's see, for instance if you do it like this in AlbumManager<br /><br /> @Produces @Named("petersCreate")<br /> private CreateAlbumRequest createRequest = new ....<br /><br />Then you can write your JSF CreateAlbum.xhtml like<br /> <br /><br />And you can get rid of getters/setters for CreateAlbumRequest in AlbumManager<br /><br />BUT stop this is only part of the story. If you try that then CDI creates more copies of CreateAlbumRequest. Why is that? Because currently AlbumManager is not CDI-Scoped, which makes the CDI-Runtime create an <br />AlbumManager for each Inject-Point...but this is CDI subtleties. To come around this and using CDI-out-of-the-box you should put AlbumManager in SessionScope for now...s. comment about CDI-ViewScope below.<br /><br /> @SessionScoped //prevents from multiple Copies <br /> @Named //must not forget this to make it availible in JSF<br /> public class AlbumManager implements Serializable<br /><br /><br />Or make it even more clever - probably we can even try to make the CreateRequest a @Model (@Model is a CDI Stereotype)?<br />That would then be very easy tied togehter<br /><br /> @Model<br /> public class CreateAlbumRequest<br /><br /> @Inject <br /> private CreateAlbumRequest createRequest;<br /><br />This provides for pretty loose coupling I see some potential for reuse-patterns, because Views don't have to be tied to Managers directly.<br /><br />I think in the future we will see even patterns which show some Produce-Inject-Cascades, I think about the use cases like this: Search -> Result-List -> Select Item From Result List -> Edit Details of selected Item. <br />If you have a BackingBean for each of the Steps than for instance the ResultList may CDI-Produce the selected Item which is then CDI-Injected into the Backing Bean of the EditDetailBackingBean<br /><br />Currently you might run into some complications<br />1.) Trying to get rid of JSF-only Scopes because out-of-the-box CDI misses some Scopes like for instance ViewScope, but there are Protable CDI-Extensions which do help you to get around that...somewhere at jboss, maybe this http://seamframework.org/Seam3/Home<br />And actually doing an ViewScope on your own for JSF is straight forward.<br />2.) Don't forget to place "beans.xml" files ;-)<br /><br />@Vineet - If you reead this, I can provide some patches, if you're interested in.<br /><br />Cheers from another msg systems ag guy<br />Peter HuberPeter Huberhttps://www.blogger.com/profile/11027182887206691775noreply@blogger.comtag:blogger.com,1999:blog-6868595312516376692.post-8696060056684410382012-04-02T08:55:24.004+02:002012-04-02T08:55:24.004+02:00Hi Heidarzadeh,
the code actually isn't in bi...Hi Heidarzadeh,<br /><br />the code actually isn't in bitbucket. I tried to link the more complex files in the text. Vineet is integrating the changes if he finds them useful. That's completely fair to me, as I am only willing to show relevant parts that I find interesting which might not reflect his intention.<br /><br />Thanks for reading,<br />-MMarkus Eiselehttps://www.blogger.com/profile/16195673592300911244noreply@blogger.comtag:blogger.com,1999:blog-6868595312516376692.post-22456934076674547962012-04-02T08:52:40.836+02:002012-04-02T08:52:40.836+02:00Hi Markus.
Thank you for continuation of Galleria ...Hi Markus.<br />Thank you for continuation of Galleria tutorial.<br />I couldn't find the code related to this part of tutorial in bitbucket!<br />Did you commit them to repository?<br /><br />ThanksHeidarzadehhttps://www.blogger.com/profile/16276389986655915283noreply@blogger.com