I currently have a component like the following example:
@Component("infoData")
public class infoDataClass(){
protected Integer age;
protected String name;
protected String address;
with their getters and setters...
And in my xhtml I access those attributes in the following way :
<div
id="infoContainer"
data-age="#{infoData.age}"
data-address="#{infoData.address}"
data-name="#{infoData.name}"
></div>
And I get them successfully. My question is, instead of accessing them one by one, how could i get them all together? I need to add 5-6 and maybe even more attributes in the future and it will become really messy if I continue like this.
In my frontend (vue) I parse them in the following way:
const age= $(containerElement).attr('data-age');
const name= $(containerElement).attr('data-name');
Fixed by serializing my object by using Gson.
public String getJsonChartData() {
Gson gson = new Gson();
return gson.toJson(this);
}