How to get session variable value in Java Method?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
su2
Reply | Threaded
Open this post in threaded view
|

How to get session variable value in Java Method?

su2
Hello Friends,

I was trying to retrieve the session value using following code in Java Method. But it gives me error -"session" can not be resolved.

-------------------------------------------------------------
String fromDate = session.getAttribute("fromDate");
-------------------------------------------------------------

Am I missing something?

Thank you for the help in advance.

Su-
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

Patrick Antivackis
May  be using this can help :
HttpSession session = ((HttpServletRequest) request).getSession();

2009/10/6 su2 <[hidden email]>

>
> Hello Friends,
>
> I was trying to retrieve the session value using following code in Java
> Method. But it gives me error -"session" can not be resolved.
>
> -------------------------------------------------------------
> String fromDate = session.getAttribute("fromDate");
> -------------------------------------------------------------
>
> Am I missing something?
>
> Thank you for the help in advance.
>
> Su-
>
> --
> View this message in context:
> http://www.nabble.com/How-to-get-session-variable-value-in-Java-Method--tp25774516p25774516.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
>
su2
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

su2
Hi Pattrick,

I tried your suggestion, and it gives error- "request" cannot be resolved.

I am not sure what I am missing.

Thank you.
Su-


Patrick Antivackis wrote
May  be using this can help :
HttpSession session = ((HttpServletRequest) request).getSession();

2009/10/6 su2 <shuchi@pexsupply.com>

>
> Hello Friends,
>
> I was trying to retrieve the session value using following code in Java
> Method. But it gives me error -"session" can not be resolved.
>
> -------------------------------------------------------------
> String fromDate = session.getAttribute("fromDate");
> -------------------------------------------------------------
>
> Am I missing something?
>
> Thank you for the help in advance.
>
> Su-
>
> --
> View this message in context:
> http://www.nabble.com/How-to-get-session-variable-value-in-Java-Method--tp25774516p25774516.html
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

Adrian Crum
In reply to this post by su2
You haven't provided enough information. Where in the program flow is
the Java method? What are you trying to retrieve? What are you trying to
achieve?

-Adrian

su2 wrote:

> Hello Friends,
>
> I was trying to retrieve the session value using following code in Java
> Method. But it gives me error -"session" can not be resolved.
>
> -------------------------------------------------------------
> String fromDate = session.getAttribute("fromDate");
> -------------------------------------------------------------
>
> Am I missing something?
>
> Thank you for the help in advance.
>
> Su-
>
su2
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

su2
Hi Adrian,

I have a screen which has bsh file in <actions> and FormWidget in <widgets> tag. I am capturing fromDate and thruDate in Session in .bsh file.

Now from FormWidget I am calling Java Methods for the data manipulation. For the data manipulation I need to have access to fromDate and thruDate selected by the user.

So here in Java method I am trying to access session variables.

I hope it helps in understanding my scenario.

Thank you.
Su-
Adrian Crum wrote
You haven't provided enough information. Where in the program flow is
the Java method? What are you trying to retrieve? What are you trying to
achieve?

-Adrian

su2 wrote:
> Hello Friends,
>
> I was trying to retrieve the session value using following code in Java
> Method. But it gives me error -"session" can not be resolved.
>
> -------------------------------------------------------------
> String fromDate = session.getAttribute("fromDate");
> -------------------------------------------------------------
>
> Am I missing something?
>
> Thank you for the help in advance.
>
> Su-
>
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

Adrian Crum
Why not keep that information in the context? Trying to access session
information in the presentation layer breaks the MVC boundaries.

-Adrian

su2 wrote:

