Note that there are some explanatory texts on larger screens.

plurals
  1. POEnable/Disable SelectOneMenu of primefaces using Java Script
    primarykey
    data
    text
    <p>I am new to JSF and Primefaces. I am building a xhtml page in which i have two selectonemenu of primefaces.I wanted to enable or disable second selectonemenu depending on the value selected by user in first selectonemenu. For enable/disable i wrote Java Script in the page as i wanted to do it at client side, but i dont know how to call java script function in the primefaces component.</p> <p>Code Sample</p> <pre><code> &lt;h:head&gt; &lt;style type="text/css"&gt; .ui-widget,.ui-widget .ui-widget { font-size: 12px !important; } &lt;/style&gt; &lt;script&gt; function disableOneMenu() { alert("In Disable One Menu Function..."); var clickedGroup = document.getElementById('groupOneMenu').value; alert("Selected Value " + clickedGroup); if (clickedGroup == "Designation") { document.getElementById('designation').disabled = true; alert("Location One Menu Disabled..."); } } &lt;/script&gt; &lt;link type="text/css" rel="stylesheet" href="#{request.contextPath}/themes/redmond/skin.css" /&gt; &lt;/h:head&gt; &lt;h:body&gt; &lt;h:form&gt; &lt;p:layout fullPage="true"&gt; &lt;p:layoutUnit position="north" size="30" header="HCV : Peer Group Analysis" resizable="true"&gt; &lt;/p:layoutUnit&gt; &lt;p:layoutUnit id="contentLayout" position="west" size="200"&gt; &lt;h:panelGrid columns="2"&gt; &lt;h:outputText value="Analyse for values of attribute: " /&gt; &lt;p:selectOneMenu id="groupOneMenu" value="#{userInput.groupAttr}" style="font-size:18;font-weight:bold;color:blue;width:100"&gt; &lt;f:selectItem itemLabel="Select One" itemValue="" /&gt; &lt;f:selectItems value="#{userInput.groupAttrList}" /&gt; &lt;p:ajax event="valueChange" actionListener="disableOneMenu" /&gt; &lt;/p:selectOneMenu&gt; &lt;h:outputText value="Designation: " /&gt; &lt;p:selectOneMenu id="designatinoOneMenu" value="#{userInput.designation}" style="font-size:18;font-weight:bold;color:blue;width:100"&gt; &lt;f:selectItem itemLabel="Select One" itemValue="" /&gt; &lt;f:selectItems value="#{userInput.designationList}" /&gt; &lt;/p:selectOneMenu&gt; &lt;/h:panelGrid&gt; &lt;/p:layoutUnit&gt; &lt;/p:layout&gt; &lt;/h:form&gt; &lt;/h:body&gt; &lt;/html&gt; </code></pre> <p>Please help, hw can i use java script in xhtml page..</p> <p>Thanks..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload