JBoss Rich Faces SVN: r3386 - in branches/3.1.x: samples/jQuery-sample/src/main/webapp and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-10-15 18:11:20 -0400 (Mon, 15 Oct 2007)
New Revision: 3386
Modified:
branches/3.1.x/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
branches/3.1.x/samples/jQuery-sample/src/main/webapp/jQuery.xhtml
Log:
jQuery escapement for : in id selectors added
sample switched to h:form
Modified: branches/3.1.x/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
===================================================================
--- branches/3.1.x/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15 21:57:50 UTC (rev 3385)
+++ branches/3.1.x/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15 22:11:20 UTC (rev 3386)
@@ -70,7 +70,7 @@
if (target != null) {
matcher.appendReplacement(sb, "#"
- + target.getClientId(context));
+ + target.getClientId(context).replaceAll(":", "\\\\\\\\\\\\\\\\:"));
}
}
}
Modified: branches/3.1.x/samples/jQuery-sample/src/main/webapp/jQuery.xhtml
===================================================================
--- branches/3.1.x/samples/jQuery-sample/src/main/webapp/jQuery.xhtml 2007-10-15 21:57:50 UTC (rev 3385)
+++ branches/3.1.x/samples/jQuery-sample/src/main/webapp/jQuery.xhtml 2007-10-15 22:11:20 UTC (rev 3386)
@@ -10,7 +10,7 @@
<f:view contentType="text/html" >
<body>
- <form id="form">
+ <h:form id="form">
<h:panelGrid id="menu" columns="1">
<h:graphicImage value="http://images.businessweek.com/tc/reviews/icons/game_50x50.gif" />
@@ -25,7 +25,7 @@
<rich:jQuery selector="#menu img" timing="onload" query="mouseover(function(){makeFat(this,{ewidth:'120px'});})" />
<rich:jQuery selector="#menu img" timing="onload" query="mouseout(function(){makeThin(this);})" />
- </form>
+ </h:form>
</body>
</f:view>
</html>
17 years, 2 months
JBoss Rich Faces SVN: r3385 - trunk/samples/jQuery-sample/src/main/webapp.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-10-15 17:57:50 -0400 (Mon, 15 Oct 2007)
New Revision: 3385
Modified:
trunk/samples/jQuery-sample/src/main/webapp/jQuery.xhtml
Log:
jQuery escapement for : in id selectors added
sample switched to h:form
Modified: trunk/samples/jQuery-sample/src/main/webapp/jQuery.xhtml
===================================================================
--- trunk/samples/jQuery-sample/src/main/webapp/jQuery.xhtml 2007-10-15 21:57:47 UTC (rev 3384)
+++ trunk/samples/jQuery-sample/src/main/webapp/jQuery.xhtml 2007-10-15 21:57:50 UTC (rev 3385)
@@ -10,7 +10,7 @@
<f:view contentType="text/html" >
<body>
- <form id="form">
+ <h:form id="form">
<h:panelGrid id="menu" columns="1">
<h:graphicImage value="http://images.businessweek.com/tc/reviews/icons/game_50x50.gif" />
@@ -25,7 +25,7 @@
<rich:jQuery selector="#menu img" timing="onload" query="mouseover(function(){makeFat(this,{ewidth:'120px'});})" />
<rich:jQuery selector="#menu img" timing="onload" query="mouseout(function(){makeThin(this);})" />
- </form>
+ </h:form>
</body>
</f:view>
</html>
17 years, 2 months
JBoss Rich Faces SVN: r3384 - trunk/framework/impl/src/main/java/org/richfaces/component/util.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-10-15 17:57:47 -0400 (Mon, 15 Oct 2007)
New Revision: 3384
Modified:
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
Log:
jQuery escapement for : in id selectors added
sample switched to h:form
Modified: trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15 18:28:03 UTC (rev 3383)
+++ trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15 21:57:47 UTC (rev 3384)
@@ -70,7 +70,7 @@
if (target != null) {
matcher.appendReplacement(sb, "#"
- + target.getClientId(context));
+ + target.getClientId(context).replaceAll(":", "\\\\\\\\\\\\\\\\:"));
}
}
}
17 years, 2 months
JBoss Rich Faces SVN: r3383 - trunk/ui/tabPanel/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-10-15 14:28:03 -0400 (Mon, 15 Oct 2007)
New Revision: 3383
Modified:
trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java
Log:
queue ActionEvent for UITab
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java 2007-10-15 18:11:13 UTC (rev 3382)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java 2007-10-15 18:28:03 UTC (rev 3383)
@@ -237,7 +237,7 @@
public void queueEvent(FacesEvent event) {
- if(event instanceof ActionEvent && this.equals(event.getComponent())){
+ if(event instanceof ActionEvent && event.getComponent()instanceof UITab){
if(isImmediate()){
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
17 years, 2 months
JBoss Rich Faces SVN: r3382 - trunk/ui/tabPanel/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-10-15 14:11:13 -0400 (Mon, 15 Oct 2007)
New Revision: 3382
Modified:
trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java
Log:
RF-258
Modified: trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java
===================================================================
--- trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java 2007-10-15 17:11:22 UTC (rev 3381)
+++ trunk/ui/tabPanel/src/main/java/org/richfaces/component/UITabPanel.java 2007-10-15 18:11:13 UTC (rev 3382)
@@ -33,14 +33,13 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.iterators.FilterIterator;
-import org.richfaces.event.SwitchablePanelSwitchEvent;
/**
* JSF component class
*/
public abstract class UITabPanel extends UISwitchablePanel {
public static final String COMPONENT_TYPE = "org.richfaces.TabPanel";
-
+
public boolean getRendersChildren() {
return true;
}
@@ -60,6 +59,21 @@
});
}
+ public boolean isImmediate() {
+
+ if(!super.isImmediate()){
+ UITab tab = getTabWithName(getValue());
+ if(tab != null){
+ if(tab.isImmediate()){
+ return true;
+ }
+ }
+ return false;
+ }else{
+ return super.isImmediate();
+ }
+ }
+
public Object convertSwitchValue(UIComponent component, Object object) {
if (object != null) {
return object;
@@ -132,11 +146,11 @@
Object[] state = new Object[2];
state[0] = super.saveState(context);
state[1] = renderedValue;
-
+
return state;
}
- public UITab getTabWithName(Object tabName){
+ private UITab getTabWithName(Object tabName){
List children = getChildren();
for (Iterator iterator = children.iterator(); iterator.hasNext();) {
@@ -223,37 +237,17 @@
public void queueEvent(FacesEvent event) {
- FacesEvent processedEvent = event;
+ if(event instanceof ActionEvent && this.equals(event.getComponent())){
+
+ if(isImmediate()){
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ }else{
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+
+ }
- if (event instanceof SwitchablePanelSwitchEvent && this.equals(event.getComponent())) {
- SwitchablePanelSwitchEvent switchEvent = (SwitchablePanelSwitchEvent) event;
- UIComponent component = switchEvent.getEventSource();
- UITab savedTab = getTabWithName(getValue());
- if(savedTab != null){
- if((component instanceof UITab) && ((UITab)savedTab).isImmediate() || isImmediate()){
- setImmediate(true);
- }else{
- setImmediate(false);
- }
- }
- }
- // redefine phaseId of ActionEvent RF-843
- if(event instanceof ActionEvent ){
- UIComponent component = event.getComponent();
- UITab savedTab = getTabWithName(getValue());
- if(savedTab != null){
- if((component instanceof UITab) && ((UITab)savedTab).isImmediate() || isImmediate()){
- setImmediate(true);
- processedEvent.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- }else{
- setImmediate(false);
- processedEvent.setPhaseId(PhaseId.INVOKE_APPLICATION);
- }
- }
- }
-
- super.queueEvent(processedEvent);
+ super.queueEvent(event);
}
-
-
+
}
17 years, 2 months
JBoss Rich Faces SVN: r3381 - in branches/3.1.x: framework/test/src/test/java/org/richfaces/component/util and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-10-15 13:11:22 -0400 (Mon, 15 Oct 2007)
New Revision: 3381
Modified:
branches/3.1.x/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
branches/3.1.x/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
branches/3.1.x/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java
branches/3.1.x/ui/jQuery/src/main/templates/jQuery.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1096
merged from trunk
Modified: branches/3.1.x/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
===================================================================
--- branches/3.1.x/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15 17:11:02 UTC (rev 3380)
+++ branches/3.1.x/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15 17:11:22 UTC (rev 3381)
@@ -21,11 +21,16 @@
package org.richfaces.component.util;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
import org.ajax4jsf.util.HtmlDimensions;
/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 09.02.2007
+ * @author Nick Belaevski - nbelaevski(a)exadel.com created 09.02.2007
*
*/
public class HtmlUtil {
@@ -40,12 +45,39 @@
return sizeDeclaration;
}
-
+
public static String addToSize(String declaration, String delta) {
Double doubleDelta = HtmlDimensions.decode(delta);
Double decoded = HtmlDimensions.decode(declaration);
-
- return HtmlDimensions.formatPx(
- new Double(decoded.doubleValue() + doubleDelta.doubleValue()));
+
+ return HtmlDimensions.formatPx(new Double(decoded.doubleValue()
+ + doubleDelta.doubleValue()));
}
+
+ public static final Pattern idSelectorPattern = Pattern
+ .compile("#((:|_|[a-z,A-Z])[a-z,A-Z,0-9,_,-,:]+)");
+
+ public static String expandIdSelector(String selector,
+ UIComponent component, FacesContext context) {
+ Matcher matcher = idSelectorPattern.matcher(selector);
+ StringBuffer sb = new StringBuffer();
+
+ while (matcher.find()) {
+ if (matcher.group(1).indexOf("::") == -1) {
+ // make new id selector here using matcher.group(1)
+
+ UIComponent target = component.findComponent(matcher.group(1));
+
+ if (target != null) {
+ matcher.appendReplacement(sb, "#"
+ + target.getClientId(context));
+ }
+ }
+ }
+ matcher.appendTail(sb);
+ String result = sb.toString();
+ if (result.length() == 0)
+ result = selector;
+ return sb.toString();
+ }
}
Modified: branches/3.1.x/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
===================================================================
--- branches/3.1.x/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2007-10-15 17:11:02 UTC (rev 3380)
+++ branches/3.1.x/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2007-10-15 17:11:22 UTC (rev 3381)
@@ -21,6 +21,14 @@
package org.richfaces.component.util;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIInput;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
import junit.framework.TestCase;
/**
@@ -29,6 +37,19 @@
*
*/
public class HtmlUtilTest extends TestCase {
+
+ public HtmlUtilTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
public void testQualifySize() throws Exception {
assertEquals("", HtmlUtil.qualifySize(""));
@@ -48,4 +69,48 @@
assertEquals("120px", HtmlUtil.addToSize("100", "20"));
assertEquals("120px", HtmlUtil.addToSize("100px", "20px"));
}
+
+ public void testExpandIdSelector() {
+ String selector = ".class_form+#:Test .class2 #_1aaaa:";
+
+ UIComponent component = new UIComponentBase() {
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public UIComponent findComponent(String expr) {
+ if (":Test".equals(expr)) {
+ return new UIComponentBase() {
+ public String getClientId(FacesContext context) {
+ return "component1";
+ }
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ } else if ("_1aaaa:".equals(expr)) {
+ return new UIComponentBase() {
+ public String getClientId(FacesContext context) {
+ return "component2";
+ }
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ }
+
+ return null;
+ }
+ };
+
+ String string =
+ HtmlUtil.expandIdSelector(selector, component, null);
+
+ assertEquals(".class_form+#component1 .class2 #component2", string);
+
+ String s = ".class_form+.component1 .class2 #1component2";
+ assertEquals(s, HtmlUtil.expandIdSelector(s, component, null));
+ }
}
Modified: branches/3.1.x/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java
===================================================================
--- branches/3.1.x/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java 2007-10-15 17:11:02 UTC (rev 3380)
+++ branches/3.1.x/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java 2007-10-15 17:11:22 UTC (rev 3381)
@@ -10,6 +10,7 @@
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.UIJQuery;
+import org.richfaces.component.util.HtmlUtil;
public class JQueryRendererBase extends HeaderResourcesRendererBase {
@@ -47,8 +48,8 @@
}
}
- protected String replaceClientIds(String selector) {
- return selector;
+ protected String replaceClientIds(FacesContext context, UIComponent component, String selector) {
+ return HtmlUtil.expandIdSelector(selector, component, context);
}
Modified: branches/3.1.x/ui/jQuery/src/main/templates/jQuery.jspx
===================================================================
--- branches/3.1.x/ui/jQuery/src/main/templates/jQuery.jspx 2007-10-15 17:11:02 UTC (rev 3380)
+++ branches/3.1.x/ui/jQuery/src/main/templates/jQuery.jspx 2007-10-15 17:11:22 UTC (rev 3381)
@@ -26,7 +26,7 @@
String selector = (String) variables.getVariable("selector");
checkValidity(clientId, name, timing, query);
- variables.setVariable("selector", replaceClientIds(selector));
+ variables.setVariable("selector", replaceClientIds(context, component, selector));
]]>
</jsp:scriptlet>
17 years, 2 months
JBoss Rich Faces SVN: r3380 - in trunk/docs/userguide: en/src/main/docbook and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: vkorluzhenko
Date: 2007-10-15 13:11:02 -0400 (Mon, 15 Oct 2007)
New Revision: 3380
Added:
trunk/docs/userguide/en/src/main/docbook/included/jQuery.desc.xml
trunk/docs/userguide/en/src/main/docbook/included/jQuery.xml
Modified:
trunk/docs/userguide/en/src/main/docbook/master.xml
trunk/docs/userguide/pom.xml
Log:
http://jira.jboss.com/jira/browse/RF-1123 - jQuery was added into the build process.
Added: trunk/docs/userguide/en/src/main/docbook/included/jQuery.desc.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/jQuery.desc.xml (rev 0)
+++ trunk/docs/userguide/en/src/main/docbook/included/jQuery.desc.xml 2007-10-15 17:11:02 UTC (rev 3380)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<section>
+ <sectioninfo>
+ <keywordset>
+ <keyword>jQuery</keyword>
+ </keywordset>
+ </sectioninfo>
+ <section>
+ <title>Description</title>
+
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/jQuery.png"/>
+ </imageobject>
+ </mediaobject>
+ </section>
+ <section>
+ <title>Key Features</title>
+ <!--itemizedlist>
+ <listitem>Highly customizable look and feel</listitem>
+ <listitem>Popup representation</listitem>
+ <listitem>Disablement support</listitem>
+ <listitem>Smart and user-defined positioning</listitem>
+ <listitem>Cells customization</listitem>
+ <listitem>Macro substitution based on tool bars customization</listitem>
+ </itemizedlist-->
+ </section>
+</section>
Added: trunk/docs/userguide/en/src/main/docbook/included/jQuery.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/included/jQuery.xml (rev 0)
+++ trunk/docs/userguide/en/src/main/docbook/included/jQuery.xml 2007-10-15 17:11:02 UTC (rev 3380)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<section>
+ <sectioninfo>
+ <keywordset>
+ <keyword>jQuery</keyword>
+ </keywordset>
+ </sectioninfo>
+
+ <table>
+ <title>Component identification parameters</title>
+
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Name</entry>
+
+ <entry>Value</entry>
+ </row>
+ </thead>
+
+ <tbody>
+ <row>
+ <entry>component-type</entry>
+
+ <entry>org.richfaces.JQuery</entry>
+ </row>
+
+ <row>
+ <entry>component-class</entry>
+
+ <entry>org.richfaces.component.html.HtmlJQuery</entry>
+ </row>
+
+ <row>
+ <entry>component-family</entry>
+
+ <entry>org.richfaces.JQuery</entry>
+ </row>
+
+ <row>
+ <entry>renderer-type</entry>
+
+ <entry>org.richfaces.JQueryRenderer</entry>
+ </row>
+
+ <row>
+ <entry>tag-class</entry>
+
+ <entry>org.richfaces.taglib.JQueryTag</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <section>
+ <title>Creating the Component with a Page Tag</title>
+
+ <para>To create the simplest variant on a page use the following syntax:</para>
+
+
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <!--programlisting role="XML"><![CDATA[...
+ <rich:jQuery name="makeFat" timing="onJScall" query="stop().animate({width:param.ewidth})" />
+...]]></programlisting-->
+ </section>
+
+ <section>
+ <title>Creating the Component Dynamically Using Java</title>
+
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="JAVA"><![CDATA[import org.richfaces.component.html.HtmlJQuery;
+...
+HtmlJQuery myJQuery = new HtmlJQuery();
+...
+]]></programlisting>
+ </section>
+
+ <section>
+ <title>Details of Usage</title>
+ </section>
+</section>
Modified: trunk/docs/userguide/en/src/main/docbook/master.xml
===================================================================
--- trunk/docs/userguide/en/src/main/docbook/master.xml 2007-10-15 16:47:45 UTC (rev 3379)
+++ trunk/docs/userguide/en/src/main/docbook/master.xml 2007-10-15 17:11:02 UTC (rev 3380)
@@ -46,6 +46,8 @@
<!ENTITY insert_table SYSTEM "../../../target/generated/insert.xml">
<!ENTITY treeModel_table SYSTEM "../../../target/generated/tree-model.xml">
<!ENTITY scrollableDataTable_table SYSTEM "../../../target/generated/scrollableDataTable.xml">
+<!ENTITY jQuery_table SYSTEM "../../../target/generated/jQuery.xml">
+
<!ENTITY coreComponents_table SYSTEM "../../../target/generated/a4j.xml">
<!ENTITY rfcFAQ SYSTEM "modules/RFCfaq.xml">
@@ -90,6 +92,7 @@
&inputNumberSlider_table;
&inputNumberSpinner_table;
&insert_table;
+&jQuery_table;
&message_table;
&modalPanel_table;
&paint2D_table;
Modified: trunk/docs/userguide/pom.xml
===================================================================
--- trunk/docs/userguide/pom.xml 2007-10-15 16:47:45 UTC (rev 3379)
+++ trunk/docs/userguide/pom.xml 2007-10-15 17:11:02 UTC (rev 3380)
@@ -185,11 +185,25 @@
</version>
</artifactItem>
+
<artifactItem>
<groupId>
org.richfaces.ui
</groupId>
<artifactId>
+ jQuery
+ </artifactId>
+ <version>
+ ${project.version}
+ </version>
+ </artifactItem>
+
+
+ <artifactItem>
+ <groupId>
+ org.richfaces.ui
+ </groupId>
+ <artifactId>
menu-components
</artifactId>
<version>
17 years, 2 months
JBoss Rich Faces SVN: r3379 - in trunk/ui/jQuery/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-10-15 12:47:45 -0400 (Mon, 15 Oct 2007)
New Revision: 3379
Modified:
trunk/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java
trunk/ui/jQuery/src/main/templates/jQuery.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1096
added logic to renderer
Modified: trunk/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java
===================================================================
--- trunk/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java 2007-10-15 16:47:37 UTC (rev 3378)
+++ trunk/ui/jQuery/src/main/java/org/richfaces/renderkit/JQueryRendererBase.java 2007-10-15 16:47:45 UTC (rev 3379)
@@ -10,6 +10,7 @@
import org.ajax4jsf.renderkit.ComponentVariables;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.UIJQuery;
+import org.richfaces.component.util.HtmlUtil;
public class JQueryRendererBase extends HeaderResourcesRendererBase {
@@ -47,8 +48,8 @@
}
}
- protected String replaceClientIds(String selector) {
- return selector;
+ protected String replaceClientIds(FacesContext context, UIComponent component, String selector) {
+ return HtmlUtil.expandIdSelector(selector, component, context);
}
Modified: trunk/ui/jQuery/src/main/templates/jQuery.jspx
===================================================================
--- trunk/ui/jQuery/src/main/templates/jQuery.jspx 2007-10-15 16:47:37 UTC (rev 3378)
+++ trunk/ui/jQuery/src/main/templates/jQuery.jspx 2007-10-15 16:47:45 UTC (rev 3379)
@@ -26,7 +26,7 @@
String selector = (String) variables.getVariable("selector");
checkValidity(clientId, name, timing, query);
- variables.setVariable("selector", replaceClientIds(selector));
+ variables.setVariable("selector", replaceClientIds(context, component, selector));
]]>
</jsp:scriptlet>
17 years, 2 months
JBoss Rich Faces SVN: r3378 - trunk/framework/test/src/test/java/org/richfaces/component/util.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-10-15 12:47:37 -0400 (Mon, 15 Oct 2007)
New Revision: 3378
Modified:
trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
Log:
http://jira.jboss.com/jira/browse/RF-1096
added logic to renderer
Modified: trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2007-10-15 16:47:31 UTC (rev 3377)
+++ trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2007-10-15 16:47:37 UTC (rev 3378)
@@ -21,6 +21,14 @@
package org.richfaces.component.util;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIInput;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
import junit.framework.TestCase;
/**
@@ -29,6 +37,19 @@
*
*/
public class HtmlUtilTest extends TestCase {
+
+ public HtmlUtilTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
public void testQualifySize() throws Exception {
assertEquals("", HtmlUtil.qualifySize(""));
@@ -48,4 +69,48 @@
assertEquals("120px", HtmlUtil.addToSize("100", "20"));
assertEquals("120px", HtmlUtil.addToSize("100px", "20px"));
}
+
+ public void testExpandIdSelector() {
+ String selector = ".class_form+#:Test .class2 #_1aaaa:";
+
+ UIComponent component = new UIComponentBase() {
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ public UIComponent findComponent(String expr) {
+ if (":Test".equals(expr)) {
+ return new UIComponentBase() {
+ public String getClientId(FacesContext context) {
+ return "component1";
+ }
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ } else if ("_1aaaa:".equals(expr)) {
+ return new UIComponentBase() {
+ public String getClientId(FacesContext context) {
+ return "component2";
+ }
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+ }
+
+ return null;
+ }
+ };
+
+ String string =
+ HtmlUtil.expandIdSelector(selector, component, null);
+
+ assertEquals(".class_form+#component1 .class2 #component2", string);
+
+ String s = ".class_form+.component1 .class2 #1component2";
+ assertEquals(s, HtmlUtil.expandIdSelector(s, component, null));
+ }
}
17 years, 2 months
JBoss Rich Faces SVN: r3377 - in trunk/framework/impl/src: test/java/org/richfaces/component/util and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: maksimkaszynski
Date: 2007-10-15 12:47:31 -0400 (Mon, 15 Oct 2007)
New Revision: 3377
Removed:
trunk/framework/impl/src/test/java/org/richfaces/component/util/HtmlUnitTest.java
Modified:
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
Log:
http://jira.jboss.com/jira/browse/RF-1096
added logic to renderer
Modified: trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15 16:20:48 UTC (rev 3376)
+++ trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15 16:47:31 UTC (rev 3377)
@@ -25,12 +25,12 @@
import java.util.regex.Pattern;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
import org.ajax4jsf.util.HtmlDimensions;
/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 09.02.2007
+ * @author Nick Belaevski - nbelaevski(a)exadel.com created 09.02.2007
*
*/
public class HtmlUtil {
@@ -45,32 +45,39 @@
return sizeDeclaration;
}
-
+
public static String addToSize(String declaration, String delta) {
Double doubleDelta = HtmlDimensions.decode(delta);
Double decoded = HtmlDimensions.decode(declaration);
-
- return HtmlDimensions.formatPx(
- new Double(decoded.doubleValue() + doubleDelta.doubleValue()));
+
+ return HtmlDimensions.formatPx(new Double(decoded.doubleValue()
+ + doubleDelta.doubleValue()));
}
-
- public static final Pattern idSelectorPattern = Pattern.compile("#((:|_|[a-z,A-Z])[a-z,A-Z,0-9,_,-,:]+)");
- public static String expandIdSelector(String selector, UIComponent component) {
- Matcher matcher = idSelectorPattern.matcher(selector);
- StringBuffer sb = new StringBuffer();
+ public static final Pattern idSelectorPattern = Pattern
+ .compile("#((:|_|[a-z,A-Z])[a-z,A-Z,0-9,_,-,:]+)");
- while (matcher.find())
- {
- if (matcher.group(1).indexOf("::")==-1)
- {
- // make new id selector here using matcher.group(1)
- matcher.appendReplacement(sb, "#new-value");
- }
- }
- matcher.appendTail(sb);
- String result = sb.toString();
- if (result.length()==0) result = selector;
- return sb.toString();
- }
+ public static String expandIdSelector(String selector,
+ UIComponent component, FacesContext context) {
+ Matcher matcher = idSelectorPattern.matcher(selector);
+ StringBuffer sb = new StringBuffer();
+
+ while (matcher.find()) {
+ if (matcher.group(1).indexOf("::") == -1) {
+ // make new id selector here using matcher.group(1)
+
+ UIComponent target = component.findComponent(matcher.group(1));
+
+ if (target != null) {
+ matcher.appendReplacement(sb, "#"
+ + target.getClientId(context));
+ }
+ }
+ }
+ matcher.appendTail(sb);
+ String result = sb.toString();
+ if (result.length() == 0)
+ result = selector;
+ return sb.toString();
+ }
}
Deleted: trunk/framework/impl/src/test/java/org/richfaces/component/util/HtmlUnitTest.java
===================================================================
--- trunk/framework/impl/src/test/java/org/richfaces/component/util/HtmlUnitTest.java 2007-10-15 16:20:48 UTC (rev 3376)
+++ trunk/framework/impl/src/test/java/org/richfaces/component/util/HtmlUnitTest.java 2007-10-15 16:47:31 UTC (rev 3377)
@@ -1,30 +0,0 @@
-package org.richfaces.component.util;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-
-import junit.framework.TestCase;
-
-//Initial draft
-
-public class HtmlUnitTest extends TestCase {
-
- public void testExpandIdSelector()throws Exception {
-
- UIComponent comp = new UIInput();
- String str = HtmlUtil.expandIdSelector(".class_form+#:Test .class2 #_1aaaa:",comp);
- //System.out.println(str);
- assertEquals(str,".class_form+#new-value .class2 #new-value");
- try {
- str = HtmlUtil.expandIdSelector(null, comp);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
-
-
-
-
- }
-
-}
17 years, 2 months