Results 1 to 4 of 4

Thread: DWR Custom Objects not being read correctly

Hybrid View

  1. #1
    Join Date
    Oct 2012
    Location
    London
    Posts
    3

    Default DWR Custom Objects not being read correctly

    Hello there,

    I am using DWR to convert an array of objects (called Rhasset.java) from JavaScript to the back-end. Simple arrays of Strings work, the individual Rhasset object also works but when I send an array of Rhasset objects than the element data looks as follows:

    [{name:reference:c0-e2, value:reference:c0-e3}]

    The 'name' and 'value' are the actual keys for the objects entries but the values are not readable.

    Here is my code:

    JavaScript:

    Code:
    var testArray = [{ name : 'TestName', value: 'TestValue'}];
    rhassetServices.invokeMessage(testArray);
    DWR.XML:

    Code:
    <convert converter="bean" match="com.qas.newmedia.internet.rhasset.model.Rhasset" />
    Java Controller:

    Code:
    public List<Rhasset> invokeMessage(List<Rhasset> list) {	
    	return list;
        }
    Java Object:

    Code:
    public class Rhasset {
        
        public String name;
        public String value;
        
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public String getValue() {
            return value;
        }
        public void setValue(String value) {
            this.value = value;
        }
    }
    As you can see this is pretty straightforward stuff. In fact I can remove the Rhasset stuff and just read back arrays of string objects and still get the same issue.

    I have tried messing around with signatures and converters and a number of other things but have not been able to get anywhere - and as far as I know this set-up should be supported as standard.

    Can someone suggest as to what I might be doing wrong or suggest any other avenues to investigate?

    Many thanks in advance,

    Greg

  2. #2
    Join Date
    Oct 2012
    Location
    London
    Posts
    3

    Default

    Any pointers would be greatly appreciated as I am now going down the route of using Ajax with JSON objects.

    But I would much prefer to use DWR.

    Many thanks in advance,

    Greg

  3. #3
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello Greg

    With the best intentions try to go with jQuery, it has a great Ajax support too.
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  4. #4
    Join Date
    Oct 2012
    Location
    London
    Posts
    3

    Default

    Thanks for your reply. Yes, I have resorted to using jQuery with Ajax and it does everything I need it to do. Would be nice to have used DWR though, and also to know what I was doing wrong.

    Thanks again, G.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •