|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
OpenCmsDate - problems reusing taglib tagshello 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 _______________________________________________ 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 |
|
|
Re: OpenCmsDate - problems reusing taglib tagsHi Ruben,
you should post the source code / jsp code directly, otherwise it's hard to help. Regards, Mathias
|
|
|
Re: OpenCmsDate - problems reusing taglib tagshi 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 _______________________________________________ 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 |
|
|
Re: OpenCmsDate - problems reusing taglib tagsNot looking at the code/issue directly (and why the editor breaks), the approach looks little complicate. You don't need to write your own taglib in order to format a timestamp.
You can just use the one below - never had any problems with that: <%@ taglib prefix="dt" uri="http://jakarta.apache.org/taglibs/datetime-1.0" %> <cms:contentcheck ifexists="date_reference"> <dt:format pattern="MM.yyyy"><cms:contentshow element="date_reference" /></dt:format> </cms:contentcheck>
|
| Free embeddable forum powered by Nabble | Forum Help |