Reputation: 36220
I am using Seam tag <s:decorate>
, it has a enclose
attribute. By default it is set to true
(You can see it in the HtmlDecorate
class).
In my application all the tags should not be enclosed, so the attribute should be set to false
on each tag. But to do specify it on each tag is not very beautiful solution.
I would like to change the default enclose = true
to false
in one place. Is it possible through injection or somehow else?
Upvotes: 3
Views: 217
Reputation: 4844
The only way I found is overriding Seam's decorate
component with yours. While it sounds complicated, it is relatively simple to accomplish, and is better than having to write enclose="false"
in every <s:decorate/>
. This solution relies on the fact that component definitions located in your project's faces-config.xml
take priority over the definitions located in the faces-config.xml
files located inside library jars.
Create your custom component class that extends HtmlDecorate
:
public class MyDecorate extends HtmlDecorate {
// Default value is false, as opposed to HtmlDecorate
private boolean _myenclose = false;
// Default constructor
public MyDecorate() {
super();
}
// Override setEnclose() and isEnclose() so that they use your variable
public boolean isEnclose() {
return _myenclose;
}
public void setEnclose(boolean enclose) {
this._myenclose = enclose;
}
}
Declare your class as the class for the decorate component, in your faces-config.xml
(note that we specify your custom component class in the <component-class />
tag, while using the usual Seam renderer):
<component>
<description>"Decorate" a JSF input field when validation fails or when required="true" is set.</description>
<component-type>org.jboss.seam.ui.Decorate</component-type>
<component-class>com.example.myapp.MyComponent</component-class>
<component-extension>
<component-family>org.jboss.seam.ui.Decorate</component-family>
<renderer-type>org.jboss.seam.ui.DecorateRenderer</renderer-type>
</component-extension>
</component>
Use the <s:decorate/>
tag as usual in your pages:
<s:decorate template="...">
....
</s:decorate>
Upvotes: 4