-
1. Re: Mapping javascript array to a bean collection property
nbelaevski Mar 31, 2009 12:25 PM (in response to mugglmenzel)Hello Michael,
You can set converter that a4j:actionparam component will use. Also take a look at org.richfaces.json.* package. -
2. Re: Mapping javascript array to a bean collection property
mugglmenzel Apr 3, 2009 5:24 AM (in response to mugglmenzel)I wrote a nice converter using the JSON-classes of org.richfaces.json, thx for that tip!
how can i convert an array to json in javascript. I assumed that richfaces uses normal prototype lib and .toJSON() is provided by every object. but unfortunately this method isn't returning any value but ending in a javascript error.
How can I convert an JS object to JSON with richfaces?
btw. this forum search is total crap, i couldn't find my own topic for 15min by using search terms that are all included in the title and message. I finally just browsed the whole forum :( Writing this I suggest that this should be improved or at least a list of "own topics" should be available. thx -
3. Re: Mapping javascript array to a bean collection property
nbelaevski Apr 3, 2009 6:06 AM (in response to mugglmenzel)how can i convert an array to json in javascript. I assumed that richfaces uses normal prototype lib and .toJSON() is provided by every object. but unfortunately this method isn't returning any value but ending in a javascript error.
The first thing to check is whether prototype.js has been loaded for this page (only the required scripts are loaded if you are using default settings). If it's not there, you can add it using a4jloadScript component.btw. this forum search is total crap, i couldn't find my own topic for 15min by using search terms that are all included in the title and message. I finally just browsed the whole forum :( Writing this I suggest that this should be improved or at least a list of "own topics" should be available. thx
Big upgrade of forum software is planned for May, so we have to wait for this. -
4. Re: Mapping javascript array to a bean collection property
mugglmenzel Apr 5, 2009 5:31 AM (in response to mugglmenzel)All loaded! PrototypeScript, json-mini and json-dom. toJSON() Method is defined but apparently not working. I use the .toJSON() method on an array that's a clone of another on (array2 = array1.clone();).
array2 definetly has the correct data set. when testing by doing an alert() on array2 it perfectly shows me its array contents. but trying to alert the .toJSON() of it the scripting dies at that point.
weird thing! does the richfaces prototype script define the .toJSON() method for every kind of object but not for arrays?
regards
Michael -
5. Re: Mapping javascript array to a bean collection property
mugglmenzel Apr 5, 2009 5:46 AM (in response to mugglmenzel)Hmm, just testet a little the .toJSON() method:
When I use it on a new defined array consisting of native types it works perfectly.
But the array I originally wanted to transform into JSON is filled with GLatLng Objects of the google API. Is the prototype framework not applied to the google api objects?
that might cause the problem! how can I JSONize these objects then?
regards
Michael -
6. Re: Mapping javascript array to a bean collection property
mugglmenzel Apr 5, 2009 7:50 AM (in response to mugglmenzel)Finally solved!
I tried to construct the method GLatLng.prototype.toJSON but this one was never called when I triggered a .toJSON on a GLatLng Object so I finally wrote a function to convert the Array to JSON.
The function is quite simple and just creates {lat, lng} objects out of the GLatLng objects and adds them to an array which can be JSONized.
Thx for your help!
Whoever might need this functionality in his JSF pages can ask me for some code.
topic closed.