|
|
Hi again friends!
I have a problem generating a finder... the problem (1 of them) is:
is there any way to create a dynamic finder wich alows me to search even if the user inputs just 1 of the parameters?
this is the code I manually created:
Code:
public static TypedQuerylt;Docgt; searcher(String name, Date minDate, Date maxDate, String description) { int count=0; String query=quot;SELECT Doc FROM Doc AS doc WHERE quot;; EntityManager em =Doc.entityManager(); if (name != null amp;amp; name.length() gt; 0){ if(countgt;0){ query+=quot; AND quot;; } query+=quot;doc.name = :namequot;; count++; } if ((minDate != null)amp;amp;(maxDate!=null)){ if(countgt;0){ query+=quot; AND quot;; } query+=quot;doc.Date BETWEEN :minDate AND :maxDatequot;; count++; } if (description != null amp;amp; description.length() gt; 0){ if(countgt;0){ query+=quot; AND quot;; } query+=quot;doc.description = :descriptionquot;; count++; } TypedQuerylt;Docgt; q = em.createQuery(query, Doc.class); if((name!=null)amp;amp;(name.length()gt;0)){q.setParameter(quot;namequot;, name);} if(minDate!=null){q.setParameter(quot;minDatequot;, minDate);} if(maxDate!=null){q.setParameter(quot;maxDatequot;, maxDate);} if((description!=null)amp;amp;(description.length()gt;0)){q.setParameter(quot;descriptionquot;, description);} return q; }
the idea is the query could be done even if the user just inputs 1 parameter... I found this code a little complex, I don't know if roo (with finder add command) can make a finder with similar features...
and my second problem is... how can I encapsulate a finder form within a popup? I'm using fancybox
thanks |
|