> Hi Adrian,
>
> I have a screen which has bsh file in <actions> and FormWidget in <widgets>
> tag. I am capturing fromDate and thruDate in Session in .bsh file.
>
> Now from FormWidget I am calling Java Methods for the data manipulation. For
> the data manipulation I need to have access to fromDate and thruDate
> selected by the user.
>
> So here in Java method I am trying to access session variables.
>
> I hope it helps in understanding my scenario.
>
> Thank you.
> Su-
>
> Adrian Crum wrote:
>> You haven't provided enough information. Where in the program flow is
>> the Java method? What are you trying to retrieve? What are you trying to
>> achieve?
>>
>> -Adrian
>>
>> su2 wrote:
>>> Hello Friends,
>>>
>>> I was trying to retrieve the session value using following code in Java
>>> Method. But it gives me error -"session" can not be resolved.
>>>
>>> -------------------------------------------------------------
>>> String fromDate = session.getAttribute("fromDate");
>>> -------------------------------------------------------------
>>>
>>> Am I missing something?
>>>
>>> Thank you for the help in advance.
>>>
>>> Su-
>>>
>>
>
su2
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

su2
Sorry, I was not able to understand - keep the information in the context. Can you please explain in detail.

I really appreciate your help.

Thank you.
Su-

Adrian Crum wrote
Why not keep that information in the context? Trying to access session
information in the presentation layer breaks the MVC boundaries.

-Adrian

su2 wrote:
> Hi Adrian,
>
> I have a screen which has bsh file in <actions> and FormWidget in <widgets>
> tag. I am capturing fromDate and thruDate in Session in .bsh file.
>
> Now from FormWidget I am calling Java Methods for the data manipulation. For
> the data manipulation I need to have access to fromDate and thruDate
> selected by the user.
>
> So here in Java method I am trying to access session variables.
>
> I hope it helps in understanding my scenario.
>
> Thank you.
> Su-
>
> Adrian Crum wrote:
>> You haven't provided enough information. Where in the program flow is
>> the Java method? What are you trying to retrieve? What are you trying to
>> achieve?
>>
>> -Adrian
>>
>> su2 wrote:
>>> Hello Friends,
>>>
>>> I was trying to retrieve the session value using following code in Java
>>> Method. But it gives me error -"session" can not be resolved.
>>>
>>> -------------------------------------------------------------
>>> String fromDate = session.getAttribute("fromDate");
>>> -------------------------------------------------------------
>>>
>>> Am I missing something?
>>>
>>> Thank you for the help in advance.
>>>
>>> Su-
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

Adrian Crum
In the screen xml:

<actions>
   <set field="fromDate" from-field"parameters.fromDate"/>
   <set field="thruDate" from-field"parameters.thruDate"/>
</actions>

In the form xml:

<actions>
   <!-- Do something with fromDate and thruDate -->
   ...
</actions>

-Adrian

su2 wrote:

> Sorry, I was not able to understand - keep the information in the context.
> Can you please explain in detail.
>
> I really appreciate your help.
>
> Thank you.
> Su-
>
>
> Adrian Crum wrote:
>> Why not keep that information in the context? Trying to access session
>> information in the presentation layer breaks the MVC boundaries.
>>
>> -Adrian
>>
>> su2 wrote:
>>> Hi Adrian,
>>>
>>> I have a screen which has bsh file in <actions> and FormWidget in
>>> <widgets>
>>> tag. I am capturing fromDate and thruDate in Session in .bsh file.
>>>
>>> Now from FormWidget I am calling Java Methods for the data manipulation.
>>> For
>>> the data manipulation I need to have access to fromDate and thruDate
>>> selected by the user.
>>>
>>> So here in Java method I am trying to access session variables.
>>>
>>> I hope it helps in understanding my scenario.
>>>
>>> Thank you.
>>> Su-
>>>
>>> Adrian Crum wrote:
>>>> You haven't provided enough information. Where in the program flow is
>>>> the Java method? What are you trying to retrieve? What are you trying to
>>>> achieve?
>>>>
>>>> -Adrian
>>>>
>>>> su2 wrote:
>>>>> Hello Friends,
>>>>>
>>>>> I was trying to retrieve the session value using following code in Java
>>>>> Method. But it gives me error -"session" can not be resolved.
>>>>>
>>>>> -------------------------------------------------------------
>>>>> String fromDate = session.getAttribute("fromDate");
>>>>> -------------------------------------------------------------
>>>>>
>>>>> Am I missing something?
>>>>>
>>>>> Thank you for the help in advance.
>>>>>
>>>>> Su-
>>>>>
>>
>
su2
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

