[
https://issues.jboss.org/browse/RF-12201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12692720#comment-12692720
]
Lukáš Fryč commented on RF-12201:
---------------------------------
Hey Paul, I would actually split that into several issues, but let's go through
them one by one:
For *1)* and *2)* could be simply covered by extending the
{{[RendererKitUtils|https://github.com/richfaces/components/blob/develop/common/ui/src/main/java/org/richfaces/renderkit/RenderKitUtils.java]}}
- all the static methods in this class are statically imported to each
generated renderer.
Then you could have
{code}
<c:when test="#{hasAttribute(component, 'brand')}">
{code}
----
For *3)* it would be actually really nice if the #{component} could be
auto-castable (cast will be provided automatically on start of the
encodeBegin/encodeEnd.
I will create new issue and comment on related one: RF-11668
----
For *4)*, I think this needs to be fixed - it should automatically call
{{is*()}} variant {{boolean}} and {{Boolean}} methods.
> 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
> Labels: cdk, method, richfaces
>
> 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
_______________________________________________
richfaces-issues mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/richfaces-issues