« Return to Thread: Excluding properties when converting from JavaScript to Java objects

Re: Excluding properties when converting from JavaScript to Java objects

by David Marginian-2 :: Rate this Message:

Reply to Author | View in Thread

I really don't know your situation but no matter the complexity I have
always been able to build objects and only send what is expected to the
back-end.  And I have been using DWR for about 4 years now dealing with a
lot of complex layouts.  My feeling is that there is an easier way.

From the sounds of it you are sending a div to the backend?  Is this true?

I can help you out further but I would need to see your html, js, the
object you are trying to save and the method you are calling to save it.  

See my comments below:

var jsObject = new Foo();
jsObject.a = 123;
jsObject.b = 456; // b is not part of Foo prototype!
Bar.saveFoo(jsObject, callbackFunction);
(Don't send b to the server then (are you saying this is a div, if that's
the case NO NO NO?).  I am still unclear why you are doing this.  You Build
your objects and just send what is needed to the server.)

DWR sends to the server:
// DWR does send it but you are telling it what to send. Not sure what your
expectation is here.

c0-scriptName=Bar
c0-methodName=saveFoo
c0-id=0
c0-e1=number:123
c0-e2=number:456
c0-param0=Object_Foo:{a:reference:c0-e1, b:reference:c0-e2}

and it doesn't matter if you change the converter to exclude the property b:

// This doesn't even make sense since b is not even a field on Foo.
// So I would expect it to have no affect.
<convert converter="bean" javascript="Foo" match="my.package.Foo">
     <param name="exclude" value="b"/>
</convert>



Original Message:
-----------------
From: Bruno Klava bklava@...
Date: Thu, 17 Apr 2008 17:13:08 -0300
To: users@...
Subject: Re: [dwr-user] Excluding properties when converting from
JavaScript to Java objects


> I am a bit confused.  If b is not a part of Foo why are you setting it in
>  your JavaScript object?

It's a gui element representing this object (the user can manipulate
the data using the gui elements, and the structure is quite complex,
so i need a reference from each element to its gui element).

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...



--------------------------------------------------------------------
myhosting.com - Premium Microsoft® Windows® and Linux web and application
hosting - http://link.myhosting.com/myhosting



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Excluding properties when converting from JavaScript to Java objects

LightInTheBox - Buy quality products at wholesale price