[richfaces-issues] [JBoss JIRA] (RF-12593) RenderKitUtils.toScriptArgs() returns empty string when no not-null parameter provided
Lukáš Fryč (JIRA)
jira-events at lists.jboss.org
Fri Oct 18 08:45:02 EDT 2013
[ https://issues.jboss.org/browse/RF-12593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12823172#comment-12823172 ]
Lukáš Fryč edited comment on RF-12593 at 10/18/13 8:43 AM:
-----------------------------------------------------------
The issue is that {{toScriptArgs}} suppose to return not only collections, as can be seen in the test:
https://github.com/richfaces/richfaces/blob/master/framework/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java#L134
In this case, it would be much better if it return:
* empty hash {{{}}} when empty map provided
* empty array {{[]}} when empty collection or array provided
* {{null}} if null provided
This is mostly the behavior which it already has:
https://github.com/richfaces/richfaces/blob/master/framework/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java#L142
The only case is return of {{""}} instead of {{null}}.
----
While {{null}} can sometimes cause {{variable is undefined}} issue, returning empty value is much more dangerous, since it leads to the code which is not compilable in runtime at all.
E.g.: https://github.com/richfaces/richfaces/blob/master/framework/src/main/java/org/richfaces/ui/input/editor/editor.template.xml#L66
In this code, when no options are provided, the renderer code is:
{code}
var options = ;
{code}
which is syntactically wrong.
was (Author: lfryc):
The issue is that {{toScriptArgs}} suppose to return not only collections, as can be seen in the test:
https://github.com/richfaces/richfaces/blob/master/framework/src/test/java/org/richfaces/renderkit/RenderKitUtilsTest.java#L134
In this case, it would be much better if it return:
* empty hash {{{}}} when empty map provided
* empty array {{[]}} when empty collection or array provided
* {{null}} if null provided
> RenderKitUtils.toScriptArgs() returns empty string when no not-null parameter provided
> --------------------------------------------------------------------------------------
>
> Key: RF-12593
> URL: https://issues.jboss.org/browse/RF-12593
> Project: RichFaces
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: core
> Affects Versions: 4.3.0.M2
> Reporter: Lukáš Fryč
> Assignee: Lukáš Fryč
> Priority: Minor
> Fix For: 5.0.0.Alpha2
>
> Original Estimate: 45 minutes
> Remaining Estimate: 45 minutes
>
> The {{toScriptArgs(Object object)}} should always return JavaScript object:
> {code:javascript}
> { ... }
> {code}
> In case null object or no not-null parameter provided, empty object should be returned:
> {code:javascript}
> {}
> {code}
> Currently, it returns empty string {{""}} which is not handy if we expect JavaScript object as a return value.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the richfaces-issues
mailing list