• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSF with Facelets - Setting maxlength attribute probelm

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have just started working on JSF along with facelets. I have created a xhtml file that contains a <h:inputText> widget. I want to set the maxlength and size attributes of the text field. Below are the options that i have tried:

option 1


option 2


When using option 1, the text box is rendered correctly but the maxlength attribute is ignored. I cant see that in the HTML.

When using option 2, I get the following error:


Can you please help me out in setting the maxlength attribute for <h:inputText>? I dont know what am I doing wrong. Have done a lot of google on this, but for no use.

Any help would be really appreciated.

Thanks
 
Punter Java
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just one more note: Same is the case with the size attribute. It is also getting ignored in option 1 and getting the same error in option 2
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"maxlength" is the Maximum number of characters that the input control will let you type in. JSF is generating an HTML '<INPUT TYPE="TEXT" SIZE="5" MAXLENGTH="4">'.

A "size" less than "maxlength" would be meaningless, except that all "size" does is provide a hint to the browser about the physical width of the input control - when not overridden by CSS.

Since all JSF does is propagate these attributes into the generated HTML, if you can make it work with straight HTML, it should work in JSF as well. You didn't supply a "value" attribute, though, and you need to.
 
Punter Java
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This works with HTML but unfortunately not with JSF. The size attribute has the value "5" and the maxlength has the value "4". So, size is indeed greater than maxlength, and it is not getting overridden by any CSS.

I have provided value to maxlength in f:attribute tag. Please let me know if there is anything more to it.

Thanks for the post!
 
Tim Holloway
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way....

We don't have many rules here at the JavaRanch, but we do insist that you use your Real Name and not some sort of "handle" or obvious alias. If you're not sure about this, see
http://www.javaranch.com/name.jsp .
 
reply
    Bookmark Topic Watch Topic
  • New Topic