Bug 824863 - groovy template should not print "null" string when variable is null
groovy template should not print "null" string when variable is null
Status: VERIFIED
Product: JBoss Enterprise Portal Platform 5
Classification: JBoss
Component: Portal (Show other bugs)
5.2.2.ER01
Unspecified Unspecified
medium Severity medium
: ---
: 5.2.2.ER04
Assigned To: Default User
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-24 09:12 EDT by hfnukal@redhat.com
Modified: 2018-02-06 14:13 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
If a GateIn Template file (*.gtmpl) contained an <input> directive that declared a variable as a value, and that variable resolved to null, the word "null" would be substituted for the value instead of the value parameter being present, but undefined. For example, <input class="key" type="text" name="key" value="${key}"/> resolved to <input class="key" type="text" name="key" value="null"/>, instead of <input class="key" type="text" name="key" value/>. The fix corrects the way null values are handled, and now prints undefined parameters, instead of printing null as the parameter value.
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Commits:
8713 by hfnukal at 2012-06-05 10:03:10 EDT (show)
8713 by hfnukal at 2012-06-05 10:03:10 EDT

Checked in to /mnt/n4aphx2-3.storage.phx2.redhat.com/svn/repos/gatein

Bug 824863 - groovy template should not print "null" string when variable is null

2 files changed:

  • epp/portal/branches/EPP_5_2_Branch/component/scripting/src/main/java/org/exoplatform/groovyscript/GroovyPrinter.java (+5 / -1)
  • epp/portal/branches/EPP_5_2_Branch/component/scripting/src/test/java/org/exoplatform/groovyscript/TestTemplateRendering.java (+9 / -0)


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker GTNPORTAL-2373 Minor Resolved groovy template should not print "null" string when variable is null 2018-03-22 15:03 EDT

  None (edit)
Description hfnukal@redhat.com 2012-05-24 09:12:50 EDT
In .gtmpl file, I use: <input class="key" type="text" name="key" value="${key}"/>
And if "key" variable is null, I will get "null" string in input like: <input type="text" name="key" value="null">
I think it should not be, we should print nothing when variable is null, for example: <input type="text" name="key" value>
Comment 1 hfnukal@redhat.com 2012-06-07 11:34:28 EDT
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
C: GTMPL template prints null, when key was not definned
C: Non valid string shown on page
R: Use empty string
F: Returning empty string instead of null.
Comment 2 Viliam Rockai 2012-07-10 11:59:57 EDT
xercesImpl-2.9.1-patch-01.jar are now used. any ideas how to check if this version has the right patch in it?
Comment 3 JBoss JIRA Server 2012-07-27 10:44:15 EDT
Boleslaw Dawidowicz <boleslaw.dawidowicz@gmail.com> made a comment on jira GTNPORTAL-2373

Kien is the patch commited in gatein? Could you confirm and resolve?
Comment 4 Trang Vu 2012-07-30 02:56:34 EDT
There is a side effect on EPP-SP 5.2.2-ER02, see https://jira.exoplatform.org/browse/SPUB-191 for the detail.
Comment 5 Michal Vanco 2012-07-30 08:46:25 EDT
Needs be updated based on https://jira.exoplatform.org/browse/SPUB-191
Comment 6 hfnukal@redhat.com 2012-07-30 10:01:26 EDT
Updated Signin.xml in branding script.
Comment 7 JBoss JIRA Server 2012-07-31 23:00:32 EDT
kien nguyen <nguyenanhkien2a@gmail.com> made a comment on jira GTNPORTAL-2373

@Trang Vu: how to verify side effect of https://jira.exoplatform.org/browse/SPUB-191 because the patch has not yet commited on gatein?
Comment 8 JBoss JIRA Server 2012-07-31 23:55:25 EDT
kien nguyen <nguyenanhkien2a@gmail.com> made a comment on jira GTNPORTAL-2373

It seems to the patch had committed on EPP. And now, Groovy engine will render "" instead of "null", so side effect will occur if your javascript is only processing by based on "null" value
Comment 9 Trang Vu 2012-08-14 07:03:26 EDT
Customers whose sites are based on ACME portal template will have to update their Signin.xml manually. We should revert the commit 8713 to avoid such kind of impact.
Comment 10 Jared MORGAN 2012-08-21 00:28:38 EDT
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,4 +1 @@
-C: GTMPL template prints null, when key was not definned
+If a GateIn Template file (*.gtmpl) contained an <input> directive that declared a variable as a value, and that variable resolved to null, the word "null" would be substituted for the value instead of the value parameter being present, but undefined. For example, &lt;input class="key" type="text" name="key" value="${key}"/&gt; resolved to &lt;input class="key" type="text" name="key" value="null"/&gt;, instead of &lt;input class="key" type="text" name="key" value/&gt;.  The fix corrects the way null values are handled, and now prints undefined parameters, instead of printing null as the parameter value.-C: Non valid string shown on page
-R: Use empty string
-F: Returning empty string instead of null.
Comment 11 Jared MORGAN 2012-08-21 02:19:09 EDT
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-If a GateIn Template file (*.gtmpl) contained an <input> directive that declared a variable as a value, and that variable resolved to null, the word "null" would be substituted for the value instead of the value parameter being present, but undefined. For example, &lt;input class="key" type="text" name="key" value="${key}"/&gt; resolved to &lt;input class="key" type="text" name="key" value="null"/&gt;, instead of &lt;input class="key" type="text" name="key" value/&gt;.  The fix corrects the way null values are handled, and now prints undefined parameters, instead of printing null as the parameter value.+If a GateIn Template file (*.gtmpl) contained an &lt;input&gt; directive that declared a variable as a value, and that variable resolved to null, the word "null" would be substituted for the value instead of the value parameter being present, but undefined. For example, &lt;input class="key" type="text" name="key" value="${key}"/&gt; resolved to &lt;input class="key" type="text" name="key" value="null"/&gt;, instead of &lt;input class="key" type="text" name="key" value/&gt;.  The fix corrects the way null values are handled, and now prints undefined parameters, instead of printing null as the parameter value.
Comment 12 JBoss JIRA Server 2012-09-04 00:19:38 EDT
kien nguyen <nguyenanhkien2a@gmail.com> made a comment on jira GTNPORTAL-2373

Some side effect of https://jira.exoplatform.org/browse/SPUB-191 are resolved and patch was committed in EPP. The patch need to be committed in GateIn
Comment 13 JBoss JIRA Server 2012-09-04 04:06:47 EDT
Vu Viet Phuong <vstorm83@gmail.com> made a comment on jira GTNPORTAL-2373

Backport from https://bugzilla.redhat.com/show_bug.cgi?id=824863
Comment 14 JBoss JIRA Server 2012-10-11 05:40:23 EDT
Trong Tran <trongtt@gmail.com> made a comment on jira GTNPORTAL-2373

printing "null" is an expected behavior from Groovy template engine world. I don't really like to change this default behavior ( And I can see that JSP syntax does the same. )

For me, the proper fix is to check non-NULL value before printing if we don't want to write "null". So I prefer to take "Won't Fix" for this.

WDYT ?
Comment 15 JBoss JIRA Server 2012-10-11 07:44:38 EDT
Trong Tran <trongtt@gmail.com> updated the status of jira GTNPORTAL-2373 to Resolved

Note You need to log in before you can comment on or make changes to this bug.