su2
Hi Adrian,

How can I access fromDate and thruDate in Form xml? I tried using fromDate but did not work.

Thanks for your help.
Su-


Adrian Crum wrote
In the screen xml:

<actions>
   <set field="fromDate" from-field"parameters.fromDate"/>
   <set field="thruDate" from-field"parameters.thruDate"/>
</actions>

In the form xml:

<actions>
   
   ...
</actions>

-Adrian

su2 wrote:
> Sorry, I was not able to understand - keep the information in the context.
> Can you please explain in detail.
>
> I really appreciate your help.
>
> Thank you.
> Su-
>
>
> Adrian Crum wrote:
>> Why not keep that information in the context? Trying to access session
>> information in the presentation layer breaks the MVC boundaries.
>>
>> -Adrian
>>
>> su2 wrote:
>>> Hi Adrian,
>>>
>>> I have a screen which has bsh file in <actions> and FormWidget in
>>> <widgets>
>>> tag. I am capturing fromDate and thruDate in Session in .bsh file.
>>>
>>> Now from FormWidget I am calling Java Methods for the data manipulation.
>>> For
>>> the data manipulation I need to have access to fromDate and thruDate
>>> selected by the user.
>>>
>>> So here in Java method I am trying to access session variables.
>>>
>>> I hope it helps in understanding my scenario.
>>>
>>> Thank you.
>>> Su-
>>>
>>> Adrian Crum wrote:
>>>> You haven't provided enough information. Where in the program flow is
>>>> the Java method? What are you trying to retrieve? What are you trying to
>>>> achieve?
>>>>
>>>> -Adrian
>>>>
>>>> su2 wrote:
>>>>> Hello Friends,
>>>>>
>>>>> I was trying to retrieve the session value using following code in Java
>>>>> Method. But it gives me error -"session" can not be resolved.
>>>>>
>>>>> -------------------------------------------------------------
>>>>> String fromDate = session.getAttribute("fromDate");
>>>>> -------------------------------------------------------------
>>>>>
>>>>> Am I missing something?
>>>>>
>>>>> Thank you for the help in advance.
>>>>>
>>>>> Su-
>>>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

Adrian Crum
You need to include some code. I can't answer if I don't know what
you're doing.

-Adrian

su2 wrote:

> Hi Adrian,
>
> How can I access fromDate and thruDate in Form xml? I tried using fromDate
> but did not work.
>
> Thanks for your help.
> Su-
>
>
>
> Adrian Crum wrote:
>> In the screen xml:
>>
>> <actions>
>>    <set field="fromDate" from-field"parameters.fromDate"/>
>>    <set field="thruDate" from-field"parameters.thruDate"/>
>> </actions>
>>
>> In the form xml:
>>
>> <actions>
>>    <!-- Do something with fromDate and thruDate -->
>>    ...
>> </actions>
>>
>> -Adrian
>>
>> su2 wrote:
>>> Sorry, I was not able to understand - keep the information in the
>>> context.
>>> Can you please explain in detail.
>>>
>>> I really appreciate your help.
>>>
>>> Thank you.
>>> Su-
>>>
>>>
>>> Adrian Crum wrote:
>>>> Why not keep that information in the context? Trying to access session
>>>> information in the presentation layer breaks the MVC boundaries.
>>>>
>>>> -Adrian
>>>>
>>>> su2 wrote:
>>>>> Hi Adrian,
>>>>>
>>>>> I have a screen which has bsh file in <actions> and FormWidget in
>>>>> <widgets>
>>>>> tag. I am capturing fromDate and thruDate in Session in .bsh file.
>>>>>
>>>>> Now from FormWidget I am calling Java Methods for the data
>>>>> manipulation.
>>>>> For
>>>>> the data manipulation I need to have access to fromDate and thruDate
>>>>> selected by the user.
>>>>>
>>>>> So here in Java method I am trying to access session variables.
>>>>>
>>>>> I hope it helps in understanding my scenario.
>>>>>
>>>>> Thank you.
>>>>> Su-
>>>>>
>>>>> Adrian Crum wrote:
>>>>>> You haven't provided enough information. Where in the program flow is
>>>>>> the Java method? What are you trying to retrieve? What are you trying
>>>>>> to
>>>>>> achieve?
>>>>>>
>>>>>> -Adrian
>>>>>>
>>>>>> su2 wrote:
>>>>>>> Hello Friends,
>>>>>>>
>>>>>>> I was trying to retrieve the session value using following code in
>>>>>>> Java
>>>>>>> Method. But it gives me error -"session" can not be resolved.
>>>>>>>
>>>>>>> -------------------------------------------------------------
>>>>>>> String fromDate = session.getAttribute("fromDate");
>>>>>>> -------------------------------------------------------------
>>>>>>>
>>>>>>> Am I missing something?
>>>>>>>
>>>>>>> Thank you for the help in advance.
>>>>>>>
>>>>>>> Su-
>>>>>>>
>>
>
su2
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

