Reputation: 4284
I have this p:inputTextarea:
<p:inputTextarea id="inputTextArea" value="#{myBean.data}" />
Since I moved the submitting form button elsewhere, myBean.data stays null when clicking on the button
So I did this:
<p:inputTextarea id="inputTextArea" value="#{myBean.data}}">
<f:ajax event="blur" />
</p:inputTextarea>
which seems to work !
But I have a feeling that there is a more elegant way of doing this. I just need the value from the inputTextarea written to the bean, so that when I click a button in another form, the data will be available.
Any ideas ?
Upvotes: 0
Views: 1073
Reputation: 236
This is all kinda wrong. You have to understand the lifecycle of JSF. To make a short answer, on your button you should "process" "@this (the button itself) and inputTextArea". And then all will work alright. As a further performance improvement, you could use on the same button "partialSubmit= true" so that only the said fields (the input and the button) are submitted with the form. So you only need
<p:inputTextarea id="inputTextArea" value="#{myBean.data}" />
(no double brackets in the end) and then
<p:commandButton ..... process = "@this inputTextArea" .... partialSubmit = "true" />
But trust me, if you hit this (so simple) problem now ... you need to get a serious JSF book and start loving the Primefaces manual.
Upvotes: 1