Author: lfryc(a)redhat.com
Date: 2010-07-10 14:10:54 -0400 (Sat, 10 Jul 2010)
New Revision: 17816
Added:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/TemplateNameConverter.java
Modified:
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml
root/tests/metamer/trunk/src/main/webapp/templates/template.xhtml
Log:
https://jira.jboss.org/jira/browse/RFPL-466
* added bookmarking
Added:
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/TemplateNameConverter.java
===================================================================
---
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/TemplateNameConverter.java
(rev 0)
+++
root/tests/metamer/trunk/src/main/java/org/richfaces/testapp/TemplateNameConverter.java 2010-07-10
18:10:54 UTC (rev 17816)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+
+package org.richfaces.testapp;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.FacesConverter;
+
+/**
+ * Converter used for view parameter "template".
+ *
+ * @author <a href="mailto:ppitonak@redhat.com">Pavol Pitonak</a>
+ * @version $Revision$
+ */
+@FacesConverter(value = "templateNameConverter")
+public class TemplateNameConverter implements Converter {
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAsObject(FacesContext context, UIComponent component, String value)
{
+ try {
+ return Template.valueOf(value.toUpperCase());
+ } catch (IllegalArgumentException iae) {
+ throw new FacesException("Cannot convert parameter \"" + value
+ "\" to the name of template.", iae);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getAsString(FacesContext context, UIComponent component, Object value)
{
+ if (value instanceof String) {
+ return (String) value;
+ }
+
+ if (value instanceof Template) {
+ return ((Template) value).toString();
+ }
+
+ throw new FacesException("Cannot convert parameter \"" + value +
"\" to the name of template.");
+ }
+}
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:10:10 UTC (rev 17815)
+++
root/tests/metamer/trunk/src/main/webapp/components/a4jCommandLink/simple.xhtml 2010-07-10
18:10:54 UTC (rev 17816)
@@ -5,6 +5,14 @@
<ui:composition template="#{templateBean.template}">
+ <ui:define name="viewParams">
+ <f:metadata>
+ <f:viewParam name="template"
value="#{templateBean.templateId}">
+ <f:converter converterId="templateNameConverter" />
+ </f:viewParam>
+ </f:metadata>
+ </ui:define>
+
<ui:define name="outOfTemplateBefore">
</ui:define>
@@ -33,7 +41,7 @@
style="#{a4jLinkBean.attributes['style']}"
styleClass="#{a4jLinkBean.attributes['styleClass']}"
tabindex="#{a4jLinkBean.attributes['tabindex']}"
target="#{a4jLinkBean.attributes['target']}"
title="#{a4jLinkBean.attributes['title']}"
type="#{a4jLinkBean.attributes['type']}"
- value="#{a4jLinkBean.attributes['value']}"
execute="@form"/>
+ value="#{a4jLinkBean.attributes['value']}"
execute="@form" />
</h:panelGrid>
@@ -55,7 +63,8 @@
</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;"/>
+ rendered="#{a4jLinkBean.attributes.getHelp(entry.key) !=
null}" height="28px;"
+ style="vertical-align: middle;" />
</h:panelGroup>
</c:forEach>
</h:panelGrid>
Modified: root/tests/metamer/trunk/src/main/webapp/templates/template.xhtml
===================================================================
--- root/tests/metamer/trunk/src/main/webapp/templates/template.xhtml 2010-07-10 18:10:10
UTC (rev 17815)
+++ root/tests/metamer/trunk/src/main/webapp/templates/template.xhtml 2010-07-10 18:10:54
UTC (rev 17816)
@@ -7,6 +7,9 @@
<title><ui:insert name="pageTitle">Testing
Application</ui:insert></title>
<meta http-equiv="Content-Type" content="text/xhtml;
charset=UTF-8" />
<!-- <h:outputStylesheet library="css" name="common.css"
/>-->
+ <ui:insert name="viewParams">
+
+ </ui:insert>
</h:head>
<h:body>
@@ -28,7 +31,7 @@
</div>
<h:panelGroup id="a4jLogPanel" layout="block">
- <a4j:log id="a4jLog" height="300px"
rendered="#{richBean.log}"/>
+ <a4j:log id="a4jLog" height="300px"
rendered="#{richBean.log}" />
</h:panelGroup>
<div id="footer"><ui:insert name="footer">