Messages posted by: kwedeer  XML
Profile for kwedeer -> Messages posted by kwedeer [4]
Author Message
mkat, many thanks - code:

worked for me.
No I am exploring - whether it works, if I try to update "description" field.
OK - I have found at least partial answer myself - as it is advised in O'Reilly book about JavaServer Faces - then one should use javax.faces.model.DataModel descendants with JSF DataTable or ice:DataTable, as I found - there is com.icesoft.faces.model.SetDataModel (inhertied from DataModel). I guess - that nothing more sophisticated is not needed even for enterprise grade applications, am I right?
As I understand, it is the best option to wrap any result from JPQL (Java Persistence Query Language or EJBQL) into DataModel and the put the reference to this DataModel on the ice:DataTable. It is pretty easy to see how to do this, if the SELECT clause contains single entity - like in the code from BEA JPQL API reference:
EntityManager em = ...
 Query q = em.createQuery ("SELECT x FROM Magazine x");
 List<Magazine> results = (List<Magazine>) q.getResultList ();

One can simple call myDataModelInstance.setWrappedData(results) and that is all. But how to handle the case:
1) when there are multiple entities in the SELECT clause - like SELECT x, y from Magazine x, Article y, ...
2) when there are separate fields in the SELECT clause - like SELECT x.PublishinHouse, y.Author from Magazine x, Article y,...

Well - I see that one solution is to create separate Java class for each such query and this class can hold the record, resulting from such query. Well - there can be class MyRecord with properties x and y or even - MyRecord properties set can be the union of properties sets of x and y.

But it is not really nice solution how to handle this, because - queries with joins should be pretty common case for any well designed and denormalized data model and it ias a bit hard to image that I should create helper classes for any report I should make. Is there better solution to that?

I have tried to write (magazinePublishingHouse is property for Magazine x entity and it is PublishingHouse entity itself with property description):
<ice:outputText id="outputText7" value="#{currentRow['magazinePublishingHouse.description']}"/>

but there is error:
javax.servlet.ServletException: java.lang.Exception: javax.faces.FacesException: javax.el.ELException: javax.faces.el.PropertyNotFoundException: javax.el.PropertyNotFoundException: The class 'default.Magazine' does not have the property'magazinePublishingHouse.description'.

Is there any better solution than to write helper classes for each select?

I am useing NB, I can imagine that IDE can be of help to generate those helper classes - but then - the synchronization can emerge as issue: e.g. if one adds some new property in DB and entity, then he or she should add the same property for helper classes as well, etc.

I am trying to design the architecture and also - to develop code for business application (for accounting and stock inventory etc. - so - there will be a lot of business logic) that will use EJB3 (or simply - Java 5 EE persistent entities) and ICEFaces, and I am trying to do this in Netbeans 6.5, there is no legacy code to take into account.

So - my impression is - that I can put my entities into the EAR (EJB application) and JSF/ICEFaces pages in WAR (web application). Every query will be defined as JPQL query in entities and there will be EJB session beans that will have methods to issue thoses queries (e.g. like findAllInvoicesByStartDateEndDateCustomer) and also - to do other complex business operations (like shipping the invoice or invoice order etc.) (e.g. methods like shipInvoice).

So - my backing beans (from WAR application) will call into the session beans from EAR part of Enterprise application. E.g. - my backing bean for page ListInvoices.iface will have method getAllInvoices whose result will be List<Invoice>. Well - and there is the question: I have tried to consume the getAllInvoices method directly into the ICEFaces table and it worked as expected, I see that I can write some additional code (e.g. make my backing bean a child from special base class) that makes the sorting possible (as it is described in ICEFaces tutorial about tables). So - the big question is - at the present I don't see any necessity for DataProvider or CachedSets. So - does my architecture is normal without use of those DataProviders, CachedSets etc.?

I have read ICEFaces tutorial about CollaborativeCRUD application and DataProviders are used here, but I guess - this was only because the authors made direct access to database in their web application and it is not certainly the good design. E.g. my design (with entities in separate module) can be handy if I am developing desktop Java application further or when I decide to expose my business logic as web services. Am I right?

Well - I have started to investigate how to handle the editable data tables (e.g. - each row uses many InputText componentes) and there is such class as DataModel and maybe I will have to use it, but as I understand - there is not need for DataProvider or CachedSet in this use case as well. Am I righ in this case as well?

Thanks for any advice and estimation of my design - in advance!
Profile for kwedeer -> Messages posted by kwedeer [4]
Go to:   
Powered by JForum 2.1.7ice © JForum Team