su2
I followed your suggestion and in screen I have following code.

 <actions>
    <set field="fromDate" from-field"parameters.fromDate"/>
    <set field="thruDate" from-field"parameters.thruDate"/>
 </actions>

Now I want to print the user selected fromDate and thruDate in my Form.

Thank you.
Su-

Adrian Crum wrote
You need to include some code. I can't answer if I don't know what
you're doing.

-Adrian

su2 wrote:
> Hi Adrian,
>
> How can I access fromDate and thruDate in Form xml? I tried using fromDate
> but did not work.
>
> Thanks for your help.
> Su-
>
>
>
> Adrian Crum wrote:
>> In the screen xml:
>>
>> <actions>
>>    <set field="fromDate" from-field"parameters.fromDate"/>
>>    <set field="thruDate" from-field"parameters.thruDate"/>
>> </actions>
>>
>> In the form xml:
>>
>> <actions>
>>    
>>    ...
>> </actions>
>>
>> -Adrian
>>
>> su2 wrote:
>>> Sorry, I was not able to understand - keep the information in the
>>> context.
>>> Can you please explain in detail.
>>>
>>> I really appreciate your help.
>>>
>>> Thank you.
>>> Su-
>>>
>>>
>>> Adrian Crum wrote:
>>>> Why not keep that information in the context? Trying to access session
>>>> information in the presentation layer breaks the MVC boundaries.
>>>>
>>>> -Adrian
>>>>
>>>> su2 wrote:
>>>>> Hi Adrian,
>>>>>
>>>>> I have a screen which has bsh file in <actions> and FormWidget in
>>>>> <widgets>
>>>>> tag. I am capturing fromDate and thruDate in Session in .bsh file.
>>>>>
>>>>> Now from FormWidget I am calling Java Methods for the data
>>>>> manipulation.
>>>>> For
>>>>> the data manipulation I need to have access to fromDate and thruDate
>>>>> selected by the user.
>>>>>
>>>>> So here in Java method I am trying to access session variables.
>>>>>
>>>>> I hope it helps in understanding my scenario.
>>>>>
>>>>> Thank you.
>>>>> Su-
>>>>>
>>>>> Adrian Crum wrote:
>>>>>> You haven't provided enough information. Where in the program flow is
>>>>>> the Java method? What are you trying to retrieve? What are you trying
>>>>>> to
>>>>>> achieve?
>>>>>>
>>>>>> -Adrian
>>>>>>
>>>>>> su2 wrote:
>>>>>>> Hello Friends,
>>>>>>>
>>>>>>> I was trying to retrieve the session value using following code in
>>>>>>> Java
>>>>>>> Method. But it gives me error -"session" can not be resolved.
>>>>>>>
>>>>>>> -------------------------------------------------------------
>>>>>>> String fromDate = session.getAttribute("fromDate");
>>>>>>> -------------------------------------------------------------
>>>>>>>
>>>>>>> Am I missing something?
>>>>>>>
>>>>>>> Thank you for the help in advance.
>>>>>>>
>>>>>>> Su-
>>>>>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

