Skip to content

Mis en ligne par admin - 23 décembre 2013 - Web Applications

JSF Richfaces retrieve Bean Object as Javascript Variable

If a javascript function must be executed using some managed bean output, the complex data should be accessible using the data attribute (e.g. in jsFunction) to point the Managed Bean java variable.
Then you should call the Javascript function using event.data.

Code:
data="#{managedBean.data}" oncomplete="StateManager.onRetrieveStatesCompleted(event.data);">

If you’re using some models generated by Liferyay Service Builder, I think you should not directly return the data (because the JSON stringifier seems not working with the generated structures)

Note that, in the case you would not use the data attribute, you would do :
oncomplete= »StateManager.onRetrieveStatesCompleted(‘#{managedBean.data}’); »>
In that case, the javascript variable would be a string.
(and without the ‘ , it would simply not work.

Articles similaires

Les articles suivants abordent des thèmes communs.

Commentaires

Partagez vos remarques.

Il n'y a pas de commentaires pour cet article.

Add a Comment

Fill in the form and submit.