You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by asif_zzz <aa...@hotmail.com> on 2008/10/21 14:44:22 UTC
How to get the session attribute in bean
Hi,
im new to cocoon.
im using cocoon 2.1.10,spring ORM and hibernate.
im setting a session attribute in flowscript(flow.js)
cocoon.session.setAttribute("Instance",instance);
I need to get the above session attibute in bean.
Anyone please tell me how to get it??
Thanks in advance.
Regards,
Aashik
--
View this message in context: http://www.nabble.com/How-to-get-the-session-attribute-in-bean-tp20089416p20089416.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by Andre Juffer <an...@oulu.fi>.
asif_zzz wrote:
> Hi Andre,
>
> I found out how to get the session value in Custom Validator class or
> Custom-Dynamic SelectionList class
> But still i dont no how get the session value from a java class ,such that
> the java class does not have any of its references to form(Cforms).
>
Sorry, I cannot help you with this particular problem. I am not sure
whether I actually understand your question. The session object would
not have references to forms.
> I think it may work for ActionListener class as well.
>
> Its a temporary solution.
>
>
> <fd:field id="test">
> <fd:label><i18n:text>test</i18n:text></fd:label>
> <fd:datatype base="string"/>
> <fd:selection-list type="java" nullable="false"
> class="com.sample.TestSelectionList"/>
> </fd:field>
>
> Sample Code:
> ---------------
>
> public class TestSelectionList extends AbstractJavaSelectionList implements
> Contextualizable {
>
> ..
> @Override
> protected boolean build() throws Exception {
>
> ..
> Request request = ContextHelper.getRequest(this.context);
> String userId = "";
>
> if(request.getSession().getAttribute("userId") != null) {
> userId = request.getSession().getAttribute("userId").toString();
> }
>
> }
>
> public void contextualize(Context context) throws ContextException {
> this.context = context;
> }
> }
>
--
Andre H. Juffer | Phone: +358-8-553 1161
Biocenter Oulu and | Fax: +358-8-553-1141
Department of Biochemistry | Email: andre.juffer@oulu.fi
University of Oulu, Finland | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat | WWW: www.strubiocat.oulu.fi
NordProt | WWW: www.nordprot.org
Triacle Biocomputing | WWW: www.triacle-bc.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by asif_zzz <an...@meteximtechnologies.com>.
Hi Andre,
I found out how to get the session value in Custom Validator class or
Custom-Dynamic SelectionList class
But still i dont no how get the session value from a java class ,such that
the java class does not have any of its references to form(Cforms).
I think it may work for ActionListener class as well.
Its a temporary solution.
<fd:field id="test">
<fd:label><i18n:text>test</i18n:text></fd:label>
<fd:datatype base="string"/>
<fd:selection-list type="java" nullable="false"
class="com.sample.TestSelectionList"/>
</fd:field>
Sample Code:
---------------
public class TestSelectionList extends AbstractJavaSelectionList implements
Contextualizable {
..
@Override
protected boolean build() throws Exception {
..
Request request = ContextHelper.getRequest(this.context);
String userId = "";
if(request.getSession().getAttribute("userId") != null) {
userId = request.getSession().getAttribute("userId").toString();
}
}
public void contextualize(Context context) throws ContextException {
this.context = context;
}
}
--
View this message in context: http://www.nabble.com/How-to-get-the-session-attribute-in-bean-tp20089416p21825696.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by asif_zzz <as...@meteximtechnologies.com>.
Hi Andre ,
Ya i know that.
Just i tried form attribute for a testing purpose only.
My aim is to get the value from session.
I cant understand what Johannes trying to say.
But if we come to know,how to get (FOM) object ,then it is easier to get the
session object.
Rite??
Regards,
Aashik.
--
View this message in context: http://www.nabble.com/How-to-get-the-session-attribute-in-bean-tp20089416p20128513.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by Andre Juffer <an...@oulu.fi>.
I am now getting somewhat confused (as Johannes), as to what you intend
to accomplish. From you last email, I don't see anything like accessing
your session attribute in your Java class. You now accessing the form
widget, which is not the same as accessing the session object. You need
to get to the Session (HttpSession) first to access the requested
attribute, which is not what you do now.
asif_zzz wrote:
> Hi Andre,
>
> You are right.
>
> I can able to get the session object in flow.js
> like this
>
> cocoon.session.getAttribute("key");
>
> And i tried with form object,which i got in java bean class
>
> final Form form=event.getSourceWidget().getForm();
> String test=form.getAttribute("key").toString();
>
> What is the life time of this form attribute??
>
> Regards,
> Aashik.
>
--
Andre H. Juffer | Phone: +358-8-553 1161
The Biocenter and | Fax: +358-8-553-1141
the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland | WWW: www.biochem.oulu.fi/Biocomputing/
NordProt | WWW: www.nordprot.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by asif_zzz <as...@meteximtechnologies.com>.
Hi Andre,
You are right.
I can able to get the session object in flow.js
like this
cocoon.session.getAttribute("key");
And i tried with form object,which i got in java bean class
final Form form=event.getSourceWidget().getForm();
String test=form.getAttribute("key").toString();
What is the life time of this form attribute??
Regards,
Aashik.
--
View this message in context: http://www.nabble.com/How-to-get-the-session-attribute-in-bean-tp20089416p20128207.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by Andre Juffer <an...@oulu.fi>.
Johannes Hoechstaedter wrote:
> See here:
>
> http://cocoon.apache.org/2.1/userdocs/flow/api.html#session
I think what Aashik meant to ask is how to get to the session inside one
his own java classes (bean), like:
cocoon.session.setAttribute("key",data);
Some bean (SomeBean.java):
public class SomeBean {
...
public void someMethod(..)
{
Session session = .....
SomeObject someObject = (SomeObject)session.getAttribute("key");
doSomethingWithSomeObject();
}
}
I have been struggling with this as well (see previous posting under the
same topic).
Thanks,
Andre
>
> asif_zzz schrieb:
>> Hi Johannes,
>> Please dont mistake me if the query are basic
>>
>> I'm setting a String value in session attribute
>>
>> cocoon.session.setAttribute("key",data);
>> my scenario is get the above session value in bean class.how to get it??
>>
>> Regards,
>> Aashik
>>
>>
>> Johannes Hoechstaedter wrote:
>>
>>> Hi Aashik ,
>>>
>>> -reply to your mail from today.
>>>
>>> I have to confess, that I don't know exactly whats the difficulty is
>>> in your case. Maybe you can give more details?
>>>
>>> If you can get the request object you should be able to set and add
>>> attributes for your session (as you already do I think).
>>>
>>> cheers
>>> Johannes
>>>
>>> Johannes Hoechstaedter schrieb:
>>>
>>>> Maybe you will find it already posted in the mailing list. Search
>>>> here:
>>>> http://www.mail-archive.com/users@cocoon.apache.org/
>>>>
>>>> Maybe this article is helpful as well:
>>>> http://wiki.apache.org/cocoon/InputModules
>>>>
>>>> cheers,
>>>> Johannes
>>>>
>>>> asif_zzz schrieb:
>>>>
>>>>> Hi,
>>>>> im new to cocoon.
>>>>> im using cocoon 2.1.10,spring ORM and hibernate.
>>>>>
>>>>> im setting a session attribute in flowscript(flow.js)
>>>>>
>>>>> cocoon.session.setAttribute("Instance",instance);
>>>>>
>>>>>
>>>>> I need to get the above session attibute in bean.
>>>>> Anyone please tell me how to get it??
>>>>>
>>>>> Thanks in advance.
>>>>>
>>>>> Regards,
>>>>> Aashik
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>>
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
--
Andre H. Juffer | Phone: +358-8-553 1161
The Biocenter and | Fax: +358-8-553-1141
the Dep. of Biochemistry | Email: Andre.Juffer@oulu.fi
University of Oulu, Finland | WWW: www.biochem.oulu.fi/Biocomputing/
NordProt | WWW: www.nordprot.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by Johannes Hoechstaedter <j....@memocomp.de>.
See here:
http://cocoon.apache.org/2.1/userdocs/flow/api.html#session
asif_zzz schrieb:
> Hi Johannes,
> Please dont mistake me if the query are basic
>
> I'm setting a String value in session attribute
>
> cocoon.session.setAttribute("key",data);
>
> my scenario is get the above session value in bean class.how to get it??
>
> Regards,
> Aashik
>
>
> Johannes Hoechstaedter wrote:
>
>> Hi Aashik ,
>>
>> -reply to your mail from today.
>>
>> I have to confess, that I don't know exactly whats the difficulty is in
>> your case. Maybe you can give more details?
>>
>> If you can get the request object you should be able to set and add
>> attributes for your session (as you already do I think).
>>
>> cheers
>> Johannes
>>
>> Johannes Hoechstaedter schrieb:
>>
>>> Maybe you will find it already posted in the mailing list. Search here:
>>> http://www.mail-archive.com/users@cocoon.apache.org/
>>>
>>> Maybe this article is helpful as well:
>>> http://wiki.apache.org/cocoon/InputModules
>>>
>>> cheers,
>>> Johannes
>>>
>>> asif_zzz schrieb:
>>>
>>>> Hi,
>>>> im new to cocoon.
>>>> im using cocoon 2.1.10,spring ORM and hibernate.
>>>>
>>>> im setting a session attribute in flowscript(flow.js)
>>>>
>>>> cocoon.session.setAttribute("Instance",instance);
>>>>
>>>>
>>>> I need to get the above session attibute in bean.
>>>> Anyone please tell me how to get it??
>>>>
>>>> Thanks in advance.
>>>>
>>>> Regards,
>>>> Aashik
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>> For additional commands, e-mail: users-help@cocoon.apache.org
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by asif_zzz <as...@meteximtechnologies.com>.
Hi Johannes,
Please dont mistake me if the query are basic
I'm setting a String value in session attribute
cocoon.session.setAttribute("key",data);
my scenario is get the above session value in bean class.how to get it??
Regards,
Aashik
Johannes Hoechstaedter wrote:
>
> Hi Aashik ,
>
> -reply to your mail from today.
>
> I have to confess, that I don't know exactly whats the difficulty is in
> your case. Maybe you can give more details?
>
> If you can get the request object you should be able to set and add
> attributes for your session (as you already do I think).
>
> cheers
> Johannes
>
> Johannes Hoechstaedter schrieb:
>> Maybe you will find it already posted in the mailing list. Search here:
>> http://www.mail-archive.com/users@cocoon.apache.org/
>>
>> Maybe this article is helpful as well:
>> http://wiki.apache.org/cocoon/InputModules
>>
>> cheers,
>> Johannes
>>
>> asif_zzz schrieb:
>>> Hi,
>>> im new to cocoon.
>>> im using cocoon 2.1.10,spring ORM and hibernate.
>>>
>>> im setting a session attribute in flowscript(flow.js)
>>>
>>> cocoon.session.setAttribute("Instance",instance);
>>>
>>>
>>> I need to get the above session attibute in bean.
>>> Anyone please tell me how to get it??
>>>
>>> Thanks in advance.
>>>
>>> Regards,
>>> Aashik
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/How-to-get-the-session-attribute-in-bean-tp20089416p20124800.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by Johannes Hoechstaedter <j....@memocomp.de>.
Hi Aashik ,
-reply to your mail from today.
I have to confess, that I don't know exactly whats the difficulty is in
your case. Maybe you can give more details?
If you can get the request object you should be able to set and add
attributes for your session (as you already do I think).
cheers
Johannes
Johannes Hoechstaedter schrieb:
> Maybe you will find it already posted in the mailing list. Search here:
> http://www.mail-archive.com/users@cocoon.apache.org/
>
> Maybe this article is helpful as well:
> http://wiki.apache.org/cocoon/InputModules
>
> cheers,
> Johannes
>
> asif_zzz schrieb:
>> Hi,
>> im new to cocoon.
>> im using cocoon 2.1.10,spring ORM and hibernate.
>>
>> im setting a session attribute in flowscript(flow.js)
>>
>> cocoon.session.setAttribute("Instance",instance);
>>
>>
>> I need to get the above session attibute in bean.
>> Anyone please tell me how to get it??
>>
>> Thanks in advance.
>>
>> Regards,
>> Aashik
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
[ANN] VTD-XML extended edition released
Posted by jimmy Zhang <cr...@comcast.net>.
The Java version of extended VTD-XmL is released and available for download.
This version supports 256 GB max file sizes and memory mapped capabilities.
The updated documentation is also available for download. In short, you can
basically do full XPath query on documents that are bigger than memory space
available on your machine.
A special thanks to Duane May who provided value suggestions and inputs and
helped refine the VTD specs to make this happen.
To download the package and the documentation, go to
https://sourceforge.net/project/downloading.php?group_id=110612&use_mirror=&filename=vtd-xml_2.4_doc.zip&64621261
https://sourceforge.net/project/downloading.php?group_id=110612&use_mirror=&filename=ximpleware_extended_2.4.zip&99532507
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by Mark Lundquist <ml...@wrinkledog.com>.
Hi Andre,
On Oct 21, 2008, at 9:55 AM, Andre Juffer wrote:
> I would also be interested to understand how this would work with
> cocoon 2.2. The SessionModule, see http://cocoon.apache.org/2.2/core-modules/sitemap-components/1.0/apidocs/org/apache/cocoon/components/modules/input/SessionModule.html
> may be the answer.
meh... see below.
>
> My problem is the following. I need to evaluate whether or not a
> given user is allowed to access certain files or to perform certain
> tasks. With Spring's capabilities of AOP (Aspect Oriented
> Programming), it is very easy to define aspects, pointcuts, and
> joint points, currently defined on certain service classes in the
> domain. Typically, before a requested task is carried out (call to
> service class method), the system 'jumps' to a policy class to check
> whether or not the user is in fact allowed to perform the task. If
> so, the system continues with the requested task, otherwise for
> instance an exception is raised.
>
> The policy class implements a PolicyEvaluator interface (totally
> unaware of cocoon), which is the one that the AOP works with.
So far so good...
> I would now need an implementation of PolicyEvaluator that needs to
> identify the requesting user. So, this could possibly be
> accomplished with the SessionModule, like
>
> PolicyEvaluatorImpl extends SessionModule implements PolicyEvaluator {
>
> private UserRepository userRepository;
>
> PolicyEvaluatorImpl(UserRepository userRepository)
> {
> super();
> this.userRepository = userRepository;
> }
>
> // From PolicyEvaluator
> public boolean isAllowed(...)
> {
> // Get the requesting user.
> Long identifier = (Long) super.getAttribute("identifier");
> User user = this.userRepository.getUser(identifier);
>
> // Apply policies here.
> String reason = ....;
>
> if ( !notAllowed )
> throw new PolicyException(reason);
> return true;
> }
> }
>
> Would this actually work? Note that I use Spring for creating all
> objects, including the PolicyEvaluatorImpl. Spring, by default would
> instantiate this class as a singleton (which is fine with me), but I
> must be quite sure that the current Session is available to the
> implementing class.
No, it won't work... you can't just instantiate an InputModule like
that, and also the getAttribute() method takes other parameters
besides just the attribute name, which refer to Cocoon internal stuff.
But also, w.r.t. the whole idea... it's sort of like taking the whole
gorilla when all you want is the banana :-). The purpose of an
InputModule is to inject data into a sitemap pipeline, and
SessionModule has a bunch of apparatus (inherited from
AbstractJXPathInputModule) to implement that, and it would be weird to
create a class extending SessionModule for some other purpose, i.e. to
not use any of the intended purpose of SessionModule but just to use
it as a way to access the session object. Much better to figure out
how things in Cocoon access the session object and then do like they
do. Somebody here should be able to help you out with that...
> My current implementation include in their signature the User
> object. In some cases this is not convenient (also gives coupling
> between packages, which possibly could be avoided) and I am
> therefore looking for an alternative solution.
I don't what the signature thing is about, so I can't comment...
cheers,
—ml—
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by Andre Juffer <an...@oulu.fi>.
I would also be interested to understand how this would work with cocoon
2.2. The SessionModule, see
http://cocoon.apache.org/2.2/core-modules/sitemap-components/1.0/apidocs/org/apache/cocoon/components/modules/input/SessionModule.html
may be the answer.
My problem is the following. I need to evaluate whether or not a given
user is allowed to access certain files or to perform certain tasks.
With Spring's capabilities of AOP (Aspect Oriented Programming), it is
very easy to define aspects, pointcuts, and joint points, currently
defined on certain service classes in the domain. Typically, before a
requested task is carried out (call to service class method), the system
'jumps' to a policy class to check whether or not the user is in fact
allowed to perform the task. If so, the system continues with the
requested task, otherwise for instance an exception is raised.
The policy class implements a PolicyEvaluator interface (totally unaware
of cocoon), which is the one that the AOP works with.
I would now need an implementation of PolicyEvaluator that needs to
identify the requesting user. So, this could possibly be accomplished
with the SessionModule, like
PolicyEvaluatorImpl extends SessionModule implements PolicyEvaluator {
private UserRepository userRepository;
PolicyEvaluatorImpl(UserRepository userRepository)
{
super();
this.userRepository = userRepository;
}
// From PolicyEvaluator
public boolean isAllowed(...)
{
// Get the requesting user.
Long identifier = (Long) super.getAttribute("identifier");
User user = this.userRepository.getUser(identifier);
// Apply policies here.
String reason = ....;
if ( !notAllowed )
throw new PolicyException(reason);
return true;
}
}
Would this actually work? Note that I use Spring for creating all
objects, including the PolicyEvaluatorImpl. Spring, by default would
instantiate this class as a singleton (which is fine with me), but I
must be quite sure that the current Session is available to the
implementing class.
My current implementation include in their signature the User object. In
some cases this is not convenient (also gives coupling between packages,
which possibly could be avoided) and I am therefore looking for an
alternative solution.
Best regards,
Andre
Johannes Hoechstaedter wrote:
> Maybe you will find it already posted in the mailing list. Search here:
> http://www.mail-archive.com/users@cocoon.apache.org/
>
> Maybe this article is helpful as well:
> http://wiki.apache.org/cocoon/InputModules
>
> cheers,
> Johannes
>
> asif_zzz schrieb:
>> Hi,
>> im new to cocoon.
>> im using cocoon 2.1.10,spring ORM and hibernate.
>>
>> im setting a session attribute in flowscript(flow.js)
>>
>> cocoon.session.setAttribute("Instance",instance);
>>
>>
>> I need to get the above session attibute in bean.
>> Anyone please tell me how to get it??
>>
>> Thanks in advance.
>>
>> Regards,
>> Aashik
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: How to get the session attribute in bean
Posted by Johannes Hoechstaedter <j....@memocomp.de>.
Maybe you will find it already posted in the mailing list. Search here:
http://www.mail-archive.com/users@cocoon.apache.org/
Maybe this article is helpful as well:
http://wiki.apache.org/cocoon/InputModules
cheers,
Johannes
asif_zzz schrieb:
> Hi,
> im new to cocoon.
> im using cocoon 2.1.10,spring ORM and hibernate.
>
> im setting a session attribute in flowscript(flow.js)
>
> cocoon.session.setAttribute("Instance",instance);
>
>
> I need to get the above session attibute in bean.
> Anyone please tell me how to get it??
>
> Thanks in advance.
>
> Regards,
> Aashik
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org