Thanks Jaques for suggesting to see how it is done OOTB.
I actually didn't know about performFind. In fact I was writing it from
scratch. It's finally great to be able to use it directly.


Jacques Le Roux wrote
> Did you look at how it's done in OFBiz OOTB? There are plenty of cases
> where you enter/set values for a search and a have a result list
> underneath.
> There are several ways to do this. Using a couple of widget forms (find a
> list forms) with the performFind service in the list form is the easiet,
> when possible
> This is for instance a common pattern in lookups fields
> 
> Jacques
> 
> On Wednesday, January 15, 2014 12:12 PM, 

> jadelomeiri@.co

>  wrote
>> So in fact I have the following form:
>> 
>> /
> <form name="PlanetDropDown" type="single"  target="processDropdown">
>> 
>>  
> <field name="planetId" title="LoanVehicle"
>>
>  map-name="mechMap.postalAddress">
>>    
> <drop-down allow-empty="false" current="selected">
>>      
> <option key="parameterValue1" description="All"/>
>>      
> <option key="parameterValue2" description="Yes"/>
>>      
> <option key="parameterValue3" description="No"/>
>>    
> </drop-down>
>>  
> </field>
>> 
>>  
> <field name="planetId2" title="HireVehicle"
>>
>  map-name="mechMap.postalAddress">
>>    
> <drop-down allow-empty="false" current="selected">
>>      
> <option key="parameterValue1" description="All"/>
>>      
> <option key="parameterValue2" description="Yes"/>
>>      
> <option key="parameterValue3" description="No"/>
>>    
> </drop-down>
>>  
> </field>
>> 
>>  
> <field name="planetId3" title="Type" map-name="mechMap.postalAddress">
>>    
> <drop-down allow-empty="false" current="selected">
>>      
> <entity-options description="${planetName}" entity-name="Planet"
>>
>  key-field-name="planetId" filter-by-date="true">
>>        
> <entity-order-by field-name="planetName"/>
>>      
> </entity-options>
>>    
> </drop-down>
>>  
> </field>
>> 
>>  
> <field name="planetId4" title="Status" map-name="mechMap.postalAddress">
>>    
> <drop-down allow-empty="false" current="selected">
>>      
> <entity-options description="${planetName}" entity-name="Planet"
>>
>  key-field-name="planetId" filter-by-date="true">
>>        
> <entity-order-by field-name="planetName"/>
>>      
> </entity-options>
>>    
> </drop-down>
>>  
> </field>
>> 
>>  
> <field name="ContractStart">
> <date-time type="date" default-value="${bsh:
>>
>  org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
> </field>
>>  
> <field name="ContractEnd">
> <date-time type="date" default-value="${bsh:
>>
>  org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
> </field>
>> 
>>  
> <field name="make">
> <text/>
> </field>
>>  
> <field name="model">
> <text/>
> </field>
>>  
> <field name="registrationNumber">
> <text/>
> </field>
>>  
> <field name="search">
> <submit/>
> </field>
>> 
>> 
> </form>
> /
>> 
>> which is included in a screen.
>> 
>> I then created an event like this:
>> 
>> / public static String processDropdown(HttpServletRequest
>> request,HttpServletResponse response)
>> {
>> String make = request.getParameter("make");
>> String model = request.getParameter("model");
>> String registrationNumber = request.getParameter("registrationNumber");
>> String resultMsg = make + " " + model + " " + registrationNumber;
>> if( make==null || model==null || registrationNumber==null || make=="" ||
>> model=="" || registrationNumber==""  )
>> {return "error";}
>> request.setAttribute("resultMsg", resultMsg);
>> request.setAttribute("allParams", UtilHttp.getParameterMap(request));
>> request.setAttribute("submit", "Submitted");
>> request.setAttribute("_EVENT_MESSAGE_", resultMsg);
>> 
>> 
>> return "success";
>> 
>> }/
>> 
>> note: a lot is there just for testing. + I also wrote a lot of other
>> screens, forms, ...for testing
>> 
>> Question:
>> 
>> How would I, from within the event shown above, trigger a query which
>> would
>> have conditions the make, model & other parameters that I am getting from
>> my
>> FORM.
>> And I would like to show the results of this query in another scree.
>> Would
>> having a FORM of type list in that screen be the best way to show the
>> query
>> results?
>> 
>> 
>> 
>> 
>> 
>> -----
>> Jad El Omeiri

