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 <an...@meteximtechnologies.com> on 2009/02/04 08:31:45 UTC

Re: How to get the session attribute in bean

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 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