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:
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...Code:public static TypedQuery<Doc> searcher(String name, Date minDate, Date maxDate, String description) { int count=0; String query="SELECT Doc FROM Doc AS doc WHERE "; EntityManager em =Doc.entityManager(); if (name != null && name.length() > 0){ if(count>0){ query+=" AND "; } query+="doc.name = :name"; count++; } if ((minDate != null)&&(maxDate!=null)){ if(count>0){ query+=" AND "; } query+="doc.Date BETWEEN :minDate AND :maxDate"; count++; } if (description != null && description.length() > 0){ if(count>0){ query+=" AND "; } query+="doc.description = :description"; count++; } TypedQuery<Doc> q = em.createQuery(query, Doc.class); if((name!=null)&&(name.length()>0)){q.setParameter("name", name);} if(minDate!=null){q.setParameter("minDate", minDate);} if(maxDate!=null){q.setParameter("maxDate", maxDate);} if((description!=null)&&(description.length()>0)){q.setParameter("description", description);} return q; }
and my second problem is... how can I encapsulate a finder form within a popup? I'm using fancybox
thanks![]()


Reply With Quote