如何使用p:commandButton更新h:inputHidden? [英] How to update a h:inputHidden with p:commandButton?

查看:70
本文介绍了如何使用p:commandButton更新h:inputHidden?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为任何数据写了一个ajax请求.但是该数据不适用于h:inputHidden. 我认为这是Primefaces的错误. 但是我现在不知道如何获取数据.

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.

代码:

<h:inputHidden id="buttonData" value="#{buttonDataBean.buttonData}" />
...
<p:commandButton id="getData" action="#{buttonAction.getButtonData}" update="buttonData" />

当我单击commandButton时,don的值不起作用. 但是,如果我使用h:outputText,它就可以工作.

When I click the commandButton, the value of don't work. But if I use the h:outputText, it worked.

我的要求: 在单击commandButton之前,我已经动态创建了任何html按钮.我想单击commandButton并更新html按钮的名称和位置.这样我就必须获取任何数据并使用Javascript更新html按钮. 我该怎么办?

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?

如果我想使用JavaScript来获取Ajax数据,该怎么做.我看到该文档并找到两个方法:jsf.ajax.request()和Primefaces.ajax.AjaxRequest().但是我不知道如何使用这两种方法.例如:Primefaces.ajax.AjaxRequest("test.xhtml" ,,). "test.xhtml"如何请求TestAction的testMethod方法?

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?

推荐答案

使用萤火虫检查html代码.您可以看到新的价值

use firebug to inspect html code. you can see new value

<h:form id="form">
  <h:inputHidden  id="buttonData" value="#{buttonDataBean.buttonData}" />
  <p:commandButton id="getData" value="button"
                   action="#{buttonDataBean.buttonAction}" update="buttonData" />
</h:form>

这篇关于如何使用p:commandButton更新h:inputHidden?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