uncle bob
uncle bob

Reputation: 680

What is different between Attribute and PassthroughtAttribute in JSF/Primefaces

I'm using Primefaces 5.3, some cases i need to add a custom attribute to UIComponent (like p:inputText or p:inputTextArea),

I see in UIComponent we have two maps are Attributes and PassthroughtAttributes, so i used both then see with PassthroughtAttribute could have me to reduce page load time (because those kind of attributes will be not rendered on HTML).

Beside of this different, is there any other things i should know?

Thanks all

Upvotes: 1

Views: 188

Answers (1)

jklee
jklee

Reputation: 2268

Normal attributes are inputs for JSF Components, for example for the data binding.

Passthrough attributes are new with JSF 2.2. For this a new namespace was introduced xmlns:pt="http://xmlns.jcp.org/jsf/passthrough". These are not changed on the server side, but are directly rendered. So you can directly use HTML5 functions.

<h:inputText id="email" value="#{userBean.email}" pt:type="email" pt:placeholder="Enter email"/>

value is a normal attribute, processing by the server side.

pt:type and pt:placeholder are ignored by the server side and rendered directly as HTML.

Output:

<input id="form:email" name="form:email" value="" placeholder="Enter email" type="email" />

Upvotes: 1

Related Questions