[richfaces-issues] [JBoss JIRA] (RF-12201) Add common method to all generated CDK component
Paul Dijou (JIRA)
jira-events at lists.jboss.org
Thu Apr 26 09:11:18 EDT 2012
Paul Dijou created RF-12201:
-------------------------------
Summary: Add common method to all generated CDK component
Key: RF-12201
URL: https://issues.jboss.org/browse/RF-12201
Project: RichFaces
Issue Type: Enhancement
Security Level: Public (Everyone can see)
Components: cdk
Affects Versions: 4.2.1.Final
Environment: All
Reporter: Paul Dijou
Looking at CDK AbstractComponent, or RendererBase or template.xml, I find lot of code copy/paste again and again. Maybe it could be usefull to have some common methods automatically generated by the CDK. I have some ideas right now, but I guess it will increase with time.
Sometime, I call the method in the "component" var inside the template. Maybe it would not be possible since we can only add methods to the "AbstractComponent". I'm fine with having them there and casting the component at the beginning of the template using {{<cdk:object>}}.
h3. 1) Test if an attribute is present :
{code:xml}
<c:when test="#{component.attributes['brand']!= null and not component.attributes['brand'].equals('')}">
{code}
Can become :
{code:xml}
<c:when test="#{component.hasAttribute('brand')}">
{code}
{code:java}
public boolean hasAttribute(String attributeName) {
// TODO : test if the attribute is present
}
{code}
h3. 2) Test if a facet is present
Same as before but about JSF facets
{code:xml}
<c:when test="#{component.getFacet('brand') != null and component.getFacet('brand').rendered}">
{code}
Become
{code:xml}
<c:when test="#{component.hasFacet('brand')}">
{code}
{code:java}
public boolean hasFacet(String facetName) {
// TODO : test if the facet is present and rendered
}
{code}
h3. 3) The castComponent method
This one is present in like 9 out of 10 AbstractComponent in the Bootstrap sandbox. I don't know how [RF-11668|https://issues.jboss.org/browse/RF-11668] will be resolved. But if we still need to cast the component, having the method in every component by default would be really nice.
h3. 4) Generate both "get..." and "is..." method for Boolean and boolean attributes
If you have an attribute like :
{code:java}
@Attribute
abstract public boolean isClosable();
{code}
This will generate a "isClosable()" method of course. But, then, trying to access it in a template like :
{code:xml}
<c:if test="#{alert.closable}">
{code}
Will crash since JSF try to call the "getClosable()" method. The workaround is to write :
{code:xml}
<c:if test="#{alert.isClosable()}">
{code}
But it would be nicer if the "geClosable()" method was generated in the same time of the "isClosable()" method.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the richfaces-issues
mailing list