I think you can try to typecast the session object when you get it from the
context map in your service. If still you didn't get any success with that
then I think the best and most preferable approach would be to simply right
a Java Event as you mentioned in your last mail, like as public static
String mymethod(HttpServletRequest request, HttpServletResponse response).
Generally in a case where we need to access and work on request and session
objects, I think the preferred approach is to write a Java or Simple event.
I would have personally preferred that :).
On Thu, Mar 27, 2008 at 12:19 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> mridul
>
> I tried this and got this exception:
>
> Type conversion of field [session] to type [javax.servlet.http.HttpSession
> ]
> failed for value "[EMAIL PROTECTED]
> ":
> org.ofbiz.base.util.GeneralException: Conversion from String to
> javax.servlet.http.HttpSession not currently supported
>
>
> The ftl file looks like this:
>
> <#assign session = request.getSession()>
> <input type="hidden" name="session" value="${session}"/>
>
> The servicedef looks like this:
>
> ....
> <attribute name="session" type="javax.servlet.http.HttpSession"
> mode="IN" optional="true"/>
> </service>
>
> This would really be nice to get right to avoid using the alternative
> public static String mymethod(HttpServletRequest request,
> HttpServletResponse response)
>
>
> I looked in ObjectType.java file and the only supported conversions are
> for
> simple types like Double, Integer, etc.
>
> Note that the url parameter is passed as
> [EMAIL PROTECTED]
>
> Hopefully, there is something I am missing.
>
> Skip
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
> Mridul Pathak
> Sent: Monday, March 24, 2008 9:14 PM
> To: [email protected]
> Subject: Re: How to use event to send session parameter
>
>
> Nattanicha,
> You have just added the session object as an IN parameter in your
> service. You will also need to pass the session object to the service. I
> mean to say that wherever you are preparing the input map for this
> service/request, may be from some form or some other event, you will get
> the
> session object there and pass it to the service in the input map.
> e.g. If you are using an ftl, you can write following code in your form:
> <#assign session = request.getSession()>
> <input type="hidden" name="session" value="${session}"/>
> I think this way you can get the session object in your service.
> If you are using form-widgets than you may use bsh to get the session
> object
> from request.
>
> On Mon, Mar 24, 2008 at 6:47 PM, Nattanicha Rittammanart
> <[EMAIL PROTECTED]>
> wrote:
>
> > Dear Miridul,
> > I use Service engine and I tried follows your suggestion. But I got
> > problem like this:
> >
> > 2008-03-24 20:03:16,468 (http-0.0.0.0-8080-Processor3) [
> > AssetServices.java:37 :INFO ] session : null
> >
> > but in log file I can see:
> >
> > 2008-03-24 20:03:16,437 (http-0.0.0.0-8080-Processor3) [
> > RequestHandler.java:245:INFO ] [Processing Request]:
> > createAssetPrototype sessionId=C24B7F75CEE3F8413665F3D314BAFE98.jvm1
> >
> > This line is print from RequestHandler.java. How can I get this
> > sessionId in createAssetPrototype
> > *
> > My code*
> > sevicedef.xml
> > <service engine="java" name="createAssetPrototype"
> > location="org.ofbiz.prototype.AssetServices"
> > invoke="createAssetPrototype">
> > <description>create asset</description>
> > <auto-attributes mode="IN" entity-name="SimpleAcc" include="nonpk"
> > optional="true"></auto-attributes>
> > <attribute type="String" mode="OUT" name="accid"
> > optional="false"></attribute>
> > <attribute mode="IN" name="session" optional="true"
> > type="javax.servlet.http.HttpSession"/>
> > </service>
> > *
> > Java code*
> > AssetServices.java
> > public static Map createAssetPrototype(DispatchContext dctx, Map
> > context)throws IOException{
> > ....
> > HttpSession session = (HttpSession)context.get("session");
> > Debug.logInfo("session Kae: "+session, module);
> > .....
> > }
> >
> > Please help me,
> > Nattanicha
> >
> > Mridul Pathak wrote:
> > > There can be two cases:
> > > 1) In the request-map you are using Java Engine. In this case of a
> Java
> > > Event you can get the session object from a request object available
> to
> > you
> > > in the event by useing *getSession()* method on request object. Now
> you
> > can
> > > get all your required session infromation from the session object.
> > > There are lots of examples that you can find in OFBiz for this
> > approach.
> > >
> > > 2) In the request-map you are using Service engine, and in the service
> > > definition you are using engine type of Java. In this case session
> > object
> > > is not available to you, but it can be made availabel by adding an IN
> > > attribute to your service definition in the following way: <attribute
> > > mode="IN" name="session" optional="true" type="
> > > javax.servlet.http.HttpSession"/>.
> > > Now you can get this session object in your Java Service from the
> > > context map in the following way:
> > > HttpSession session = (HttpSession)context.get("session");
> > >
> > > I think this way you can access the session information.
> > >
> > >
> > > On Sat, Mar 22, 2008 at 7:03 AM, Nattanicha Rittammanart <
> > [EMAIL PROTECTED]>
> > > wrote:
> > >
> > >
> > >> Dear all,
> > >> I need to work with session information. I knew that we can send
> > >> session information to Java engine by using event. Anyway, I don't
> know
> > >> how to do this. Who used to do this please tell me or tell me where I
> > >> can read this is also OK. Thanks in advance.
> > >>
> > >> Nattanicha
> > >>
> > >>
> > >
> > >
> > >
> > >
> >
> >
>
>
> --
> Thanks & Regards
> Mridul Pathak
> Hotwax Media
> http://www.hotwaxmedia.com
> [EMAIL PROTECTED]
> __________________________________
> Office : 509.855.4113
> Mobile : +919425926892
>
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.519 / Virus Database: 269.21.8/1339 - Release Date: 3/22/2008
> 4:43 PM
>
> No virus found in this outgoing message.
> Checked by AVG.
> Version: 7.5.519 / Virus Database: 269.21.8/1339 - Release Date: 3/22/2008
> 4:43 PM
>
>
--
Thanks & Regards
Mridul Pathak
Hotwax Media
http://www.hotwaxmedia.com
[EMAIL PROTECTED]
__________________________________
Office : 509.855.4113
Mobile : +919425926892