and thank you Lei for the example showing how to use performFind


Lei Wu wrote
> Jad,
> 
> I listed one example for you, with details
> 
> In the widget section of your some screen, add:
>                   
> <decorator-screen name="FindScreenDecorator"
> location="component://common/widget/CommonScreens.xml">
>                     
> <decorator-section name="search-options">
>                       
> <include-form name="FindCourses"
> location="component://curricula/widget/curricula/Forms.xml"/>
>                     
> </decorator-section>
>                     
> <decorator-section name="search-results">
>                       
> <include-form name="ListCourses"
> location="component://curricula/widget/curricula/Forms.xml"/>
>                     
> </decorator-section>
>                   
> </decorator-screen>
> In my example, in form FindCourses, it's just a simple form with type
> 'single', as shown below,
>     
> <form name="FindCourses" type="single" target="courses"
> default-entity-name="VCourses">
>         
> <field name="noConditionFind">
> <hidden value="Y"/>

> </field>
>         
> <field name="courseId"
> title="${uiLabelMap.CourseId}">
> <text-find>
> </text-find>
> </field>
>         
> <field name="courseName"
> title="${uiLabelMap.CourseName}">
> <text-find>
> </text-find>
> </field>
>         
> <field name="searchButton" title="${uiLabelMap.CommonFind}"
> widget-style="smallSubmit">
> <submit button-type="button"
> image-location="/images/icons/magnifier.png"/>
> </field>
>     
> </form>
> In my example, in form ListCourses, note you must have list-name with
> value
> 'listIt', and the only thing left to do is to provide your entityName with
> interest, in my example, it's 'VCourses',
>     
> <form name="ListCourses" type="list" list-name="listIt" target=""
> paginate-target="courses" default-entity-name="VCourses"
> separate-columns="true"
>         odd-row-style="alternate-row" header-row-style="header-row-2"
> default-table-style="basic-table hover-bar">
>         
> <actions>
>             
> <service service-name="performFind" result-map="result"
> result-map-list="listIt">
>                 
> <field-map field-name="inputFields"
> from-field="parameters"/>
>                 
> <field-map field-name="entityName" value="VCourses"/>
>                 
> <field-map field-name="orderBy"
> from-field="parameters.sortField"/>
>                 
> <field-map field-name="viewIndex" from-field="viewIndex"/>
>                 
> <field-map field-name="viewSize" from-field="viewSize"/>
>             
> </service>
>         
> </actions>
>     /* ... other specific contents that your form requires ... */
>     
> </form>
> Hope it helps.
> 
> 
> On Sun, Jan 19, 2014 at 6:53 PM, Jacques Le Roux <

> jacques.le.roux@

>> wrote:
> 
>> Did you look at how it's done in OFBiz OOTB? There are plenty of cases
>> where you enter/set values for a search and a have a result list
>> underneath.
>> There are several ways to do this. Using a couple of widget forms (find a
>> list forms) with the performFind service in the list form is the easiet,
>> when possible
>> This is for instance a common pattern in lookups fields
>>
>> Jacques
>>
>> On Wednesday, January 15, 2014 12:12 PM, 

> jadelomeiri@.co

