I created a Facelet component to extend h:commandLink (to add some functionality and rounded corners).
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<span class="btn-left btn-corners"> </span>
<span type="submit" class="submit">
<h:commandLink id="#{id}" value="#{label}" action="#{action}" />
</span>
<span class="btn-right btn-corners"> </span> </ui:composition>
My new component can be accessed using
<my:commandLink id="continue" label="continue" action="#{applyBacking.submit}"/>
and the Java code is
public String submit(){
...
}
However it gives me an error “ApplyBacking does not have the property submit”.
I understand the reason for this error because while rendering my:commandLink, it tries to evaluate #{applyBacking.submit} to a property. Instead, I want the info about the method to the invoked (applyBacking.submit) to be passed to the template and evaluated while rendering h:commandLink.
Any suggestions?
Create a composite component instead (tutorial here), it enables you to define bean actions as attribtues.
Here’s a kickoff example:
/resources/components/commandLink.xhtml/somepage.xhtmlBy the way, I would personally prefer using JS/jQuery for the rounded corners part, for example the jQuery corner plugin. Just give your commandlink a specific
styleClassand let JS do the magic.