cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laurent Trillaud" <ltrill...@jouve.fr>
Subject RE: [xsp-session-fw] NPE when use getxml with empty tag
Date Thu, 18 Dec 2003 16:57:05 GMT
You're right I can see it.
We need a single line instruction. Something like that :
fnc().getFirstNode() == null ? "" : fnc().getFirstNode().getNodeValue()
But that not good because we compute fnc twice, so I put it in a variable
( node = fnc().getFirstNode()) != null ? "" : node.getNodeValue()

Therefore the full expression becomes:
<xsp:expr>(node = (DocumentFragment)(XSPSessionFwHelper.getXML(this.manager,
String.valueOf(<xsl:copy-of select="$context"/>),
String.valueOf(<xsl:copy-of select="$path"/>)))).getFirstChild()) != null ?
node.getNodeValue() : ""</xsp:expr>

This patch works for me. Hope for you.
Best Regards,
Laurent Trillaud

> -----Message d'origine-----
> De : Antonio Gallardo [mailto:agallardo@agsoftware.dnsalias.com]
> Envoyé : jeudi 18 décembre 2003 13:22
> À : users@cocoon.apache.org
> Objet : RE: [xsp-session-fw] NPE when use getxml with empty tag
> 
> Laurent Trillaud dijo:
> > Yes, I know but in this case, I need a string.
> > In fact the logicsheet is not safe enough because the java generated is
> > ((DocumentFragment) blahblah).getFirstChild().getNodeValue();
> > Laurent
> 
> I have the following problem with the solution you suggested. I use the
> getxml inside a <xsp:expr>:
> 
> <xsp:expr>Integer.parseInt(<xsp-session-fw:getxml context="authentication"
> path="/authentication/data/loc_id" as="string"/>)</xsp:expr>
> 
> This is translated to:
> 
> (Integer.parseInt(
>         	node =
> ((DocumentFragment)(XSPSessionFwHelper.getXML(this.manager,
>                 String.valueOf("authentication"),
> 
> String.valueOf("/authentication/data/loc_id")))).getFirstChild();
>         	node != null ? node.getNodeValue() : ""))
> 
> In this sample this is a bad compiled code, because we cannot use inside a
> function Integer.parseInt 2 instructions:
> 
> (DocumentFragment)(XSPSessionFwHelper.getXML(this.manager,
>                 String.valueOf("authentication"),
> 
> String.valueOf("/authentication/data/loc_id")))).getFirstChild();
> 
> and
> 
> node != null ? node.getNodeValue() : ""
> 
> What we can do?
> 
> Best Regards,
> 
> Antonio Gallardo
> 
> >
> >> -----Message d'origine-----
> >> De : Antonio Gallardo [mailto:agallardo@agsoftware.dnsalias.com]
> >> Envoyé : mardi 16 décembre 2003 14:06
> >> À : users@cocoon.apache.org
> >> Objet : Re: [xsp-session-fw] NPE when use getxml with empty tag
> >>
> >> Laurent Trillaud dijo:
> >> > Hi
> >> >>From the portal engine, for example, when I use <xsp-session-
> fw:getxml
> >> > as="string" context="authentication"
> >> path="/authentication/data/title"/>
> >> I
> >> > got an NPE if this tag is empty.
> >> > If I put something on it in the sunrise-user.xml from the portal
> >> sample,
> >> > it's working fine.
> >> > Any idea?
> >>
> >> Try:
> >>
> >> as="object"
> >>
> >> More info @ http://wiki.cocoondev.org/Wiki.jsp?page=XspSessionFw
> >>
> >> Best Regards,
> >>
> >> Antonio Gallardo
> >>
> >>
> >> ---------------------------------------------------------------------
> >> 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


Mime
View raw message