如何用 p:commandButton 更新 ah:inputHidden?
我写了一个ajax请求来获取任何数据。但数据不适用于 h:inputHidden。 我认为这是 Primefaces 的一个错误。 但我现在不知道如何获取数据。
代码:
<h:inputHidden id="buttonData" value="#{buttonDataBean.buttonData}" />
...
<p:commandButton id="getData" action="#{buttonAction.getButtonData}" update="buttonData" />
当我单击命令按钮时, 的值不起作用。 但如果我使用 h:outputText,它就起作用了。
我的要求: 在单击 commandButton 之前,我已经动态创建了任何 html 按钮。我想单击 commandButton 并更新 html 按钮的名称和位置。所以我必须获取任何数据并使用 Javascript 更新 html 按钮。 我该怎么办?
如果我想使用JavaScript来获取ajax数据,该怎么做。我查看文档并找到两个方法:jsf.ajax.request()和Primefaces.ajax.AjaxRequest()。但我不知道如何使用这两种方法。例如:Primefaces.ajax.AjaxRequest("test.xhtml",,)。 “test.xhtml”如何请求TestAction的testMethod方法?
I writed an ajax request for any data. But the data don't work with h:inputHidden.
I think it's a bug of Primefaces.
But I don't know how to get the data now.
code:
<h:inputHidden id="buttonData" value="#{buttonDataBean.buttonData}" />
...
<p:commandButton id="getData" action="#{buttonAction.getButtonData}" update="buttonData" />
When I click the commandButton, the value of don't work.
But if I use the h:outputText, it worked.
My requirement:
Before click the commandButton, I have create any html buttons dynamically. I want to click the commandButton and update the name and position of html buttons. So that I must get any data and update the html buttons with Javascript.
how could I do about it?
If I want to use the JavaScript to get the ajax data, how to do it. I see the document and find two method: jsf.ajax.request() and Primefaces.ajax.AjaxRequest(). But I don't know how to use the two method. for example: Primefaces.ajax.AjaxRequest("test.xhtml",,). The "test.xhtml" how to request the method testMethod of TestAction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 firebug 检查 html 代码。你可以看到新的价值
use firebug to inspect html code. you can see new value
如果你的问题用primefaces ajax没有解决,你可以使用jsf提供的原生ajax看看。它有效,我用它做了很多这样的事情。
If your problem does not get solved with primefaces ajax, you can use the native ajax provided by jsf have a look at it.It works, i have done many such things with it.
您可以利用 JSF 并使用
f:param
或f:attribute
,而不是使用隐藏输入。阅读 BalusC 品牌下这篇非常精彩的文章:http://balusc .blogspot.com/2006/06/communication-in-jsf.html。
Instead of using a hidden input you could take advantage of JSF and use a
f:param
orf:attribute
.Read this really fine article, under the brand of BalusC: http://balusc.blogspot.com/2006/06/communication-in-jsf.html .