Announcement Announcement Module
Collapse
No announcement yet.
finders and jquery Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • finders and jquery

    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 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;
    	    }
    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
    Last edited by ycabello; Feb 17th, 2011, 10:35 AM.

  • #2
    Hello community Roo!

    I need to create a filter search for my application.จ


    จจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจจ จจจจจจจจจจจจจจ
    exception

    javax.servlet.ServletException: The component ID menuForm: voteSubmenu already found in the preview
    javax.faces.webapp.FacesServlet.service(FacesServl et.java:606)
    org.primefaces.webapp.filter.FileUploadFilter.doFi lter(FileUploadFilter.java:79)
    org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter.doFilterInternal(OpenEntityManager InViewFilter.java:147)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)


    root cause

    java.lang.IllegalStateException: The component ID menuForm: voteSubmenu already found in the preview.
    com.sun.faces.util.Util.checkIdUniqueness(Util.jav a:821)
    com.sun.faces.util.Util.checkIdUniqueness(Util.jav a:805)
    com.sun.faces.util.Util.checkIdUniqueness(Util.jav a:805)
    com.sun.faces.util.Util.checkIdUniqueness(Util.jav a:805)
    com.sun.faces.util.Util.checkIdUniqueness(Util.jav a:805)
    com.sun.faces.util.Util.checkIdUniqueness(Util.jav a:805)
    com.sun.faces.util.Util.checkIdUniqueness(Util.jav a:805)
    com.sun.faces.application.view.StateManagementStra tegyImpl.saveView(StateManagementStrategyImpl.java :144)
    com.sun.faces.application.StateManagerImpl.saveVie w(StateManagerImpl.java:133)
    com.sun.faces.application.view.WriteBehindStateWri ter.flushToWriter(WriteBehindStateWriter.java:225)
    com.sun.faces.application.view.FaceletViewHandling Strategy.renderView(FaceletViewHandlingStrategy.ja va:418)
    com.sun.faces.application.view.MultiViewHandler.re nderView(MultiViewHandler.java:131)
    com.sun.faces.lifecycle.RenderResponsePhase.execut e(RenderResponsePhase.java:121)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:1 01)
    com.sun.faces.lifecycle.LifecycleImpl.render(Lifec ycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServl et.java:594)
    org.primefaces.webapp.filter.FileUploadFilter.doFi lter(FileUploadFilter.java:79)
    org.springframework.orm.jpa.support.OpenEntityMana gerInViewFilter.doFilterInternal(OpenEntityManager InViewFilter.java:147)
    org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)


    follows commands used:

    jpa setup --provider HIBERNATE --database HYPERSONIC_PERSISTENT
    entity jpa --class ~.domain.Choice --testAutomatically
    field string namingChoice --notNull --sizeMin 1 --sizeMax 30
    field string description --sizeMax 80
    web jsf setup --library PRIMEFACES --theme SMOOTHNESS --implementation ORACLE_MOJARRA
    web jsf scaffold ~.web.ChoiceController
    entity jpa --class Vote --testAutomatically
    field reference choice --type Choice
    field string ip --notNull --sizeMin 7 --sizeMax 15
    field date registered --type java.util.Date --notNull --past
    web jsf scaffold ~.web.VoteController
    web jsf scaffold ~.web.PublicVoteController
    finder list --class ~.domain.Vote --depth 2 --filter reg,choice
    finder add --finderName findVotesByChoice
    finder add --finderName findVotesByChoiceOrRegisteredBetween


    Can anyone help me on this error?
    Last edited by lorenarc; Dec 4th, 2012, 12:28 PM.

    Comment

    Working...
    X