ofbiz-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Crum <adrian.c...@sandglass-software.com>
Subject Re: FreeMarker requestAttribute issue
Date Wed, 04 May 2011 17:36:01 GMT
In FTL:

${context}

In screen widget:

<label text="${context}"/>

-Adrian

On 5/4/2011 10:23 AM, Justin Robinson wrote:
> Now I have another problem also related to the context and what's avaiable
> at times in between requests.
> When a survey is encountered attached to the product being added to the cart
> in, addOrderItem in OrderEvents, the addorderItem service returns "survey"
> which then calls the ftl&  groovy script that all works fine. But when the
> answers have been entered and the form submitted (A SurveyResponse entity is
> created and stored) it then calls addOrderItem again but this time the order
> item doesn't get added because the productId is no longer available in the
> context, at least that seems to be the reason.
> Doubtless it's related and the issue has been encountered before because
> besides the simple-method method-name="createSurveyResponse" in
> SurveyServices.xml of the content app, there's also another service
> createSurveyResponseAndRestoreParameters in SurveyEvents of the content app.
> I tried using this instead but it still doesn't work.
>
> I can't get my head around the context and request parameters thing, if only
> there was some way to see what was in it at any time. The only thing I can
> think of is to pass the productId and other required parameters through the
> createSurveyResponseAndRestoreParameters or a  new service based on it as
> INOUT so they are available on the other side of the request, have yet to
> try this...
> But there must be a better way?
>
> On Wed, May 4, 2011 at 4:55 PM, Justin Robinson<justin@venturenet.co.za>wrote:
>
>> Brilliant thanks...for saving me some time... been reading the freemarker
>> manual&  looking at the the ofbiz freemarker framework all afternoon.
>> *That code was on OrderEvents but I moved it to a groovy script, were all
>> the parameters gotten from the request seem to be available anyway.*
>>
>>
>> On Wed, May 4, 2011 at 2:49 PM, Scott Gray<scott.gray@hotwaxmedia.com>
>> wrote:
>>> You need to put it in the screen context and not in the request
>> attributes, if you're using groovy then it's just:
>>> context.surveyWrapper = surveyWrapper
>>>
>>> Reason being that the request attributes (and session attributes and
>> parameters) have already been placed in the context at the start of the
>> screen rendering and your actions are occurring after that point.
>>> Regards
>>> Scott
>>>
>>> HotWax Media
>>> http://www.hotwaxmedia.com
>>>
>>> On 4/05/2011, at 9:55 PM, Justin Robinson wrote:
>>>
>>>> surveyWrapper?has_content always returns false no matter that the
>>>> debug shows that it's not null when it's set.
>>>> Have tried setting it as a session attribute, with no effect.
>>>> Am really stumped on this one no idea what to try....Any ideas?
>>>>
>>>>
>>>> the ftl:
>>>> <div class="screenlet">
>>>>     <div class="screenlet-body">
>>>>         <#-- Render the survey -->
>>>>         <#if surveyWrapper?has_content>
>>>>             <form method="post" enctype="multipart/form-data"
>>>> action="<@ofbizUrl>profilesurvey/profilesurvey</@ofbizUrl>"
>>>> style="margin: 0;">
>>>>               ${surveyWrapper.render()}
>>>>             </form>
>>>>         <#else>
>>>>             <h1>Survey Failed</h1>
>>>>             <p>surveyWrapper?has_content returned false</p>
>>>>         </#if>
>>>>     </div>
>>>> </div>
>>>>
>>>> code that sets the surveyWrapper:
>>>> // set up a surveyAction and surveyWrapper, then redirect to survey
>>>> ProductStoreSurveyWrapper wrapper = new
>>>> ProductStoreSurveyWrapper(surveys.get(0), cart.getOrderPartyId(),
>>>> UtilHttp.getParameterMap(request));
>>>> Debug.log("wrapper: "+(wrapper!=null? "not null":"null"), MODULE);
>>>> request.setAttribute("surveyWrapper", wrapper);
>>>> request.getSession().setAttribute("surveyWrapper", wrapper);
>>>> request.setAttribute("surveyAction", "addOrderItemSurvey")
>>>>
>>>> Regards,
>>>> Justin
>>>> Venture-Net Research&  Development
>>>
>>
>>
>> --
>> Regards,
>> Justin
>> Venture-Net Research&  Development
>>
>>
>>
>>
>>
>

Mime
View raw message