从javascript更新UI值未反映在javabean中

编程入门 行业动态 更新时间:2024-10-24 20:15:04
本文介绍了从javascript更新UI值未反映在javabean中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用Java脚本方法更新primefaces 6.2中的UI文本字段.虽然我可以从UI端更新值,但它并没有反映在支持托管bean上

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:

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

实际上,我试图将使用Js从UI端更改的值提交到实际的bean值,基本上是单独更改dom,并且尝试使用任何ajax调用提交相同的值.但仍然无法正常工作.引用了此链接:何时使用valueChangeListener或f:ajax监听器?能否请一些人对如何实现这一目标提供一些见解?

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?

推荐答案

如果通过JavaScript设置值,则必须通过JavaScript显式触发更改事件.

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

更多推荐

从javascript更新UI值未反映在javabean中

本文发布于:2023-11-10 06:31:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1574611.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:javascript   UI   javabean

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!