Question

i have a requirement where a state dropdown populates the city. so i used autosubmit on the statedropdown & a valuechangeListener to refersh the city dropdown using partial triggers, since i want my values on the client side i have used the valuepassthru on the state dropdown but this prevents my valluechange listener from being called.

If i set the valuepassthru attibute to false the valuechange listener is called but i need the valuepassthru to be set to true to access the value at client side javascript.

My binded object on the state is a string and the options are list of selectItems so i thought this could be a issue and used a custome converter but that didnt work either

Any thoughts on what could be reason for not triggering the valuechangelistener with autosubmit and valuepassthrough=true? any help on this is highly appreciated

I am using trinidad componets for the dropdown and Jsf1.1 thanks

Était-ce utile?

La solution

Do you only need the selected value, or do you need to access all values? If you only need the selected value you can add some Javascript in your bean's value change listener:

FacesContext context = FacesContext.getCurrentInstance();
ExtendedRenderKitService erks = Service.getRenderKitService(
  context
, ExtendedRenderKitService.class
);
String jsValue = StringEscapeUtils.escapeJavaScript(value);
erks.addScript(context, "alert('"+ jsValue +"');");
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top