Using JSF form fields with jQuery – Can’t use jQuery with : (colon) problem

Using JSF form fields with jQuery – Can’t use jQuery with : (colon) problem

if you have a jsf page of the following

<h:body>
<h:form id="frmRegistration">
<h:panelGrid columns="2" rules="rows">
<h:outputLabel id="lblFirstName" value="First Name"  />
<h:inputText id="txtFirstName" value="#{memberRegisterBean.member.name}" label="First Name" required="true"/>
.
.
.

And say you want assign default value from javascript to the text box you would use:

    $("#frmRegistration:txtFirstName").val("this val");

Since that is how JSF would generate the id of the component
But, you wont see any effect as jQuery don’ like the generated colon (:).
use this instead> ‘escape it’

    $("#frmRegistration\:txtFirstName").val("this val");

See how you would solve these known algorithm problems

Changing decimal number to its binary equivalent

Check if there are three numbers a, b, c giving a total T from array A

Find K Complementary numbers from array Java implementation

Kadane’s algorithm in C – Dynamic Programming

Get maximum occurring character

Implement Queue Using two Stacks – JavaScript algorithm

Find longest palindrom from sequence of characters

Java solution for checking anagram strings – tell if phrases are anagrams

Flatten nested javascript array

String Ordered Permutation Algorithm Problem

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*