>> > So in fact I have the following form:
>> >
>> > /
> <form name="PlanetDropDown" type="single"  target="processDropdown">
>> >
>> >  
> <field name="planetId" title="LoanVehicle"
>>
>  > map-name="mechMap.postalAddress">
>> >    
> <drop-down allow-empty="false" current="selected">
>> >      
> <option key="parameterValue1" description="All"/>
>> >      
> <option key="parameterValue2" description="Yes"/>
>> >      
> <option key="parameterValue3" description="No"/>
>> >    
> </drop-down>
>> >  
> </field>
>> >
>> >  
> <field name="planetId2" title="HireVehicle"
>>
>  > map-name="mechMap.postalAddress">
>> >    
> <drop-down allow-empty="false" current="selected">
>> >      
> <option key="parameterValue1" description="All"/>
>> >      
> <option key="parameterValue2" description="Yes"/>
>> >      
> <option key="parameterValue3" description="No"/>
>> >    
> </drop-down>
>> >  
> </field>
>> >
>> >  
> <field name="planetId3" title="Type" map-name="mechMap.postalAddress">
>> >    
> <drop-down allow-empty="false" current="selected">
>> >      
> <entity-options description="${planetName}" entity-name="Planet"
>>
>  > key-field-name="planetId" filter-by-date="true">
>> >        
> <entity-order-by field-name="planetName"/>
>> >      
> </entity-options>
>> >    
> </drop-down>
>> >  
> </field>
>> >
>> >  
> <field name="planetId4" title="Status" map-name="mechMap.postalAddress">
>> >    
> <drop-down allow-empty="false" current="selected">
>> >      
> <entity-options description="${planetName}" entity-name="Planet"
>>
>  > key-field-name="planetId" filter-by-date="true">
>> >        
> <entity-order-by field-name="planetName"/>
>> >      
> </entity-options>
>> >    
> </drop-down>
>> >  
> </field>
>> >
>> >  
> <field name="ContractStart">
> <date-time type="date" default-value="${bsh:
>>
>  > org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
> </field>
>> >  
> <field name="ContractEnd">
> <date-time type="date" default-value="${bsh:
>>
>  > org.ofbiz.base.util.UtilDateTime.nowTimestamp()}"/>
> </field>
>> >
>> >  
> <field name="make">
> <text/>
> </field>
>> >  
> <field name="model">
> <text/>
> </field>
>> >  
> <field name="registrationNumber">
> <text/>
> </field>
>> >  
> <field name="search">
> <submit/>
> </field>
>> >
>> > 
> </form>
> /
>> >
>> > which is included in a screen.
>> >
>> > I then created an event like this:
>> >
>> > / public static String processDropdown(HttpServletRequest
>> > request,HttpServletResponse response)
>> > {
>> > String make = request.getParameter("make");
>> > String model = request.getParameter("model");
>> > String registrationNumber = request.getParameter("registrationNumber");
>> > String resultMsg = make + " " + model + " " + registrationNumber;
>> > if( make==null || model==null || registrationNumber==null || make==""
>> ||
>> > model=="" || registrationNumber==""  )
>> > {return "error";}
>> > request.setAttribute("resultMsg", resultMsg);
>> > request.setAttribute("allParams", UtilHttp.getParameterMap(request));
>> > request.setAttribute("submit", "Submitted");
>> > request.setAttribute("_EVENT_MESSAGE_", resultMsg);
>> >
>> >
>> > return "success";
>> >
>> > }/
>> >
>> > note: a lot is there just for testing. + I also wrote a lot of other
>> > screens, forms, ...for testing
>> >
>> > Question:
>> >
>> > How would I, from within the event shown above, trigger a query which
>> would
>> > have conditions the make, model & other parameters that I am getting
>> from my
>> > FORM.
>> > And I would like to show the results of this query in another scree.
>> Would
>> > having a FORM of type list in that screen be the best way to show the
>> query
>> > results?
>> >
>> >
>> >
>> >
>> >
>> > -----
>> > Jad El Omeiri
>>

It wasn't just useful. But very very useful! Thanks!



-----
Jad El Omeiri
--
View this message in context: 
http://ofbiz.135035.n4.nabble.com/find-records-after-submitting-FORM-tp4647193p4647485.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to