cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vadim Gritsenko" <vadim.gritse...@verizon.net>
Subject RE: xsp-session:get-attribute not returning a String?
Date Thu, 02 May 2002 23:52:24 GMT
> From: Zack Angelo [mailto:zack@nostromocorp.com]
> 
> Hey,
> 
> I have a statement along the lines of this in my XSP doc:
> 
> String test = <xsp-session:get-attribute name="mySessionAttr"/>;
> 
> However, it won't work (I get an incompatible types compiler error)
> unless I cast it as a String. Consequently, I think it's returning an
> invalid value.  The same circumstances apply when I use
> session.getAttribute() as well. Any ideas? Thanks in advance.

See
http://xml.apache.org/cocoon/apidocs/org/apache/cocoon/environment/Reque
st.html#getAttribute(java.lang.String):

public java.lang.Object getAttribute(java.lang.String name)


http://xml.apache.org/cocoon/apidocs/org/apache/cocoon/environment/Sessi
on.html#getAttribute(java.lang.String):

public java.lang.Object getAttribute(java.lang.String name)


Which means that attributes are *objects*, not strings, and compiler is
right. However, xsp-request logicsheet provides you with conversion
abilities:

<xsp:logic>
String s = <xsp-request:get-attribute name="name" as="string"/>;
Object o = <xsp-request:get-attribute name="name" as="object"/>;
</xsp:logic>
<!--
  Generates XML tag
  <xsp-request:attribute>attr value here</xsp-request:attribute>
-->
<xsp-request:get-attribute name="name" as="xml"/>


Same holds true for session attributes.

Vadim

> -Zack



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message