Adrian Crum
Use a display field.

-Adrian

su2 wrote:

> I followed your suggestion and in screen I have following code.
>
>  <actions>
>     <set field="fromDate" from-field"parameters.fromDate"/>
>     <set field="thruDate" from-field"parameters.thruDate"/>
>  </actions>
>
> Now I want to print the user selected fromDate and thruDate in my Form.
>
> Thank you.
> Su-
>
>
> Adrian Crum wrote:
>> You need to include some code. I can't answer if I don't know what
>> you're doing.
>>
>> -Adrian
>>
>> su2 wrote:
>>> Hi Adrian,
>>>
>>> How can I access fromDate and thruDate in Form xml? I tried using
>>> fromDate
>>> but did not work.
>>>
>>> Thanks for your help.
>>> Su-
>>>
>>>
>>>
>>> Adrian Crum wrote:
>>>> In the screen xml:
>>>>
>>>> <actions>
>>>>    <set field="fromDate" from-field"parameters.fromDate"/>
>>>>    <set field="thruDate" from-field"parameters.thruDate"/>
>>>> </actions>
>>>>
>>>> In the form xml:
>>>>
>>>> <actions>
>>>>    <!-- Do something with fromDate and thruDate -->
>>>>    ...
>>>> </actions>
>>>>
>>>> -Adrian
>>>>
>>>> su2 wrote:
>>>>> Sorry, I was not able to understand - keep the information in the
>>>>> context.
>>>>> Can you please explain in detail.
>>>>>
>>>>> I really appreciate your help.
>>>>>
>>>>> Thank you.
>>>>> Su-
>>>>>
>>>>>
>>>>> Adrian Crum wrote:
>>>>>> Why not keep that information in the context? Trying to access session
>>>>>> information in the presentation layer breaks the MVC boundaries.
>>>>>>
>>>>>> -Adrian
>>>>>>
>>>>>> su2 wrote:
>>>>>>> Hi Adrian,
>>>>>>>
>>>>>>> I have a screen which has bsh file in <actions> and FormWidget in
>>>>>>> <widgets>
>>>>>>> tag. I am capturing fromDate and thruDate in Session in .bsh file.
>>>>>>>
>>>>>>> Now from FormWidget I am calling Java Methods for the data
>>>>>>> manipulation.
>>>>>>> For
>>>>>>> the data manipulation I need to have access to fromDate and thruDate
>>>>>>> selected by the user.
>>>>>>>
>>>>>>> So here in Java method I am trying to access session variables.
>>>>>>>
>>>>>>> I hope it helps in understanding my scenario.
>>>>>>>
>>>>>>> Thank you.
>>>>>>> Su-
>>>>>>>
>>>>>>> Adrian Crum wrote:
>>>>>>>> You haven't provided enough information. Where in the program flow
>>>>>>>> is
>>>>>>>> the Java method? What are you trying to retrieve? What are you
>>>>>>>> trying
>>>>>>>> to
>>>>>>>> achieve?
>>>>>>>>
>>>>>>>> -Adrian
>>>>>>>>
>>>>>>>> su2 wrote:
>>>>>>>>> Hello Friends,
>>>>>>>>>
>>>>>>>>> I was trying to retrieve the session value using following code in
>>>>>>>>> Java
>>>>>>>>> Method. But it gives me error -"session" can not be resolved.
>>>>>>>>>
>>>>>>>>> -------------------------------------------------------------
>>>>>>>>> String fromDate = session.getAttribute("fromDate");
>>>>>>>>> -------------------------------------------------------------
>>>>>>>>>
>>>>>>>>> Am I missing something?
>>>>>>>>>
>>>>>>>>> Thank you for the help in advance.
>>>>>>>>>
>>>>>>>>> Su-
>>>>>>>>>
>>
>
su2
Reply | Threaded
Open this post in threaded view
|

