0

I needs to enable / disable commandlink depending text area.

Here is the code:

<p:inputTextarea id="inputTextarea" value="#{headerBean.dto.erganzendeInfo}" 
valueChangeListener="#{headerBean.eventValidator}" autoResize="false" 
onclick="enableField(inputTextarea)"> </p:inputTextarea>
<p:commandLink id="selectOneMenuId" widgetVar="selectOneMenuWidget1" 
oncomplete="PF('popUp').show();" styleClass="mediumButton" process="@this" disabled="#{headerBean.dto.headerSwitcherDto.lang}" update="message_popup">
<f:param name="newLink" value="YES" />

<h:graphicImage library="#{sessionData.theme}" name="images/message.png" /> </p:commandLink>

I try to set disable by the following: script

        function enableField(element) {
            PF('selectOneMenuWidget1').enable();
            document.getElementById("formId:selectOneMenuId").enabled = true;
            jQuery('#selectOneMenuId').val("enabled");

        }

but not successful.

user3431624
  • 171
  • 1
  • 1
  • 10
  • 1
    Client-side enabling a disabled button does not work. Would be a security thing. https://stackoverflow.com/questions/8647315/pcommandbutton-not-working-when-disable-true-initially – Kukeltje Jan 20 '20 at 13:21
  • You should use the disabled attribute of your commandButton, which is managed from your back-end (ManagedBean), and use the onchange listener of the inputtext area to change the value of this attribute, and just use update from the onchange listener to update the button – BugsForBreakfast Jan 20 '20 at 14:50
  • @BugsForBreakfast its works for commandButton. But not works for my p:commandLink – user3431624 Jan 27 '20 at 05:25
  • Hmm are you allowed to use the rendered attribute instead? – BugsForBreakfast Jan 27 '20 at 13:06
  • no but disable condition there ' disabled="#{headerBean.dto.headerSwitcherDto.lang}"' – user3431624 Jan 28 '20 at 09:11

0 Answers0