Author: lfryc(a)redhat.com
Date: 2010-07-10 14:09:21 -0400 (Sat, 10 Jul 2010)
New Revision: 17814
Added:
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JCommandLinkBean.properties
root/tests/metamer/trunk/src/main/webapp/resources/images/help.png
Modified:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/Attributes.java
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JCommandLinkBean.java
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml
Log:
https://jira.jboss.org/jira/browse/RFPL-466
* added attributes' help functionality
Modified: root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/Attributes.java
===================================================================
---
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/Attributes.java 2010-07-10
18:08:18 UTC (rev 17813)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/Attributes.java 2010-07-10
18:09:21 UTC (rev 17814)
@@ -27,8 +27,11 @@
import java.beans.PropertyDescriptor;
import java.util.Collection;
import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.ResourceBundle;
import java.util.Set;
import java.util.TreeMap;
@@ -52,23 +55,26 @@
private Logger logger;
private Map<String, Object> attributes;
+ private Map<String, String> helpMap;
private Set<String> excludeSet;
/**
* Constructor for class Attributes.
*
- * @param clazz
+ * @param componentClass
* class object of a JSF component whose attributes will be stored
+ * @param beanClass
+ * class object of a managed bean
*/
- public Attributes(Class<? extends UIComponentBase> clazz) {
+ public Attributes(Class<? extends UIComponentBase> componentClass,
Class<?> beanClass) {
logger = LoggerFactory.getLogger(Attributes.class);
- logger.info("creating attributes map for " + clazz);
+ logger.info("creating attributes map for " + componentClass);
PropertyDescriptor[] descriptors = null;
try {
- descriptors = Introspector.getBeanInfo(clazz).getPropertyDescriptors();
+ descriptors =
Introspector.getBeanInfo(componentClass).getPropertyDescriptors();
} catch (IntrospectionException e) {
- logger.error("Could not get a list with attributes of class" +
clazz);
+ logger.error("Could not get a list with attributes of class" +
componentClass);
attributes = Collections.emptyMap();
return;
}
@@ -84,9 +90,34 @@
}
logger.info(attributes.keySet().toString());
+
+ helpMap = loadHelp(beanClass);
}
/**
+ * Loads help for given managed bean.
+ *
+ * @param beanClass
+ * class object of a managed bean
+ * @return map where key is attribute's name and value is help for this
attribute
+ */
+ private Map<String, String> loadHelp(Class<?> beanClass) {
+ ResourceBundle rb = ResourceBundle.getBundle(beanClass.getName());
+ Enumeration<String> keys = rb.getKeys();
+ String key = null;
+ Map<String, String> result = new HashMap<String, String>();
+
+ while (keys.hasMoreElements()) {
+ key = keys.nextElement();
+ if (key.startsWith("help.")) {
+ result.put(key.replaceFirst("help.", ""),
rb.getString(key));
+ }
+ }
+
+ return result;
+ }
+
+ /**
* {@inheritDoc}
*/
public void clear() {
@@ -182,7 +213,7 @@
}
Set<String> set = new HashSet<String>();
-
+
set.add("attributes");
set.add("actionExpression");
set.add("actionListeners");
@@ -209,6 +240,30 @@
}
/**
+ * Setter for help.
+ *
+ * @param attribute
+ * name of an attribute
+ * @param help
+ * description of an attribute
+ */
+ public void setHelp(String attribute, String help) {
+ helpMap.put(attribute, help);
+ }
+
+ /**
+ * Getter for help.
+ *
+ * @param attribute
+ * name of an attribute whose help will be retrieved
+ * @return description of an attribute
+ */
+ public String getHelp(String attribute) {
+ String help = helpMap.get(attribute);
+ return help;
+ }
+
+ /**
* Determines whether given object represents an EL expression, e.g.
#{bean.property}.
*
* @param value
Modified:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JCommandLinkBean.java
===================================================================
---
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JCommandLinkBean.java 2010-07-10
18:08:18 UTC (rev 17813)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/bean/A4JCommandLinkBean.java 2010-07-10
18:09:21 UTC (rev 17814)
@@ -58,9 +58,9 @@
@PostConstruct
public void init() {
logger = LoggerFactory.getLogger(A4JCommandLinkBean.class);
- logger.debug("initializing bean");
+ logger.info("initializing bean " + getClass().getName());
- attributes = new Attributes(HtmlCommandLink.class);
+ attributes = new Attributes(HtmlCommandLink.class, getClass());
attributes.put("value", "command link");
attributes.put("rendered", "true");
@@ -68,6 +68,7 @@
attributes.put("action",
"#{a4jLinkBean.first6CharsAction}");
attributes.put("actionListener",
"#{a4jLinkBean.toUpperCaseActionListener}");
attributes.put("render", "output1 output2 output3");
+
}
/**
Added:
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JCommandLinkBean.properties
===================================================================
---
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JCommandLinkBean.properties
(rev 0)
+++
root/tests/metamer/trunk/src/main/resources/org/richfaces/testapp/bean/A4JCommandLinkBean.properties 2010-07-10
18:09:21 UTC (rev 17814)
@@ -0,0 +1,4 @@
+help.rendered=true or false
+help.disabled=true or false
+help.action=#{a4jLinkBean.first6CharsAction} #{a4jLinkBean.doubleStringAction}
#{a4jLinkBean.toUpperCaseAction}
+help.actionListener=#{a4jLinkBean.first6CharsActionListener}
#{a4jLinkBean.doubleStringActionListener} #{a4jLinkBean.toUpperCaseActionListener}
Modified: root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml
===================================================================
---
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml 2010-07-10
18:08:18 UTC (rev 17813)
+++
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml 2010-07-10
18:09:21 UTC (rev 17814)
@@ -45,14 +45,20 @@
</ui:define>
<ui:define name="outOfTemplateAfter">
- <h:panelGrid id="attributes" columns="4">
- <c:forEach items="#{a4jLinkBean.attributes}"
var="entry">
- <h:outputLabel id="#{entry.key}Label"
value="#{entry.key}" />
- <h:inputText id="#{entry.key}Input"
value="#{a4jLinkBean.attributes[entry.key]}">
- <a4j:ajax event="blur" render="panel" />
- </h:inputText>
- </c:forEach>
- </h:panelGrid>
+ <h:panelGrid id="attributes" columns="4"
style="">
+ <c:forEach items="#{a4jLinkBean.attributes}"
var="entry">
+
+ <h:outputLabel id="#{entry.key}Label"
value="#{entry.key}" />
+ <h:panelGroup layout="block">
+ <h:inputText id="#{entry.key}Input"
value="#{a4jLinkBean.attributes[entry.key]}">
+ <a4j:ajax event="blur" render="panel"
/>
+ </h:inputText>
+ <h:graphicImage value="/resources/images/help.png"
+ title="#{a4jLinkBean.attributes.getHelp(entry.key)}"
+ rendered="#{a4jLinkBean.attributes.getHelp(entry.key) !=
null}" height="28px;" style="vertical-align: middle;"/>
+ </h:panelGroup>
+ </c:forEach>
+ </h:panelGrid>
</ui:define>
</ui:composition>
Added: root/tests/metamer/trunk/src/main/webapp/resources/images/help.png
===================================================================
--- root/tests/metamer/trunk/src/main/webapp/resources/images/help.png
(rev 0)
+++ root/tests/metamer/trunk/src/main/webapp/resources/images/help.png 2010-07-10 18:09:21
UTC (rev 17814)
@@ -0,0 +1,16 @@
+�PNG
+
+
+��p��f$�"�$ -//��ܹ3y���Q]�c�9��B��JQ���k�����MIT�|��˗/�������|>O&�e�
��"hs����毭�- ��D"�3lm����3�!,�#J���p�©���v�j��?�����.�\JR&����J�^ר�O��=w�� �`��=��Ś����`6�������?q�ܹ���2��?��q��-K}u���#`k=��x�#
V?sئ䓎�{C����Z�K'�Ӊ�W��������m�,��!,
+�gq9{�lwkk�H������������V�a?��6�x.�U!oe�%�GP��x9�!d�٬����^�qJ�'C�&ֈD Ax�@����ݧ(
+��K���[MG�h��+�U���$��_�\2�j�4�c#���~����ltvv6��χ9��M��r�(c��z�^����"c�R5�%"�f>)���}(Pm���UU���A`��� �dȨ[Ζ��J/�F����nJD6$>~EƇ ��}a�x�y9��)����O:���:�V+�H��TdS ��w�������E������f�My2fmm
+�
+���6J��d
+�n0���k��/���f.>;�[�2�_3�p���I�1Hh� ����Y�^��/����IU�Oxt|�'0�C_K�62�����p0�^O$GFF��P�Y���\>t*m�{ӎ'b`���>���X����h�ʃ�C�E��������4666�v����ʾp�b�{&�-��"
@�m���C��<�z���`lQ����5E�ċ^$3Mj����655����*�����Tr�m�5��g�YŬ�tA�/���i����fff ��G�ݿr�ʏ�V�ʁKIN>�< ��A��|
+�B佮�a p�ڵk?��a�S�PR�́�H
+�qog_$!ǟ())A.��dQ|�Ú��$,��]�Ӫ[�b}}������������j/�D*�J����thxx8�w��0J�
+�h]�[#:O�?o�A<3q�(*�3e��X~IQC�:����k������m��C,�y���%\�K���~D��5
+0
\ No newline at end of file