Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is data.foo syntax in JSF/Rich Faces

what is data.foo syntax in JSF/Rich Faces?

Say for example,

  <a4j:support event="onchange"  action="#{bean.retrieveStates}"  
  reRender="states_dropDown" data="#{student}"></a4j:support>

i am passing student object in data attribute. can I access in managed bean? Documentation says this "Serialized (on default with JSON) data passed on the client by a developer on AJAX request. It's accessible via "data.foo" syntax "

can some one please explain.

like image 343
crazyTechie Avatar asked Apr 08 '26 15:04

crazyTechie


1 Answers

From this blogpost:

Another attribute is data, which allows you to get any additional data from the server during an Ajax request. The data attribute can simply point to a bean property via EL, and the data will be serialized in JSON format and available on the client side. Here’s an example:

<a4j:commandButton value="Submit" reRender="out"
   data="#{bean.text}"
   oncomplete="alert(data)"/>

So yes - you can access any attribute of the managed bean and reference it (most often) in oncomplete.

like image 79
Bozho Avatar answered Apr 12 '26 01:04

Bozho