0

I'm using primefaces for my front end with java as backing bean. I have a textarea with a clear button attached to it, followed by a selectMenu. When the textarea is not empty, I want my selectMenu disabled, however when the textArea is cleared with the button, I can't seem to get it to update the selectMenu so that it becomes enabled is again. However when the textarea is manually cleared, it updates my selectMenu.

Here is my code:

<p:outputPanel>
   <div class="ui-grid-col-3">
      <p:inputTextarea id="containerNums" cols="60" rows="3">
         <p:ajax event="change" process="@this" immediate="true" update="containerSection">
      </p:inputTextarea >
   </div>
</p:outputPanel>
   <div class="ui-grid-col-3">
      <p:commandButton type="button"
         value="x"
         onclick="clearTextArea(containerNums)"
         update="containerType"/>
   </div>
<p:outputPanel>
   <p:selectOneMenu id="containerType"
   value="containerType"
   disabled="#{myBean.containerNums != null}">
</p:outputPanel>

Any ideas on what to change to achieve my desired result?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Liam Paquette
  • 79
  • 1
  • 7
  • Hi, start by creating a [mcve] and narrow things down – Kukeltje Jun 28 '19 at 13:27
  • Effectively you imply (without explicitly mentioning) that calling `clearTextArea(containerNums)` from the browser console it works! But I'm sure you tried that and it is indeed working. – Kukeltje Jun 28 '19 at 13:39
  • yes it works, my actual code has a lot more going on but I tried to simplify as much as possible – Liam Paquette Jun 28 '19 at 14:20
  • It is not about simplifying alone, it is always about [mcve] there isoo much in your code that might either be a typo or code missing. And with the code as it is I cannot imagine calling the javascript from the cinsole works – Kukeltje Jun 28 '19 at 14:34
  • The ajax of your textarea is different from the buttons' ajax in that it processes itself only (@this) while the button processes the entire form. (@form) And there is the immediate="true" thing. – Selaron Jun 28 '19 at 16:10
  • Possible duplicate of [commandButton/commandLink/ajax action/listener method not invoked or input value not set/updated](https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value) – Selaron Jun 28 '19 at 16:12

0 Answers0