2

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
wsxiapiaoxue
  • 47
  • 1
  • 2
  • 9

3 Answers3

0

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>
Yuck
  • 49,664
  • 13
  • 105
  • 135
ravindra
  • 186
  • 1
  • 9
0

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.

deepmoteria
  • 2,279
  • 2
  • 19
  • 20
0

Instead of using a hidden input you could take advantage of JSF and use a f:param or f:attribute.

Read this really fine article, under the brand of BalusC: http://balusc.blogspot.com/2006/06/communication-in-jsf.html .

spauny
  • 4,976
  • 9
  • 44
  • 61