Hi Brian,
Another option (beside the resolver) would be to implement a custom ValueExpression and define it by default for the rendered attribute by creating an Application decorate overriding the various create component method. The expression implementation would check if the attributes is present, if so apply the logic, else return true. The main advantage would be that you would no longer have to specify the rendered attribute in the page, only the <f:attribute>. There would be a huge drawback though though as that value would be overridden if the rendered attribute was to be specified on the tag. Depending on your exact use cases that may or not be an issue.
Yet another way depending on JSF 2.0 would be to use system event to hook some logic on the components. Putting it simply, JSF 2.0 offers you way more option to achieve what you're trying to do. If you have only JSF 1.2, I would advise a #{bean.invokeMethod[methodName][parameter1][parameter2]...[parameterN]} syntax. It more complex to implement, but it's also way more flexible and easier to read IMHO. Furthermore, since it's a recognized syntax, the compiler won't whine and new developers will get used to it faster. To implement such syntax you must create a resolver that:
- handles the tuple base=?, property="invokeMethod" and in which case it should return an internal MethodInvoker instance (inner static class)
- handles the tuple base=MethodInvoker instance, property=?, which either return a modified MethodInvoker instance (or a new one) that include the parameter, or the method's invocation result if all parameters were already specified. This option does not allow method overload though.
Another syntax is #{bean.invokeMethod[methodName][parameterCount][parameter1][parameter2]...[parameterN]} which uses a resolver with pretty much the same logic, but that support method overload at the cost of another EL element. I implemented that last one in a project using JSF 1.2 and it works quite nicely. Of course, if you only have one method you want to make available and not something generic, defining a specialized ELResolver is perfectly acceptable and even more efficient since it has less processing to do.
Regards,
~ Simon