name
to <h:commandButton />
and NetBeans correctly was identifying that there is an issue with that.Fortunately, some of these attributes were passing through to the underlying page without needing
p:passthrough
. However, you should not rely on such functionality to work. If the VDL Document does not show it as an attribute, you shouldn't expect it to work.
Alright, so how do we do it correctly?
There is no magic here. It is simply a matter of adding the attribute with a prefix of
p:
, for example p:name="someName"
for the name
attribute. This will result in the attribute being passed through the rendered and added to the resulting output.So I have an example, and the resulting output.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8' ?> | |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" | |
xmlns:h="http://xmlns.jcp.org/jsf/html" | |
xmlns:p="http://xmlns.jcp.org/jsf/passthrough"> | |
<h:head> | |
<title><p:passthrough/> example</title> | |
</h:head> | |
<h:body> | |
<h:panelGroup id="panelGroup1" layout="block" | |
p:onmouseover="this.setAttribute('style', 'color: blue; font-size:32px; font-weight:bolder;');" | |
p:onmouseout="this.setAttribute('style', 'color: black; font-size:inherit; font-weight:normal;');"> | |
<h:outputText id="outputText1" value="Click me!" | |
p:data-experimental-type="Hello World!" | |
p:style="font-variant:small-caps;" | |
p:onclick="alert(this.getAttribute('data-experimental-type'));"/> | |
</h:panelGroup> | |
</h:body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version='1.0' encoding='UTF-8' ?> | |
<!DOCTYPE html> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head id="j_idt2"> | |
<title><p:passthrough/> example</title> | |
</head> | |
<body> | |
<h1><p:passthrough/> example</h1> | |
<div id="panelGroup1" | |
onmouseout="this.setAttribute('style', 'color: black; font-size:inherit; font-weight:normal;');" | |
onmouseover="this.setAttribute('style', 'color: blue; font-size:32px; font-weight:bolder;');"> | |
<span id="outputText1" onclick="alert(this.getAttribute('data-experimental-type'));" | |
data-experimental-type="Hello World!" | |
style="font-variant:small-caps;">Click me!</span> | |
</div> | |
</body> | |
</html> |
0 comments :
Post a Comment