jsf - How to specify name attribute in h:inputText? -


i need render h:inputtext following html output :

  <input id="yourname" type="text" name="name" />   <input id="email" type="text" name="email" /> 

but h:inputtext renders name attribute same client id of component. want specify name attribute myself, instead of putting client id in that, input field can show meaningful autocomplete suggestions submitted values same field type on other sites. e.g. when use name="email" input field email, user shown suggestions of emails ids submitted on other websites.

you can't achieve using <h:inputtext>. name autogenerated jsf based on client id (which in turn based on component id , of naming container parents).

you've 2 options achieve concrete functional requirement anyway:

  1. if there no other naming container parents, instruct parent form not prepend id:

    <h:form prependid="false"> 

    this cause <f:ajax> fail.

  2. use plain html elements instead of jsf components:

    <input name="name" value="#{bean.name}" /> <input name="email" value="#{bean.email}" /> 

    you have collect them via @managedproperty on request scoped bean:

    @managedproperty("#{param.name}") private string name;  @managedproperty("#{param.email}") private string email; 

    and you'll miss jsf builtin validation/conversion facility , ajax magic.

there's different alternative: use html5 <input type="email">. way browser autosuggest entered emails on inputs of same type. not natively supported <h:inputtext>. can use custom render kit work, answered in adding custom attribute (html5) support primefaces (3.4):

<h:inputtext type="email" ... /> 

update of jsf 2.2 can declare passthrough attributes without needing custom render kit.

<... xmlns:a="http://xmlns.jcp.org/jsf/passthrough"> ... <h:inputtext a:type="email" ... /> 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -