Hello,
I want to develop kind of a template in JSF allowing to write (simplified):
<mylib:formField prompt=[PROMPT]>
<h:inputText id=”ID” maxlength=”15″ required=”true” />
</mylib:formField>
instead of:
<TR><TD>
<h:outputText value=”[PROMPT]” />
</TD><TD>
<h:inputText id=”ID” maxlength=”15″ required=”true” />
</TD><TD>
<h:message for=”ID” />
</TD></TR>
At first I thought that I can simply do that by developing JSP tag. I decided to use tag files for that but then I ran into problems as:
1) tag files seem not to work in my setting. Simple tag file:
<%@ attribute name=”test” required=”true” %>
Test: ${test}
produces as output “Text: ${test}” instead of replacing ${test} with variable value. I guess this is a configuration-issue but I have no idea what I’m doing wrong (I’m using JBoss 4.0.1sp1 which claims to support JSP 2.0)
2) I need to produce text: <h:message for=”ID” /> but for this I need ID. I could include it as another argument to my new tag but this would lead to redundancy (ID is in tag and then also in tag body) that I’d prefer to avoid. So I need to somehow obtain the ID from the tag’s body but I have no idea how to do that neatly…
Then I decided to try to develop new component instead of writing a custom tag. But again I run into problems because I know how to write a component that produces desired HTML code in its encode-methods but I have no idea how to write a component that just simply merges few other components into one (which is in fact what I’m aiming at).
I’d be very grateful for any suggestions/references. Thanks in advance!
Kind regards,
kosl