cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Gallardo Rivera <agalla...@agsoftware.dnsalias.com>
Subject Re: <xsp-session:getxml>
Date Fri, 27 Sep 2002 00:43:22 GMT
Please check this function I included into XSPSessionHelper.java in 
src/java/org/apache/cocoon/components/language/markup/xsp:

    /** GetXML Fragment from the given session context and path
      *
      *
     * @param session The Session object
     * @param context The Session context tha define where to search
     * @param path The parameter path
     * @param defaultValue Value to substitute in absence of the required 
Fragment
     **/
     public static DocumentFragment getXML(ComponentManager cm, String 
context, String path) throws ProcessingException {

         DocumentFragment df = null;
         SessionManager sm = null;

         try {
             // Start looking up the manager
             sm = (SessionManager)cm.lookup(SessionManager.ROLE);
             // Make our work
             df = sm.getContextFragment(context, path);
             if (sm != null) {
                 cm.release(sm);
             }
         } catch (ComponentException ce) {
                throw new ProcessingException("Error during lookup of 
SessionManager component.", ce);
         }
         // End releasing the sessionmanager
        return df;
     }

Soon I will publish here too the changes in the xsp-session.xsl

I takes me 3 days!

Antonio Gallardo.


El Jueves, 26 de Septiembre de 2002 03:50, Antonio Gallardo Rivera escribió:
> I will try to explain how far I am now in the building of the
> <xsp-session:getxml> for XSP.
>
> As I said I was researching about that, now I can get the values of the
> "authentication" context.
>
> In XSP we can use:
> Namespace: xmlns:xsp-session="http://apache.org/xsp/session/2.0"
>
> 2-Add imports:
> <xsp:include>org.apache.cocoon.webapps.session.context.SimpleSessionContext
></xsp:include> <xsp:include>org.w3c.dom.DocumentFragment</xsp:include>
> <xsp:include>org.apache.cocoon.xml.dom.DOMUtil</xsp:include>
>
> 3- Logic inside the xsp:page:
>
> <xsp:logic>
> SimpleSessionContext a =
> ((SimpleSessionContext)<xsp:expr><xsp-session:get-attribute
> name="org.apache.cocoon.webapps.authentication.SessionContext"/></xsp:expr>
>); DocumentFragment b = a.getXML("/");
> String d = DOMUtil.createText(b);
> </xsp:logic>
>
> Only for test I used, and it gets the values I need.
>
> <xsp:expr>b</xsp:expr>
>
> After it returns I saw in the generated HTML that there is only one
> context.
>
> <myhandler>
> <authentication>
> <ID>1</ID>
> <role>myrole</role>
> <data>
> 	<username>My name</username>
> 	<birthday></birthday>
> 	.....
> </data>
> </authentication>
> </myhandler>
>
> I am also researching about how to get the authentication context because
> there are two attributes and the name of the handler can be diferent as
> long as I know. Then:
>
> A) adding imports
> <xsp:include>java.util.ArrayList</xsp:include>
> <xsp:include>java.util.HashMap</xsp:include>
>
> B) <xsp:logic>
>
> ArrayList al =
> ((ArrayList)<xsp:expr><xsp-session:get-attribute-names/></xsp:expr>);
>
> String al0 = ((String)al.get(0));
> String al1 = ((String)al.get(1));oot node, does anyone know how
> HashMap hs = ((HashMap)<xsp:expr><xsp-session:get-attribute
> name="org.apache.cocoon.webapps.authentication.Handlers"/></xsp:expr>);
>
> With al. I can make use of the attributesnames of the session, after that I
> can get the names using the variables al0 and al1.
>
> al0 is org.apache.cocoon.webapps.authentication.Handlers
> and
> al1 is org.apache.cocoon.webapps.authentication.SessionContext
>
> About al1 is above a litlle explain that can helps to get directly the
> authentication ID using the Strings:
>
> <xsp:logic>
> SimpleSessionContext a =
> ((SimpleSessionContext)<xsp:expr><xsp-session:get-attribute
> name="org.apache.cocoon.webapps.authentication.SessionContext"/></xsp:expr>
>); DocumentFragment b = a.getXML("/myhandler/authentication/ID");
> </xsp:logic>
>
> After this, the variable b has the value of "/authentication/ID".
>
> About al0 (org.apache.cocoon.webapps.authentication.Handlers) it is a
> ArrayList that contains the names of the attributes.
>
> Some examples using
>
> <p>Key: <xsp:expr>hs.keySet()</xsp:expr></p>
> <p>Value: <xsp:expr>hs.values()</xsp:expr></p>
> <p>Attribute: <xsp:expr>hs.values()</xsp:expr></p>
>
> But I cannot take the Session Context. I was thinking in a get how to get
> away the context and just write a tag like:
>
> <xsp-session:getxml path="/myhandler/authentication"/>
>
> Another question: Can we add this new function to the already xsp-session
> logicsheet?
>
> Comments are welcome :)
>
> Antonio Gallardo
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.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