ofbiz-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Dixit <deepak.di...@hotwaxmedia.com>
Subject Re: ajax response
Date Mon, 06 Sep 2010 05:00:49 GMT
Hi Pierre,

After looking your code you need to run Ajax.updator instead of 
Ajax.request, because your request just rendering the view instead of 
returning the service response.You are using groovy for data fetching, 
If you want to run Ajax.Requset then convert that groovy file to service 
and then same code will work for you.One more thing you need to change 
in controller .xml :

<request-map uri="getAssociatedTaskList">
       <security https="true" auth="true"/>
       <response name="success" type="request" value="json"/>
</request-map>

For more reference please see specialpurpose/ecommerce/webapp/ecommerce/WEB-INF/controller.xml
file for ajax call.
e.g. 
  <request-map uri="getCountryList">
        <security https="true" auth="false"/>
        <event type="service" invoke="getCountryList"/>
        <response name="success" type="request" value="json"/>
        <response name="error" type="request" value="json"/>
    </request-map>



Thanks & Regards
-- 
Deepak Dixit




Pierre Smits wrote:
> Hi Sascha,
>
> As I am a newbie on OFBiz and ajax, do you know of an example in OFBiz .js
> files that doesn't look for a JSON object?
>
> Regards,
>
> Pierre
>
> 2010/9/3 Sascha Rodekamp <sascha.rodekamp.lynx.de@googlemail.com>
>
>   
>> Hi Pierre,
>> you're Ajax request looks for a JSON Object in you're return parameters and
>> you try to render a screen. Try to start you're Ajax request without asking
>> for an JSON Object.
>> That should work. If not let me now.
>>
>> Cheers
>> Sascha
>>
>>
>>
>>
>> 2010/9/2 Pierre Smits <pierre.smits@gmail.com>
>>
>>     
>>> Hi all,
>>>
>>> In a .ftl form I build a list of projects available. The list contains
>>>       
>> per
>>     
>>> row a selection box to generate a query-string.
>>>
>>> I then pass the request (with the query-string) to following javascript
>>> function:
>>>
>>> function getAssociatedTaskList(request) {;
>>>    new Ajax.Request( request, {
>>>        onSuccess: function(transport) {
>>>            var data = transport.responseText.evalJSON(true);
>>>            var serverError = getServerError(data);
>>>            if (serverError != "") {
>>>                alert("het gaat fout");
>>>                Effect.Appear('createListError',{duration:0.0});
>>>                $('createListError').update(serverError);
>>>            } else {
>>>                Effect.Fade('createListError', {duration: 0.0});
>>>                new Ajax.Updater($('TaskOverview'), 'ListTasks' ,
>>> {evalScripts: true});
>>>            }
>>>        },
>>>        asynchronous: true,
>>>        requestHeaders: {Accept: 'application/json'}
>>>    });
>>> }
>>>
>>> the request is like:
>>> /application/control/getAssociatedTaskList?projectsSelected=10050
>>>
>>> The request-map in controller.xml is:
>>> <request-map uri="getAssociatedTaskList">
>>>        <security https="true" auth="true"/>
>>>        <response name="success" type="view"
>>>       
>> value="getAssociatedTaskList"/>
>>     
>>>    </request-map>
>>>
>>> With the corresponding view-map:
>>> <view-map name="getAssociatedTaskList" type="screen"
>>> page="component://application/widget/applicationScreens.xml#ListTasks"/>
>>>
>>> ListTasks in applicationScreens.xml contains:
>>> <screen name="ListTasks">
>>>        <section>
>>>            <actions>
>>>                <property-map resource="casUiLabels" map-name="uiLabelMap"
>>> global="true"/>
>>>                <set field="parameters.partyId"
>>> from-field="parameters.userLogin.partyId"/>
>>>                <script
>>>
>>>
>>>       
>> location="component://application/webapp/application/WEB-INF/actions/projects/ListTasks.groovy"/>
>>     
>>>            </actions>
>>>            <widgets>
>>>                <platform-specific>
>>>                    <html><html-template
>>> location="component://cas/webapp/cas/cas/listTasks.ftl"/></html>
>>>                </platform-specific>
>>>            </widgets>
>>>        </section>
>>>    </screen>
>>>
>>> When the js function is executed I see that the groovy file gets the
>>> correct
>>> parameters (from the query string passed).
>>>
>>> But I don't see the ajax result appearing in the div
>>>       
>> (div="TaskOverview").
>>     
>>> Can you help with some pointers?
>>>
>>> Regards,
>>>
>>> Pierre
>>>
>>>       
>>
>> --
>> Sascha Rodekamp
>>    Lynx-Consulting GmbH
>>    Johanniskirchplatz 6
>>    D-33615 Bielefeld
>>    http://www.lynx.de
>>
>>     
>
>   



Mime
View raw message