I noticed an issue with the formatDate tag.
It displays current date when the date passed is a null object when used in the gsp page. The default date is rendered along with timestamp when the gsp pages are generated using grails commands generate-views or generate-all for a domain class. The views (list.jsp and show.jsp) generated for the domain class contains the following code fragment. (Assuming your domain class has a variable declared as Date)
${fieldValue(bean:objectInstance, field:'expiryDate')}
By using the formatDate tag as below we will be able to overcome the formatting issue.
${objectInstance?.expiryDate}
However, I noticed that when expiryDate in the above example is null, the tag displays the current date as opposed to to showing blank.
By replacing the formatDate tag with the following line resolved the problem.
${objectInstance?.expiryDate?.format("MM/dd/yyyy")}
It displays current date when the date passed is a null object when used in the gsp page. The default date is rendered along with timestamp when the gsp pages are generated using grails commands generate-views or generate-all for a domain class. The views (list.jsp and show.jsp) generated for the domain class contains the following code fragment. (Assuming your domain class has a variable declared as Date)
${fieldValue(bean:objectInstance, field:'expiryDate')}
By using the formatDate tag as below we will be able to overcome the formatting issue.
However, I noticed that when expiryDate in the above example is null, the tag displays the current date as opposed to to showing blank.
By replacing the formatDate tag with the following line resolved the problem.
${objectInstance?.expiryDate?.format("MM/dd/yyyy")}
Comments
Post a Comment