Re: How to get session variable value in Java Method?

su2
I tried

      <field name="fromDate" title="date">
        <display description="${fromDate}"/>
        </field>

and

      <field name="fromDate" title="date">
        <display/>
        </field>

But neither of them worked.
Adrian Crum wrote
Use a display field.

-Adrian

su2 wrote:
> I followed your suggestion and in screen I have following code.
>
>  <actions>
>     <set field="fromDate" from-field"parameters.fromDate"/>
>     <set field="thruDate" from-field"parameters.thruDate"/>
>  </actions>
>
> Now I want to print the user selected fromDate and thruDate in my Form.
>
> Thank you.
> Su-
>
>
> Adrian Crum wrote:
>> You need to include some code. I can't answer if I don't know what
>> you're doing.
>>
>> -Adrian
>>
>> su2 wrote:
>>> Hi Adrian,
>>>
>>> How can I access fromDate and thruDate in Form xml? I tried using
>>> fromDate
>>> but did not work.
>>>
>>> Thanks for your help.
>>> Su-
>>>
>>>
>>>
>>> Adrian Crum wrote:
>>>> In the screen xml:
>>>>
>>>> <actions>
>>>>    <set field="fromDate" from-field"parameters.fromDate"/>
>>>>    <set field="thruDate" from-field"parameters.thruDate"/>
>>>> </actions>
>>>>
>>>> In the form xml:
>>>>
>>>> <actions>
>>>>    
>>>>    ...
>>>> </actions>
>>>>
>>>> -Adrian
>>>>
>>>> su2 wrote:
>>>>> Sorry, I was not able to understand - keep the information in the
>>>>> context.
>>>>> Can you please explain in detail.
>>>>>
>>>>> I really appreciate your help.
>>>>>
>>>>> Thank you.
>>>>> Su-
>>>>>
>>>>>
>>>>> Adrian Crum wrote:
>>>>>> Why not keep that information in the context? Trying to access session
>>>>>> information in the presentation layer breaks the MVC boundaries.
>>>>>>
>>>>>> -Adrian
>>>>>>
>>>>>> su2 wrote:
>>>>>>> Hi Adrian,
>>>>>>>
>>>>>>> I have a screen which has bsh file in <actions> and FormWidget in
>>>>>>> <widgets>
>>>>>>> tag. I am capturing fromDate and thruDate in Session in .bsh file.
>>>>>>>
>>>>>>> Now from FormWidget I am calling Java Methods for the data
>>>>>>> manipulation.
>>>>>>> For
>>>>>>> the data manipulation I need to have access to fromDate and thruDate
>>>>>>> selected by the user.
>>>>>>>
>>>>>>> So here in Java method I am trying to access session variables.
>>>>>>>
>>>>>>> I hope it helps in understanding my scenario.
>>>>>>>
>>>>>>> Thank you.
>>>>>>> Su-
>>>>>>>
>>>>>>> Adrian Crum wrote:
>>>>>>>> You haven't provided enough information. Where in the program flow
>>>>>>>> is
>>>>>>>> the Java method? What are you trying to retrieve? What are you
>>>>>>>> trying
>>>>>>>> to
>>>>>>>> achieve?
>>>>>>>>
>>>>>>>> -Adrian
>>>>>>>>
>>>>>>>> su2 wrote:
>>>>>>>>> Hello Friends,
>>>>>>>>>
>>>>>>>>> I was trying to retrieve the session value using following code in
>>>>>>>>> Java
>>>>>>>>> Method. But it gives me error -"session" can not be resolved.
>>>>>>>>>
>>>>>>>>> -------------------------------------------------------------
>>>>>>>>> String fromDate = session.getAttribute("fromDate");
>>>>>>>>> -------------------------------------------------------------
>>>>>>>>>
>>>>>>>>> Am I missing something?
>>>>>>>>>
>>>>>>>>> Thank you for the help in advance.
>>>>>>>>>
>>>>>>>>> Su-
>>>>>>>>>
>>
>