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