You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by "Michael Allman (JIRA)" <ji...@apache.org> on 2010/06/25 06:51:50 UTC

[jira] Created: (PIVOT-547) Bug in JSON.java prevents the use of Element as a destination for data binding

Bug in JSON.java prevents the use of Element as a destination for data binding
------------------------------------------------------------------------------

                 Key: PIVOT-547
                 URL: https://issues.apache.org/jira/browse/PIVOT-547
             Project: Pivot
          Issue Type: Bug
          Components: core-xml
    Affects Versions: 1.5
            Reporter: Michael Allman
            Priority: Minor
         Attachments: xml_binding_fix.patch

A bug in the JSON.put method prevents using an Element instance as a destination for data binding.  This issue arises because Element implements both the Dictionary and Sequence interfaces.

I've attached a proposed fix.  The approach I've taken is to test if the key can be parsed into an int.  If not, it's assumed to be a Dictionary key.  This fixes the issue with Element and should fix the issue for the more general case of any other class that implement Dictionary and Sequence.

Given that this is a bug, I've generated the patch against the 1.5.x branch.

Cheers.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (PIVOT-547) Bug in JSON.java prevents the use of Element as a destination for data binding

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/PIVOT-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12882558#action_12882558 ] 

Greg Brown commented on PIVOT-547:
----------------------------------

This may or may not be a bug. The JSON accessor methods aren't really intended to be used with XML elements - they are meant to manipulate JSON-like structures, which XML elements are not. You can use the org.apache.pivot.xml.XML class to access nested XML data.

In any case, I'd like to look into this a bit more. Can you provide some sample code that reproduces the issue? Thanks.


> Bug in JSON.java prevents the use of Element as a destination for data binding
> ------------------------------------------------------------------------------
>
>                 Key: PIVOT-547
>                 URL: https://issues.apache.org/jira/browse/PIVOT-547
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-xml
>    Affects Versions: 1.5
>            Reporter: Michael Allman
>            Priority: Minor
>         Attachments: xml_binding_fix.patch
>
>
> A bug in the JSON.put method prevents using an Element instance as a destination for data binding.  This issue arises because Element implements both the Dictionary and Sequence interfaces.
> I've attached a proposed fix.  The approach I've taken is to test if the key can be parsed into an int.  If not, it's assumed to be a Dictionary key.  This fixes the issue with Element and should fix the issue for the more general case of any other class that implement Dictionary and Sequence.
> Given that this is a bug, I've generated the patch against the 1.5.x branch.
> Cheers.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIVOT-547) Bug in JSON.java prevents the use of Element as a destination for data binding

Posted by "Michael Allman (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Allman updated PIVOT-547:
---------------------------------

    Attachment: xml_binding_fix.patch

Proposed fix

> Bug in JSON.java prevents the use of Element as a destination for data binding
> ------------------------------------------------------------------------------
>
>                 Key: PIVOT-547
>                 URL: https://issues.apache.org/jira/browse/PIVOT-547
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-xml
>    Affects Versions: 1.5
>            Reporter: Michael Allman
>            Priority: Minor
>         Attachments: xml_binding_fix.patch
>
>
> A bug in the JSON.put method prevents using an Element instance as a destination for data binding.  This issue arises because Element implements both the Dictionary and Sequence interfaces.
> I've attached a proposed fix.  The approach I've taken is to test if the key can be parsed into an int.  If not, it's assumed to be a Dictionary key.  This fixes the issue with Element and should fix the issue for the more general case of any other class that implement Dictionary and Sequence.
> Given that this is a bug, I've generated the patch against the 1.5.x branch.
> Cheers.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (PIVOT-547) Bug in JSON.java prevents the use of Element as a destination for data binding

Posted by "Michael Allman (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Allman updated PIVOT-547:
---------------------------------

    Attachment: Element_Bug.tgz

Eclipse project illustrating the bug is attached.

First, you'll need to fix the build path to reference the Pivot libs on your system.

Run ElementBug.  Put some text in the fields or whatever.  Press "Store".  You'll get an exception.

Set a breakpoint on JSON.put.  Rerun the app in the debugger and step through the put method.  This should make the problem crystal clear.

Cheers.

> Bug in JSON.java prevents the use of Element as a destination for data binding
> ------------------------------------------------------------------------------
>
>                 Key: PIVOT-547
>                 URL: https://issues.apache.org/jira/browse/PIVOT-547
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-xml
>    Affects Versions: 1.5
>            Reporter: Michael Allman
>            Priority: Minor
>         Attachments: Element_Bug.tgz, xml_binding_fix.patch
>
>
> A bug in the JSON.put method prevents using an Element instance as a destination for data binding.  This issue arises because Element implements both the Dictionary and Sequence interfaces.
> I've attached a proposed fix.  The approach I've taken is to test if the key can be parsed into an int.  If not, it's assumed to be a Dictionary key.  This fixes the issue with Element and should fix the issue for the more general case of any other class that implement Dictionary and Sequence.
> Given that this is a bug, I've generated the patch against the 1.5.x branch.
> Cheers.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (PIVOT-547) Bug in JSON.java prevents the use of Element as a destination for data binding

Posted by "Greg Brown (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/PIVOT-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Brown resolved PIVOT-547.
------------------------------

    Resolution: Not A Problem

XML elements are not really intended to serve as model data as shown in this example. The JSON-oriented data structures (List and Map) or Java bean objects should be used for this purpose. 

Additionally, the JSON class is meant to access properties of JSON-like structures, not XML structures. You should use the XML class for path-based access to an XML DOM.



> Bug in JSON.java prevents the use of Element as a destination for data binding
> ------------------------------------------------------------------------------
>
>                 Key: PIVOT-547
>                 URL: https://issues.apache.org/jira/browse/PIVOT-547
>             Project: Pivot
>          Issue Type: Bug
>          Components: core-xml
>    Affects Versions: 1.5
>            Reporter: Michael Allman
>            Priority: Minor
>         Attachments: Element_Bug.tgz, xml_binding_fix.patch
>
>
> A bug in the JSON.put method prevents using an Element instance as a destination for data binding.  This issue arises because Element implements both the Dictionary and Sequence interfaces.
> I've attached a proposed fix.  The approach I've taken is to test if the key can be parsed into an int.  If not, it's assumed to be a Dictionary key.  This fixes the issue with Element and should fix the issue for the more general case of any other class that implement Dictionary and Sequence.
> Given that this is a bug, I've generated the patch against the 1.5.x branch.
> Cheers.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.