0
votes

I am trying to update an UI text field in primefaces 6.2 using java script method. Though I am able to update the value from UI side, it is not reflecting in backing managed bean

Xhtml:

<h:inputHidden id="test" value="#{mybean.fieldname}" valueChangeListener="#            
{mybean.method}">
    <f:ajax/>
</h:inputHidden>

Javascript:

function update(){
    document.getElementByID('form:test').value="change";
    alert(document.getElementByID('form:test').value);
}

I expect my value changehandler to get called since I updated my value but nothing occurs.can some one pls tell where I am getting wrong

Edit :Actually I am trying to submit the value changed from UI side alone using Js to the actual bean value, basically dom alone is changed and kind of trying to submit the same using any ajax calls. but still it is not working. Refered this link:When to use valueChangeListener or f:ajax listener? Can some one pls give some insights on how this can be achieved?

1
Changing the value client-side does not make it submit the value... And there is nothing PrimeFaces in here... - Kukeltje
And some basic searching like google.com/… results in many hits that might help... - Kukeltje
Hi , thanks all for the inputs. I actually tried out stackoverflow.com/questions/11879138/… this. But that does not work though :( - user3729090
There are lots of things in there, what did you try? What was the result? 'Did not work' is to vage and to little info to help with. minimal reproducible example please! - Kukeltje

1 Answers

0
votes

You have to trigger explicitly a change event by JavaScript if you set a value by JavaScript.