[opencms-dev] Check if element exists

Mario Jäger m.jaeger at alkacon.com
Tue Mar 29 16:13:01 CEST 2011


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



More information about the opencms-dev mailing list