You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Hari Plaikoil <ha...@gmail.com> on 2008/12/03 06:46:42 UTC

getParameter has the data, but why getAttribute is null when catch in java's event?

I tried using getParameter and getAttribute for both of the parameters.
First, in .ftl I set like this :

      <#assign jrP = requestAttributes.jrParameters>
      <@inputHidden name="jrPr" value=jrP/>
      <#assign jrD = requestAttributes.jrDataSource>
      <@inputHidden name="jrDt" value=jrD/>

and then I called java event through controller, and I caught both of the
parameter like this :

        Map<String, Object> jPrm = (Map)request.getAttribute("jrPr");
        JRDataSource jrDataSource = (JRDataSource)
request.getAttribute("jrDt");
        
        Debug.logInfo("jPrm = "+jPrm, module); //gives null value
        Debug.logInfo("jrDataSource = "+jrDataSource, module); // gives null
value

        Debug.logInfo("jPrm = "+request.getParameter("jrPr"), module); //
gives the data
        Debug.logInfo("jrDataSource = "+request.getParameter("jrDt"),
module); // gives the data


Does anyone wanna help me to solve this problem?

Thanks

Hari Plaikoil wrote:
> 
> Thanks Scott for your advice. 
> 
> But, I think when I use request.getParameter it will give a String value.
> I don't want a String, I want a Map  and a JRDataSource :-D
> 
> my jrParameters is Map's type, Map<String, Object> type.
> 
> I tried request.getParameter("jrParameters"), it was really impossible :
> 
>  Map<String, Object> jrParameters = request.getParameter("jrParameters");
> <--- cannot convert from String to Map :-D
> 
> I really totally confuse with all this code :-((
> 
> 
> Scott Gray wrote:
>> 
>> Ah ok, so you mean that you have a form generated from an ftl and when
>> that
>> form is submitted you can't get the parameters using request.getAttribute
>> ("jrParameters")?  Try using request.getParameter("jrParameters").
>> Usually when people talk about trying to do things from ftl they are
>> talking
>> about while rendering the template.
>> 
>> Regards
>> Scott
>> 
>> 2008/12/3 Hari Plaikoil <ha...@gmail.com>
>> 
>>>
>>> I need to go to .ftl after visit the .bsh because I have to choose an
>>> printer
>>> name, report type for my other parameters for the java's event. and the
>>> choices are in .ftl (drop-down) :-D
>>>
>>> you can say I take a long path just to make a pdf's report :-D frankly,
>>> I
>>> don't know how to explain that.
>>>
>>> So, would you like to help me how to pass the parameters (Map's type &
>>> JRDataSource's type) from .ftl to java's event?
>>>
>>> Anyway, I write piece of code on java's event to catch the parameters
>>> like
>>> this :
>>>
>>>        Map<String, Object> jPrm =
>>> (Map)request.getAttribute("jrParameters");
>>>         JRDataSource jrDataSource = (JRDataSource)
>>> request.getAttribute("jrDataSource");
>>>
>>>     but, the variables give me null value :-((
>>>
>>>
>>>
>>> Scott Gray wrote:
>>> >
>>> > Why are you waiting until you get to the template?  Wouldn't it be
>>> easier
>>> > to
>>> > call the method from the bsh script?
>>> > Regards
>>> > Scott
>>> >
>>> > 2008/12/3 Hari Plaikoil <ha...@gmail.com>
>>> >
>>> >>
>>> >> I followed your instruction. First, I've got the jrParameters (Map's
>>> >> type)
>>> >> and jrDataSource (JRDataSource's type) as output parameters from java
>>> >> service. Second, I catch the parameters on .bsh file, I put the
>>> >> parameters
>>> >> on context than I pass to .ftl
>>> >> Third, on .ftl, I've checked both of the parameters, they have the
>>> same
>>> >> data
>>> >> like in .bsh file.
>>> >> Fourth, I called java's event from .ftl through controller. On the
>>> java's
>>> >> event I realized the value of jrParameters and jrDataSource are null.
>>> >>
>>> >> I really don't have any idea how to set  fields or parameters for
>>> both
>>> of
>>> >> them on .ftl so when I catch on java's event the value will not null.
>>> I
>>> >> tried on .ftl assign the parameters like the code below:
>>> >>
>>> >>  <@inputHidden name="jrParameters" value="${jrParameters}"/>
>>> >>  <@inputHidden name="jrDataSource" value="${jrDataSource}"/>
>>> >>
>>> >>  the code causes error exception, so I changed to :
>>> >>
>>> >>  <#assign jrParameters = "${jrParameters}">
>>> >>  <#assign jrDataSource = "${jrDataSource}">
>>> >>
>>> >>  again, it causes an error exception too :-((
>>> >>
>>> >>  Please, help me out....
>>> >>
>>> >>  Thanks.
>>> >>
>>> >>
>>> >> BJ Freeman wrote:
>>> >> >
>>> >> > in ofbiz you pass the ftl thru the controller to a request-map
>>> >> > if you need to process the data then you can all a service or
>>> event.
>>> >> > if you use a service then the data is availible as a context.
>>> >> > if you use an event it is availible thru the httprequest.
>>> >> > otherwise you can direct to another page through a view that would
>>> be
>>> >> > your report.
>>> >> > if your using widgets you can process data in the action section
>>> then
>>> >> > define the ftl that will show the report.
>>> >> >
>>> >> > ofbiz takes care of passing the information.
>>> >> >
>>> >> > review
>>> >> >
>>> >>
>>> http://docs.ofbiz.org/display/OFBIZ/OFBiz+Beginner%27s+Development+Guide+Using+Practice+Application
>>> >> .
>>> >> >
>>> >> >
>>> >> >
>>> >> > Hari Plaikoil sent the following on 12/2/2008 3:15 AM:
>>> >> >> Dear all,
>>> >> >>
>>> >> >> Could you tell me how to pass a Map's parameter from ftl to java?
>>> >> >>
>>> >> >> When in ftl, the parameter has data. But when I call it in java's
>>> >> method
>>> >> >> by
>>> >> >> this code below, I got null value:
>>> >> >>
>>> >> >>  Map<String, Object> jPrm = (Map<String,
>>> >> >> Object>)request.getAttribute("jrParameters");
>>> >> >>  JRDataSource jrDataSource = (JRDataSource)
>>> >> >> request.getAttribute("jrDataSource");
>>> >> >>
>>> >> >>  In this case, I want to pass jrParameter and jrDatasource to make
>>> a
>>> >> >> report.
>>> >> >>
>>> >> >> Please, help me...
>>> >> >>
>>> >> >> Thanks.
>>> >> >
>>> >> >
>>> >>
>>> >> --
>>> >> View this message in context:
>>> >>
>>> http://www.nabble.com/passing-map-parameter-from-ftl-to-event-type-java-tp20790183p20805691.html
>>> >> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>> >>
>>> >>
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/passing-map-parameter-from-ftl-to-event-type-java-tp20790183p20805941.html
>>> Sent from the OFBiz - User mailing list archive at Nabble.com.
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/passing-map-parameter-from-ftl-to-event-type-java-tp20790183p20807225.html
Sent from the OFBiz - User mailing list archive at Nabble.com.