1

I'm trying to use jQuery UI Datepicker. In same JSF page, it works on HTML <input> tag, but not on JSF <h:inputText> tag.

<div class="form-group">
    <h:inputText id="mask-date" class="form-control mask" />
    <input type="text" class="form-control mask" id="mask-date"/>
    <span class="help-block blue">mm/dd/yyyy</span>
</div>

How is this caused and how can I solve it?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
BlackBird
  • 76
  • 6
  • Code snippets are for providing runnable demo's using HTML/CSS/JS. it'll not interpret your jsf tags. I converted them to normal code blocks. That being said, please don't dump the source of entire libraries and plugins in question. Instead provide a link to their documentation, or tag it in question if a tag is available.. – T J Dec 15 '14 at 15:42

2 Answers2

0

In most cases JSF tags not pure HTML tags but constructed from multiple HTML tags, for example

<div id="input> 
<input ... />
</div>

And id of JSF tag not pointing to <input> tag but to outer <div>. You should view your outcome page code in HTML and correct your selector accordingly.

Anatoly
  • 5,056
  • 9
  • 62
  • 136
0

Your problem is here:

<h:inputText ... class="form-control mask" />

The class attribute isn't supported on <h:inputText>. Instead, it's named styleClass.

<h:inputText ... styleClass="form-control mask" />

This is true for all other JSF components. You should also have noticed the absence of the class attribute in the JSF-generated HTML <input> element when taking the effort to do rightclick and View Source in webbrowser.

The attribute name is different from the HTML counterpart, because class is a reserved keyword in Java and therefore it isn't possible to have a private String class; field in the UI component class.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks for giving your valuable time.Actually I am new to JSF and I don't know the future scope of JSF , I have heard that it is an old framework. Is it true? – BlackBird Jan 09 '15 at 08:26
  • JSF is indeed an old framework. It exist almost a decade. But you're actually not working with decade-old codebase ;) Mojarra has a new release at least once a month. The JSF spec also keeps evolving and improving. See also http://stackoverflow.com/questions/3623911/what-are-the-main-disadvantages-of-java-server-faces-2-0. And as a starter looking for valuable resources you may find https://jsf.zeef.com helpful. – BalusC Jan 09 '15 at 08:31