1

I want to set a set some value to a bean property through my D3 code. For this I am using h:inputHidden tag of JSF to create a hidden input field:

<h:inputHidden id="hiddenInputID" value="#{someBean.someBeanProperty}"/>

someBeanProperty is a String variable in someBean class which has getter and setter methods.

Through my D3 code, I am selecting an element by it's class and on click event I am passing the value through JQuery.

d3.selectAll('.someclass').on('click',function (item,i) {
jQuery('#hiddenInputID').val("valueToSet");
});

But this approach is not working. Can anybody please find the mistakes I am making or suggest some better approach. Thanks

Ash
  • 672
  • 6
  • 21
  • Ok, so this solved my problem: I changed the way I was selecting the ID of hidden input field through JQuery, because JSF rendering the ID by appending some more random values. Here is the changes I made: `jQuery('input[id*="hiddenInputID"]').val("valueToSet");` . I am now selecting the element which contains the "hiddenInputID" Id instead of exact match. – Ash Mar 22 '18 at 11:38
  • The values are not random, the id is prefixed with parent naming container ids. – Jasper de Vries Mar 22 '18 at 12:05
  • .. you probably don't have ids set on the parent naming containers which causes ids to be generated (which may seem random). When you set an id to, for example your form, you can use a better selector (using `=` instead of `*=`). – Jasper de Vries Mar 22 '18 at 12:31
  • Thanks @JasperdeVries, but I work in particular section on UI, and the parent naming containers have their id set according to current system time. So, I have to go with this approach. – Ash Mar 30 '18 at 08:33

0 Answers0