Forums de discussion

Validations for AUI Select, Radio and CheckBoxes..

thumbnail
Balakrishna Mahamkali, modifié il y a 9 années.

Validations for AUI Select, Radio and CheckBoxes..

New Member Publications: 24 Date d'inscription: 19/12/13 Publications récentes
Hi all,

I am able to do validations for AUI Input Fileds, but i am failing in Validate the AUI Select, Radio and Check Boxes in a form.
Test code:
//working code for input fields
<aui:input name="name" id="name" label="Topic Name" > >
<aui:validator name="required" errorMessage="Name is required"/>
<aui:validator name="alphanum" />
<aui:validator name="minLength">5</aui:validator>
<aui:validator name="maxLength">70</aui:validator>
</aui:input>
//not working
<aui:select id="parentId" name="parentId" label="Parent Id" >
<aui:option value="0" label="Select Parent Topic" />
<aui:option value=" 2" label=""abc" />
<aui:option value="1" label="zxc" />

<aui:validator name="custom" errorMessage="Please Select Topic Parent" >
function (val, fieldNode, ruleValue) {
var result = false;
var selectedVal = A.one('#<portlet:namespace/>parentId').val();
alert(selectedVal);
if (selectedVal == 0) {

result = false;
}
return result;
}
</aui:validator>
</aui:select></p>

when i use that AUI:validator for Select tags i am getting error like following:
org.apache.catalina.core.ApplicationDispatcher invoke
SEVERE: Servlet.service() for servlet topicDetail Servlet threw exception
java.lang.NullPointerException
at com.liferay.taglib.aui.ValidatorTagImpl.doEndTag(ValidatorTagImpl.java:82)
at org.apache.jsp.TopicsPortlet.topicDetail_jsp._jspx_meth_aui_005fvalidator_005f0(ABC_jsp.java:779)
at org.apache.jsp.TopicsPortlet.topicDetail_jsp._jspx_meth_aui_005fselect_005f0(ABC_jsp.java:637)
at org.apache.jsp.TopicsPortlet.topicDetail_jsp._jspx_meth_aui_005ffieldset_005f0(ABC_jsp.java:561)

Pls Let me any solution, its urgent..
Pls share working code..


Thanks In Advance:
thumbnail
Manali Lalaji, modifié il y a 9 années.

RE: Validations for AUI Select, Radio and CheckBoxes..

Expert Publications: 362 Date d'inscription: 09/03/10 Publications récentes
Hi,

Can you try below code for aui:select ? You can customize code according to your requirements.

<aui:form action="/abc" method="post" name="form">
           <aui:select label="" id="SimpleTermDropDown" name="SimpleTermDropDown">
                           <aui:option selected="true" value=""><liferay-ui:message key="Choose a Data Type" /></aui:option>
                          <aui:option value="integer"><liferay-ui:message key="Integer" /></aui:option>
                            <aui:option value="long"><liferay-ui:message key="Long" /></aui:option>
                           <aui:option value="string"><liferay-ui:message key="String" /></aui:option>
           </aui:select>
           <br><br><aui:button cssclass="save" value="Save" type="Submit"></aui:button>
 </aui:form>
 
<script type="text/javascript" charset="utf-8">
 AUI().ready('alloy-node','aui-form-validator', function(A) {
    
     validator2 = new A.FormValidator({
        boundingBox: document.<portlet:namespace/>form,
        rules: {     
              <portlet:namespace />SimpleTermDropDown: {
                  required: true
             }
        },
       fieldStrings: {
             <portlet:namespace />SimpleTermDropDown: {
                required: 'Select dropdown value'
             }
         },
       on: {
             validateField: function(event) {
            },
            validField: function(event) {
            },
            errorField: function(event) {
            },
             submitError: function(event) {
                var formEvent = event.validator.formEvent;
                var errors = event.validator.errors;
                 event.preventDefault();
             },
             submit: function(event) {
                     var formEvent = event.validator.formEvent;
                    return false;
             }
         }
   });
 });
 
</script>



HTH!
thumbnail
Balakrishna Mahamkali, modifié il y a 9 années.

RE: Validations for AUI Select, Radio and CheckBoxes..

New Member Publications: 24 Date d'inscription: 19/12/13 Publications récentes
Thank So much Manali .. i did the same thing but i missed to take <portlet:namespace> any way thanks again:
and one Quick Question do u have any working experience on Solr and Liferay Integartion. we are using liferay tomcat ce GA3 (6.1.2)..
thumbnail
Manali Lalaji, modifié il y a 9 années.

RE: Validations for AUI Select, Radio and CheckBoxes..

Expert Publications: 362 Date d'inscription: 09/03/10 Publications récentes
Hi,

You can search out several links available for Solr Integration with Liferay. Refer link1, link2

HTH!