I want to create a Tag (Source) File to get a custom tag in facelets (as described here). I want it to get used like this:
<my:inputText value="#{myBean.someString}"/>
<my:inputText inputText="#{myBean.inputText}"/>
In the first case, one could bind it to a simple String property within my bean. In the second case myBean should provide a backing bean for the input field. That backing bean contains not only the value, but also properties like maxlength, disabled, mandatory and so on.
The Tag File looks like this (simplified):
<?xml version="1.0" encoding="UTF-8"?>
<ui:fragment
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:h="http://java.sun.com/jsf/html">
<c:set var="someValue" value="#{value}"/>
<c:if test="#{empty value and not empty inputText}">
<c:set var="someValue" value="#{inputText.value}"/>
</c:if>
<h:inputText value="#{someValue}"
disabled="#{disabled or inputText.disabled}"/>
</ui:fragment>
This problem is, this is not allowed. When I enter some text in the input field, I get the following error: Illegal Syntax for Set Operation. How can I use "value" or "inputText.value" depending on whether the one or the other is specified?