[opencms-dev] OpenCmsDate - problems reusing taglib tags
Ruben Malchow
ruben at disk0.de
Mon Oct 26 05:08:58 CET 2009
hi mathias,
thanks for the quick reply ... actually, there is no a lot of
sourceode, but what little there is:
the template looks like this:
<cms:contentload
collector="singleFile"
param="${file}"
editable="true">
<c:set var="date"><cms:contentshow element="date_reference"/></c:set>
<!-- try to format the date -->
<c:catch var="ex">
<c:set var="date">
<d:formatTimestamp
pattern="yyyy-MM-dd"
value="${date}"
/>
</c:set>
</c:catch>
${date}
<c:if test = "${ex!=null}">
<!--
${ex}
${ex.message}
-->
</c:if>
[...]
</contentload>
the schema is like this:
[...]
<xsd:element
maxOccurs="1"
minOccurs="1"
name="date_reference"
type="OpenCmsString" />
[...]
[...]
<mapping
element="date_reference"
mapto="attribute:datereleased" />
[...]
and the tag used basically does this:
public int doEndTag() throws JspException {
try {
long l = Long.parseLong(value);
SimpleDateFormat sdf =
new SimpleDateFormat(pattern);
pageContext.getOut().print(
sdf.format(new Date(l)));
} catch (Exception e) {
e.printStackTrace();
}
return super.doEndTag();
}
so ... the problem is that after the template is called once with a
undefined date_reference field, the date/time widget in the backend will
not work anymore ... instead, the editor will display a simple text field.
.rm
Mathias Lin | SYSVISION wrote:
> Hi Ruben,
> you should post the source code / jsp code directly, otherwise it's hard to
> help.
> Regards, Mathias
>
>
> Ruben Malchow-3 wrote:
>>
>>
>> hello list.
>>
>> i am running into a somewhat strange problem. ocms is 7.0.5.
>>
>> i have a field in a schema that is a date. i also have a template that
>> displays this date as part of the headline of an article. to format
>> this, i have a little jsp tag that takes a pattern and a long value and
>> formats tries to format the value according to the pattern. in my
>> template, this tag is surrounded by a jstl try/catch thing (so if it
>> doesn't work, the result is just an empty string).
>>
>> now what happens is this: if i call the template with a cotent xml which
>> doesn't have the date set yet, it displays as expected, so instead of
>> the date, there is an empty string. BUT: it also breaks the editor.
>> meaning that when i go back to set the date, the datetime widget is
>> gone. until i restart the tomcat.
>>
>> any ideas? i have no idea where to start looking ... my tag doesn't even
>> use any ocms classes, it just instantiates a SimpleDateFormat.
>>
>> .rm
>>
>
>
> -----
> Mathias Lin
> SYSVISION Ltd., China
> http://www.sysvision.com
More information about the opencms-dev
mailing list