[opencms-dev] Check if element exists
Yves Glodt
yg at mind.lu
Tue Mar 29 22:40:50 CEST 2011
Here is the controlcode:
<?xml version="1.0" encoding="UTF-8"?>
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.opencms.org/dtd/6.0/xmlpage.xsd">
<page language="en">
<element name="lcontent">
<links/>
<content/>
</element>
<element name="mcontent">
<links/>
<content/>
</element>
<element name="rcontent">
<links />
<content />
</element>
</page>
</pages>
On 29 March 2011 17:48, Mario Jäger <m.jaeger at alkacon.com> wrote:
>
> Hi Yves,
>
> Please, show me the control code of your "page with free text". The
> structure is important for me, not the content of the elements. Shall
> mean, that you can remove the content of the elements, of course.
>
> Kind Regards,
> Mario.
>
> Am 29.03.2011 16:45, schrieb Yves Glodt:
> > Hi Mario,
> >
> > in fact the element exists in the page, so yes, I wonder why isEmpty
> > returns "true".
> >
> > And I also wonder why the 2 other calls return false... :-)
> >
> > Is there another way to check whether an element exists in a page?
> >
> > The example here does also not work as I expect:
> >
http://opencms-wiki.org/EL_functions_provided_by_OpenCMS_taglib#XML_content
> >
> > Maybe I expect something impossible. As said, my page is a simple "page
> > with free text"
> >
> >
> > On 29 March 2011 16:13, Mario Jäger <m.jaeger at alkacon.com
> > <mailto:m.jaeger at alkacon.com>> wrote:
> >
> > Hi Yves,
> >
> > I assume, that you are wondering over the (second) return value
"true",
> > because the element does not exist in your xml content. With the
three
> > function calls you use, methods in
> > org.opencms.jsp.util.CmsJspContentAccessValueWrapper.java are used.
The
> > second call uses the method getIsEmpty() in that class. And that
method
> > also returns true for non existing values. The description for that
> > method says: Returns true in case the value is empty, that is either
> > null or an empty String.
> >
> > Kind Regards,
> > Mario.
> >
> > Am 29.03.2011 14:58, schrieb Yves Glodt:
> > > Hello,
> > >
> > > I try to check if an element exists in a "page with free text",
> > and if
> > > yes, include it.
> > >
> > > The check I do like this (in a c:if), but these 3 calls return
> > "false,
> > > true, false" (in order of appearance)
> > >
> >
${cms:vfs(pageContext).xml[cms:vfs(pageContext).context.uri].hasValue['rcontent']}
> > >
> >
${cms:vfs(pageContext).xml[cms:vfs(pageContext).context.uri].value['rcontent'].isEmpty}
> > >
> >
${cms:vfs(pageContext).xml[cms:vfs(pageContext).context.uri].value['rcontent'].exists}
> > >
> > > What is wrong about this?
> > >
> > > Best regards,
> > > Yves
> > >
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > This mail is sent to you from the opencms-dev mailing list
> > > To change your list options, or to unsubscribe from the list,
> > please visit
> > > http://lists.opencms.org/mailman/listinfo/opencms-dev
> >
> >
> > --
> > -------------------
> > Mario Jäger
> >
> > Visit OpenCms Days 2011 Conference and Expo
> > May 9 to May 10 2011 in Cologne, Germany
> > http://www.opencms-days.org
> >
> > Alkacon Software GmbH - The OpenCms Experts
> > http://www.alkacon.com - http://www.opencms.org
> >
> >
> >
> >
> >
> > _______________________________________________
> > This mail is sent to you from the opencms-dev mailing list
> > To change your list options, or to unsubscribe from the list, please
visit
> > http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
> --
> -------------------
> Mario Jäger
>
> Visit OpenCms Days 2011 Conference and Expo
> May 9 to May 10 2011 in Cologne, Germany
> http://www.opencms-days.org
>
> Alkacon Software GmbH - The OpenCms Experts
> http://www.alkacon.com - http://www.opencms.org
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20110329/30568406/attachment.htm>
More information about the opencms-dev
mailing list