JBoss Rich Faces SVN: r238 - in trunk/richfaces/tree/src: main/java/org/richfaces/renderkit and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2007-04-02 20:33:01 -0400 (Mon, 02 Apr 2007)
New Revision: 238
Added:
trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeModelTest.java
Removed:
trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModelStrategyWrapper.java
Modified:
trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
trunk/richfaces/tree/src/test/java/org/richfaces/component/JSFComponentTest.java
trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeNodeTest.java
trunk/richfaces/tree/src/test/java/org/richfaces/component/xml/TreeDataBuilderTest.java
trunk/richfaces/tree/src/test/resources/org/richfaces/component/xml/XmlTreeDataBuilderTest.xml
Log:
New model test
Tests updated - coverage increased
Deleted: trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModelStrategyWrapper.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModelStrategyWrapper.java 2007-04-02 16:45:04 UTC (rev 237)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/component/AbstractTreeDataModelStrategyWrapper.java 2007-04-03 00:33:01 UTC (rev 238)
@@ -1,70 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.ajax.repeat.DataVisitor;
-import org.ajax4jsf.ajax.repeat.Range;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 08.12.2006
- * Wrapper class for {@link AbstractTreeDataModel} instances. Allows developer to change behaviuor
- * easily by implementing customized {@link #getAbstractTreeDataModel()} method
- * @see PersistedDataModel for an example of customized wrapper allowing to address calls to backing model
- * or to cached one
- */
-public abstract class AbstractTreeDataModelStrategyWrapper extends AbstractTreeDataModel {
-
- public Object getRowData() {
- return getAbstractTreeDataModel().getRowData();
- }
-
- public Object getRowKey() {
- return getAbstractTreeDataModel().getRowKey();
- }
-
- public boolean isLeaf() {
- return getAbstractTreeDataModel().isLeaf();
- }
-
- public boolean isRowAvailable() {
- return getAbstractTreeDataModel().isRowAvailable();
- }
-
- public void setRowKey(Object key) {
- getAbstractTreeDataModel().setRowKey(key);
- }
-
- public void walk(FacesContext context, DataVisitor dataVisitor, Range range, TreeRowKey rowKey, Object argument, boolean last) throws IOException {
- getAbstractTreeDataModel().walk(context, dataVisitor, range, rowKey, argument, last);
- }
-
- /**
- * returns wrapped {@link AbstractTreeDataModel}
- * @return wrapped {@link AbstractTreeDataModel} instance
- */
- protected abstract AbstractTreeDataModel getAbstractTreeDataModel();
-}
Modified: trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-04-02 16:45:04 UTC (rev 237)
+++ trunk/richfaces/tree/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2007-04-03 00:33:01 UTC (rev 238)
@@ -234,20 +234,6 @@
return "";
}
- protected String getWaitOnLoadId(FacesContext context, UITree tree) {
- if(tree.getAttributes().get("waitOnLoadId") instanceof String) {
- String waitOnLoadId = (String) tree.getAttributes().get("waitOnLoadId");
- if (waitOnLoadId != null) {
- UIComponent component = tree.getParent().findComponent(waitOnLoadId);
- if (component != null) {
- return component.getClientId(context);
- }
- }
- }
-
- return "";
- }
-
protected String getScriptContributions(FacesContext context, UITree tree) {
return super.getScriptContributions(getJavaScriptVarName(context, tree), context, tree);
}
Modified: trunk/richfaces/tree/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-02 16:45:04 UTC (rev 237)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-03 00:33:01 UTC (rev 238)
@@ -21,17 +21,40 @@
package org.richfaces.component;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlCommandLink;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.context.FacesContext;
+import org.ajax4jsf.framework.ViewHandlerWrapper;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.xml.XmlTreeDataBuilder;
+import org.xml.sax.InputSource;
+
+import com.gargoylesoftware.htmlunit.KeyValuePair;
+import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
/**
* Unit test for simple Component.
*/
public class JSFComponentTest
- extends TestCase
+ extends AbstractAjax4JsfTestCase
{
+ private UICommand command = null;
+ private UIInput input = null;
+ private UIForm form = null;
+ private UIComponent tree = null;
+
/**
* Create the test case
*
@@ -42,12 +65,112 @@
super( testName );
}
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form = new HtmlForm();
+
+ facesContext.getViewRoot().getChildren().add(form);
+
+ input = new UIInput() {
+ public void decode(FacesContext context) {
+ // TODO Auto-generated method stub
+ super.decode(context);
+ }
+ };
+ input.setId("input");
+
+ form.getChildren().add(input);
- /**
+ command = new HtmlCommandLink();
+ command.setId("command");
+
+ form.getChildren().add(command);
+
+ application.setViewHandler(new ViewHandlerWrapper(application.getViewHandler()) {
+ public void writeState(FacesContext context) throws IOException {
+ //System.out.println(".writeState()");
+ }
+
+ public String getResourceURL(FacesContext context, String url) {
+ // TODO Auto-generated method stub
+ return url;
+ }
+
+ public String getActionURL(FacesContext context, String url) {
+ // TODO Auto-generated method stub
+ return url;
+ }
+
+ public UIViewRoot restoreView(FacesContext context, String viewId) {
+ // TODO Auto-generated method stub
+ return super.restoreView(context, viewId);
+ }
+
+ public UIViewRoot createView(FacesContext context, String viewId) {
+ // TODO Auto-generated method stub
+ return super.createView(context, viewId);
+ }
+ });
+
+ tree = application.createComponent(UITree.COMPONENT_TYPE);
+
+ ((UITree) tree).setValue(
+ XmlTreeDataBuilder.build(
+ new InputSource(
+ this.getClass().
+ getResourceAsStream("/org/richfaces/component/xml/XmlTreeDataBuilderTest.xml")
+ )));
+
+ form.getChildren().add(tree);
+ ((UITree) tree).queueExpandAll();
+ }
+
+
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ this.input = null;
+ this.form = null;
+ this.command = null;
+ this.tree = null;
+ }
+
+ /**
* Rigourous Test :-)
+ * @throws Exception
*/
- public void testComponent()
+ public void testComponent() throws Exception
{
- assertTrue( true );
+ HtmlPage renderedView = renderView();
+ System.out.println(renderedView.getWebResponse().getContentAsString());
+
+ HtmlInput htmlInput = (HtmlInput) renderedView.getHtmlElementById(input.getClientId(facesContext));
+ htmlInput.setValueAttribute("testInput");
+
+ HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
+ htmlLink.click();
+
+ List lastParameters = this.webConnection.getLastParameters();
+ for (Iterator iterator = lastParameters.iterator(); iterator.hasNext();) {
+ KeyValuePair keyValue = (KeyValuePair) iterator.next();
+
+ externalContext.addRequestParameterMap((String) keyValue.getKey(), (String) keyValue.getValue());
+ }
+
+ System.out.println(this.webConnection.getLastParameters());
+
+ UIViewRoot root = facesContext.getViewRoot();
+ root.processDecodes(facesContext);
+ root.processValidators(facesContext);
+ root.processUpdates(facesContext);
+ root.processApplication(facesContext);
+
+ renderedView = renderView();
+ System.out.println(renderedView.getWebResponse().getContentAsString());
}
+
+ public void testProcess() {
+ }
}
Added: trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeModelTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeModelTest.java (rev 0)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeModelTest.java 2007-04-03 00:33:01 UTC (rev 238)
@@ -0,0 +1,139 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.component;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.faces.context.FacesContext;
+
+import junit.framework.TestCase;
+
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.richfaces.component.xml.XmlNodeData;
+import org.richfaces.component.xml.XmlTreeDataBuilder;
+import org.xml.sax.InputSource;
+
+/**
+ * @author Nick - mailto:nbelaevski@exadel.com
+ * created 03.04.2007
+ *
+ */
+public class TreeModelTest extends TestCase {
+ private TreeNode node = null;
+ private AbstractTreeDataModel model = new TreeDataModel();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ InputStream stream = this.getClass().getResourceAsStream("/org/richfaces/component/xml/XmlTreeDataBuilderTest.xml");
+ try {
+ node = XmlTreeDataBuilder.build(new InputSource(stream));
+ } finally {
+ stream.close();
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ node = null;
+ model = null;
+ }
+
+ public void testBaseProperties() {
+ assertNull(model.getWrappedData());
+ model.setWrappedData(node);
+ assertSame(model.getWrappedData(), node);
+
+ assertEquals(-1, model.getRowCount());
+ assertEquals(-1, model.getRowIndex());
+
+ try {
+ model.setRowIndex(1);
+
+ fail();
+ } catch (IllegalArgumentException e) {
+
+ }
+
+ model.setRowIndex(-1);
+ }
+
+ public void testWalk() throws Exception {
+ final Set set = new HashSet();
+ set.add("web-app");
+ set.add("login-config");
+ set.add("auth-method");
+ set.add("url-pattern");
+ set.add("load-on-startup-id");
+ set.add("dispatcher");
+ set.add("filter-class");
+ set.add("param-value");
+
+ model.setWrappedData(node);
+
+ model.walk(null, new Walker1(model, set) {
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+ model.setRowKey(rowKey);
+
+ XmlNodeData data = (XmlNodeData) model.getRowData();
+ if (data == null || set.contains(data.getName())) {
+ assertTrue(isLast());
+ } else {
+ assertFalse(isLast());
+ }
+ }
+ }, null, null);
+
+ model.setRowKey(new ListRowKey("testId:displayName"));
+ assertEquals("tree-demo", ((XmlNodeData) model.getRowData()).getText());
+
+ model.setRowKey(new ListRowKey("testId:1:1"));
+ assertEquals(".xhtml", ((XmlNodeData) model.getRowData()).getText());
+ }
+}
+
+abstract class Walker1 implements DataVisitor, LastElementAware {
+
+ private boolean last = false;
+ private AbstractTreeDataModel model;
+ private Set lastElementNames = null;
+
+ public Walker1(AbstractTreeDataModel model, Set lastElementNames) {
+ super();
+ this.model = model;
+ this.lastElementNames = lastElementNames;
+ }
+
+ public void resetLastElement() {
+ this.last = false;
+ }
+
+ public void setLastElement() {
+ this.last = true;
+ }
+
+ public boolean isLast() {
+ return last;
+ }
+}
Modified: trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeNodeTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeNodeTest.java 2007-04-02 16:45:04 UTC (rev 237)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/TreeNodeTest.java 2007-04-03 00:33:01 UTC (rev 238)
@@ -52,6 +52,11 @@
node = new TreeNodeImpl();
}
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ node = null;
+ }
+
public void testChildrenNew() {
assertFalse(node.getChildren().hasNext());
}
Modified: trunk/richfaces/tree/src/test/java/org/richfaces/component/xml/TreeDataBuilderTest.java
===================================================================
--- trunk/richfaces/tree/src/test/java/org/richfaces/component/xml/TreeDataBuilderTest.java 2007-04-02 16:45:04 UTC (rev 237)
+++ trunk/richfaces/tree/src/test/java/org/richfaces/component/xml/TreeDataBuilderTest.java 2007-04-03 00:33:01 UTC (rev 238)
@@ -50,6 +50,7 @@
protected void tearDown() throws Exception {
super.tearDown();
+ treeNode = null;
}
public void testIds() {
Modified: trunk/richfaces/tree/src/test/resources/org/richfaces/component/xml/XmlTreeDataBuilderTest.xml
===================================================================
--- trunk/richfaces/tree/src/test/resources/org/richfaces/component/xml/XmlTreeDataBuilderTest.xml 2007-04-02 16:45:04 UTC (rev 237)
+++ trunk/richfaces/tree/src/test/resources/org/richfaces/component/xml/XmlTreeDataBuilderTest.xml 2007-04-03 00:33:01 UTC (rev 238)
@@ -39,8 +39,6 @@
<filter-mapping>
<filter-name>a4j</filter-name>
<servlet-name>Faces Servlet</servlet-name>
- <dispatcher>FORWARD</dispatcher>
- <dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<servlet>
17 years, 9 months
JBoss Rich Faces SVN: r237 - in trunk/richfaces/suggestionbox/src: test and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-04-02 12:45:04 -0400 (Mon, 02 Apr 2007)
New Revision: 237
Added:
trunk/richfaces/suggestionbox/src/test/
trunk/richfaces/suggestionbox/src/test/java/
trunk/richfaces/suggestionbox/src/test/java/org/
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/html/
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/html/HtmlSuggestionBoxTest.java
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/taglib/
trunk/richfaces/suggestionbox/src/test/java/org/richfaces/taglib/SuggestionBoxTagTest.java
trunk/richfaces/suggestionbox/src/test/resources/
trunk/richfaces/suggestionbox/src/test/resources/WEB-INF/
trunk/richfaces/suggestionbox/src/test/resources/WEB-INF/web.xml
Log:
test added
Added: trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java
===================================================================
--- trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java (rev 0)
+++ trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/SuggestionBoxComponentTest.java 2007-04-02 16:45:04 UTC (rev 237)
@@ -0,0 +1,143 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import junit.framework.Assert;
+import org.ajax4jsf.framework.ajax.AjaxViewHandler;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.shale.test.mock.MockViewHandler;
+import org.richfaces.component.html.HtmlSuggestionBox;
+import org.richfaces.renderkit.html.SuggestionBoxRenderer;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.context.FacesContext;
+import java.util.List;
+
+/**
+ * Unit test for simple Component.
+ */
+public class SuggestionBoxComponentTest extends AbstractAjax4JsfTestCase {
+
+
+ HtmlSuggestionBox htmlSuggestionBox;
+ UIForm form;
+
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public SuggestionBoxComponentTest( String testName ) {
+ super( testName );
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ application.setViewHandler(new AjaxViewHandler(new MyMockViewHandler()));
+
+ UIComponent form = createComponent(UIForm.COMPONENT_TYPE, UIForm.class.getName(), null, null , null);
+ UIComponent input = createComponent(HtmlInputText.COMPONENT_TYPE, HtmlInputText.class.getName(), null, null , null);
+
+ form.setId("form");
+ input.setId("text");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ form.getChildren().add(input);
+
+ htmlSuggestionBox = new HtmlSuggestionBox();
+ htmlSuggestionBox.setId("suggestionBox");
+ htmlSuggestionBox.setFor(input.getId());
+ htmlSuggestionBox.setRendererType("suggestionBoxRenderer");
+ renderKit.addRenderer(HtmlSuggestionBox.COMPONENT_FAMILY, "suggestionBoxRenderer", new SuggestionBoxRenderer());
+
+ form.getChildren().add(htmlSuggestionBox);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ htmlSuggestionBox = null;
+ form = null;
+ }
+ /**
+ * Rigourous Test :-)
+ * @throws Exception
+ */
+ public void testRender() throws Exception {
+ HtmlPage page = renderView();
+ Assert.assertNotNull(page);
+ System.out.println(page.asXml());
+ HtmlElement div = page.getHtmlElementById("form:suggestionBox");
+ Assert.assertNotNull(div);
+ Assert.assertEquals("div", div.getNodeName());
+ }
+
+ /**
+ * Rigourous Test :-)
+ * @throws Exception
+ */
+ public void testRenderStyle() throws Exception {
+ HtmlPage page = renderView();
+ Assert.assertNotNull(page);
+ List elementsByTagName = page.getDocumentElement().getHtmlElementsByTagName("link");
+ Assert.assertEquals(1, elementsByTagName.size());
+ HtmlElement link = (HtmlElement) elementsByTagName.get(0);
+ Assert.assertTrue(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/suggestionbox.xcss"));
+ }
+
+ /**
+ * Rigourous Test :-)
+ * @throws Exception
+ */
+ public void testRenderAttributes() throws Exception {
+ /*
+ Object[][] attributes ={{"style","xxx","style","xxx"},{"onclick","alert()","onclick","alert()"},{"styleClass","yyy","class","dr-pnl rich-panel yyy"}};
+ for (int i = 0; i < attributes.length; i++) {
+ Object[] attr = attributes[i];
+ htmlSuggestionBox.getAttributes().put(attr[0], attr[1]);
+ }
+ HtmlPage page = renderView();
+ Assert.assertNotNull(page);
+ System.out.println(page.asXml());
+ HtmlElement div = page.getHtmlElementById("form:suggestionBox");
+ Assert.assertNotNull(div);
+ for (int i = 0; i < attributes.length; i++) {
+ Object[] attr = attributes[i];
+ Assert.assertEquals(attr[3],div.getAttributeValue((String) attr[2]));
+ }
+ */
+ }
+
+ class MyMockViewHandler extends MockViewHandler {
+ public UIViewRoot restoreView(FacesContext context, String viewId) {
+ return null;
+ }
+
+ public void writeState(FacesContext context) {
+
+ }
+ }
+}
Added: trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/html/HtmlSuggestionBoxTest.java
===================================================================
--- trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/html/HtmlSuggestionBoxTest.java (rev 0)
+++ trunk/richfaces/suggestionbox/src/test/java/org/richfaces/component/html/HtmlSuggestionBoxTest.java 2007-04-02 16:45:04 UTC (rev 237)
@@ -0,0 +1,52 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.html;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+/**
+ * Unit test for HtmlSuggestionBox.
+ */
+public class HtmlSuggestionBoxTest extends AbstractAjax4JsfTestCase {
+ public HtmlSuggestionBoxTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testSaveStateFacesContext() {
+ HtmlSuggestionBox htmlSuggestionBox = new HtmlSuggestionBox();
+ htmlSuggestionBox.setStyleClass("styleClass");
+ htmlSuggestionBox.setSelectedClass("selectedClass");
+ Object state = htmlSuggestionBox.saveState(facesContext);
+ HtmlSuggestionBox newHtmlSuggestionBox = new HtmlSuggestionBox();
+ newHtmlSuggestionBox.restoreState(facesContext, state);
+ assertEquals("styleClass", newHtmlSuggestionBox.getStyleClass());
+ assertEquals("selectedClass", newHtmlSuggestionBox.getSelectedClass());
+ }
+}
Added: trunk/richfaces/suggestionbox/src/test/java/org/richfaces/taglib/SuggestionBoxTagTest.java
===================================================================
--- trunk/richfaces/suggestionbox/src/test/java/org/richfaces/taglib/SuggestionBoxTagTest.java (rev 0)
+++ trunk/richfaces/suggestionbox/src/test/java/org/richfaces/taglib/SuggestionBoxTagTest.java 2007-04-02 16:45:04 UTC (rev 237)
@@ -0,0 +1,91 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.taglib;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.html.HtmlSuggestionBox;
+
+import javax.faces.webapp.UIComponentTag;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.Tag;
+
+public class SuggestionBoxTagTest extends AbstractAjax4JsfTestCase {
+
+ SuggestionBoxTag tag;
+
+ public SuggestionBoxTagTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ tag = new SuggestionBoxTag();
+ tag.setParent(new UIComponentTag(){
+
+ public String getComponentType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getRendererType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int doStartTag() throws JspException {
+ // TODO Auto-generated method stub
+ return Tag.EVAL_BODY_INCLUDE;
+ }
+
+ public int doEndTag() throws JspException {
+ // TODO Auto-generated method stub
+ return Tag.EVAL_BODY_INCLUDE;
+ }
+
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ tag = null;
+ }
+
+ /**
+ * Test method for {@link org.richfaces.taglib.SuggestionBoxTag#setProperties(javax.faces.component.UIComponent)}.
+ * @throws JspException
+ */
+ public void testSetPropertiesUIComponent() throws JspException {
+ HtmlSuggestionBox htmlSuggestionBox = new HtmlSuggestionBox();
+
+ tag.setStyleClass("styleClass");
+ tag.setSelectedClass("selectedClass");
+ tag.setProperties(htmlSuggestionBox);
+ assertEquals("styleClass", htmlSuggestionBox.getStyleClass());
+ assertEquals("selectedClass", htmlSuggestionBox.getSelectedClass());
+ }
+}
Added: trunk/richfaces/suggestionbox/src/test/resources/WEB-INF/web.xml
===================================================================
--- trunk/richfaces/suggestionbox/src/test/resources/WEB-INF/web.xml (rev 0)
+++ trunk/richfaces/suggestionbox/src/test/resources/WEB-INF/web.xml 2007-04-02 16:45:04 UTC (rev 237)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+ <display-name>testcase</display-name>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config.xml</param-value>
+ </context-param>
+
+ <filter>
+ <description>Convert HTML to XML</description>
+ <display-name>Filter</display-name>
+ <filter-name>A4J</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ <init-param>
+ <param-name>publicid</param-name>
+ <param-value>-//W3C//DTD XHTML 1.0 Transitional//EN</param-value>
+ </init-param>
+ <init-param>
+ <param-name>systemid</param-name>
+ <param-value>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</param-value>
+ </init-param>
+ <init-param>
+ <param-name>namespace</param-name>
+ <param-value>http://www.w3.org/1999/xhtml</param-value>
+ </init-param>
+ <init-param>
+ <param-name>forceparser</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>rewriteid</param-name>
+ <param-value>false</param-value>
+ </init-param>
+ <init-param>
+ <param-name>mime-type</param-name>
+ <param-value>text/xml</param-value>
+ </init-param>
+ <init-param>
+ <param-name>log4j-init-file</param-name>
+ <param-value>WEB-INF/log4j.xml</param-value>
+ </init-param>
+ <init-param>
+ <param-name>enable-cache</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ </filter>
+ <filter-mapping>
+ <filter-name>A4J</filter-name>
+ <url-pattern>*.jsf</url-pattern>
+ </filter-mapping>
+ <filter-mapping>
+ <filter-name>A4J</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+ <listener>
+ <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+</web-app>
17 years, 9 months
JBoss Rich Faces SVN: r236 - in trunk/richfaces/menu-components/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-04-02 11:19:09 -0400 (Mon, 02 Apr 2007)
New Revision: 236
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
Log:
changing classes for label and icon on select
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-04-02 15:02:40 UTC (rev 235)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-04-02 15:19:09 UTC (rev 236)
@@ -26,6 +26,8 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.framework.renderer.ComponentVariables;
+import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.richfaces.component.UIMenuGroup;
@@ -41,4 +43,31 @@
return true;
}
+ public void initializeResources(FacesContext context, UIMenuGroup menuGroup)
+ throws IOException {
+
+ ComponentVariables variables = ComponentsVariableResolver.getVariables(this, menuGroup);
+
+ boolean disabled = ((Boolean) menuGroup.getAttributes().get("disabled")).booleanValue();
+ if (!disabled) {
+ StringBuffer scriptValue = new StringBuffer();
+ scriptValue.append("document.getElementById('ref" + menuGroup.getClientId(context) + ":icon').className='dr-menu-icon rich-menu-item-icon ")
+ .append(getAttributeOrEmpty(menuGroup, "iconClass") + "'; ")
+ .append("document.getElementById('ref" + menuGroup.getClientId(context) + ":anchor').className='dr-menu-label rich-menu-item-label'; ");
+ variables.setVariable("onmouseout", scriptValue);
+
+ scriptValue = new StringBuffer();
+ scriptValue.append("document.getElementById('ref" + menuGroup.getClientId(context) + ":icon').className='dr-menu-icon dr-menu-icon-selected rich-menu-item-icon rich-menu-item-icon-selected ")
+ .append(getAttributeOrEmpty(menuGroup, "iconClass") + "'; ")
+ .append("document.getElementById('ref" + menuGroup.getClientId(context) + ":anchor').className='dr-menu-label dr-menu-label-selected rich-menu-item-label rich-menu-item-label-selected'; ");
+ variables.setVariable("onmouseover", scriptValue);
+
+ }
+ }
+
+ public String getAttributeOrEmpty(UIComponent component, String attr) {
+ Object value = component.getAttributes().get(attr);
+ return value==null?"":value.toString();
+ }
+
}
Modified: trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx
===================================================================
--- trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-04-02 15:02:40 UTC (rev 235)
+++ trunk/richfaces/menu-components/src/main/templates/org/richfaces/htmlMenuGroup.jspx 2007-04-02 15:19:09 UTC (rev 236)
@@ -18,6 +18,8 @@
scripts/menu.js,
scripts/css-rules.js
</h:scripts>
+
+ <f:call name="initializeResources" />
<f:clientid var="clientId"/>
<f:resource name="/org/richfaces/renderkit/html/images/spacer.gif" var="spacer" />
@@ -29,8 +31,8 @@
<div id="ref#{clientId}"
class="dr-menu-item dr-menu-item-enabled rich-menu-group #{component.attributes['styleClass']}"
style="#{component.attributes['style']}"
- onmouseout="this.className='dr-menu-item dr-menu-item-enabled rich-menu-group'; #{component.attributes['onmouseout']}"
- onmouseover="this.className='dr-menu-item dr-menu-item-hover rich-menu-group rich-menu-group-hover'; #{component.attributes['onmouseover']}"
+ onmouseout="this.className='dr-menu-item dr-menu-item-enabled rich-menu-group'; #{onmouseout} #{component.attributes['onmouseout']}"
+ onmouseover="this.className='dr-menu-item dr-menu-item-hover rich-menu-group rich-menu-group-hover'; #{component.attributes['selectClass']} #{onmouseover} #{component.attributes['onmouseover']}"
onmousemove="#{component.attributes['onmousemove']}">
<span id="ref#{clientId}:icon"
17 years, 9 months
JBoss Rich Faces SVN: r235 - trunk/richfaces/menu-components/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: F.antonov
Date: 2007-04-02 11:02:40 -0400 (Mon, 02 Apr 2007)
New Revision: 235
Modified:
trunk/richfaces/menu-components/src/test/java/org/richfaces/component/JSFComponentTest.java
Log:
Test application update.
Modified: trunk/richfaces/menu-components/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-02 14:59:34 UTC (rev 234)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-02 15:02:40 UTC (rev 235)
@@ -83,8 +83,6 @@
public void testRenderHeader() throws Exception
{
- menuItem = new HtmlMenuItem();
- menuItem.setId("menuItem");
UIComponent text = createComponent(HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(), null, null , null);
menuItem.getFacets().put("iconDisabled", text);
HtmlPage page = renderView();
17 years, 9 months
JBoss Rich Faces SVN: r234 - trunk/richfaces/menu-components/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: F.antonov
Date: 2007-04-02 10:59:34 -0400 (Mon, 02 Apr 2007)
New Revision: 234
Modified:
trunk/richfaces/menu-components/src/test/java/org/richfaces/component/JSFComponentTest.java
Log:
Test application update.
Modified: trunk/richfaces/menu-components/src/test/java/org/richfaces/component/JSFComponentTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-02 14:32:36 UTC (rev 233)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/component/JSFComponentTest.java 2007-04-02 14:59:34 UTC (rev 234)
@@ -25,13 +25,25 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
import javax.faces.component.UIComponent;
+import javax.faces.component.html.HtmlOutputText;
+import org.richfaces.component.html.HtmlMenuItem;
+import org.richfaces.renderkit.html.MenuItemRenderer;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
/**
* Unit test for simple Component.
*/
public class JSFComponentTest
- extends TestCase
+ extends AbstractAjax4JsfTestCase
{
+
+ HtmlMenuItem menuItem;
+
/**
* Create the test case
*
@@ -41,13 +53,44 @@
{
super( testName );
}
+
+ public void setUp() throws Exception {
+ super.setUp();
+ menuItem = new HtmlMenuItem();
+ menuItem.setId("menuItem");
+ menuItem.setRendererType("org.richfaces.MenuItemRenderer");
+ facesContext.getViewRoot().getChildren().add(menuItem);
+ renderKit.addRenderer(menuItem.COMPONENT_FAMILY, "org.richfaces.MenuItemRenderer", new MenuItemRenderer());
+ }
+ public void tearDown() throws Exception {
+ super.tearDown();
+ menuItem = null;
+ }
/**
* Rigourous Test :-)
*/
- public void testComponent()
+ public void testRender() throws Exception
{
- assertTrue( true );
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+ HtmlElement div = page.getHtmlElementById("menuItem");
+ assertNotNull(div);
+ assertEquals("div", div.getNodeName());
}
+
+ public void testRenderHeader() throws Exception
+ {
+ menuItem = new HtmlMenuItem();
+ menuItem.setId("menuItem");
+ UIComponent text = createComponent(HtmlOutputText.COMPONENT_TYPE, HtmlOutputText.class.getName(), null, null , null);
+ menuItem.getFacets().put("iconDisabled", text);
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+ HtmlElement span = page.getHtmlElementById("menuItem:icon");
+ assertNotNull(span);
+ }
}
17 years, 9 months
JBoss Rich Faces SVN: r233 - in trunk/richfaces/dropdown-menu/src/main: resources/org/richfaces/renderkit/html/css and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: d.bulahov
Date: 2007-04-02 10:32:36 -0400 (Mon, 02 Apr 2007)
New Revision: 233
Modified:
trunk/richfaces/dropdown-menu/src/main/config/component/dropdownmenu.xml
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/css/dropdownmenu.xcss
trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Log:
Development (positioning of the menu of groups)
Modified: trunk/richfaces/dropdown-menu/src/main/config/component/dropdownmenu.xml
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/config/component/dropdownmenu.xml 2007-04-02 08:27:15 UTC (rev 232)
+++ trunk/richfaces/dropdown-menu/src/main/config/component/dropdownmenu.xml 2007-04-02 14:32:36 UTC (rev 233)
@@ -44,6 +44,7 @@
<description>
Set the submission mode for all menu items of the menu except ones where this attribute redefined. (ajax,server(Default),none)
</description>
+ <defaultvalue>"server"</defaultvalue>
</property>
<property>
Modified: trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/css/dropdownmenu.xcss
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/css/dropdownmenu.xcss 2007-04-02 08:27:15 UTC (rev 232)
+++ trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/css/dropdownmenu.xcss 2007-04-02 14:32:36 UTC (rev 233)
@@ -27,7 +27,6 @@
white-space : nowrap;
font-family : arial;
font-size : 11px;
- position : relative;
width : 75px;
height : 18px;
}
Modified: trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-04-02 08:27:15 UTC (rev 232)
+++ trunk/richfaces/dropdown-menu/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2007-04-02 14:32:36 UTC (rev 233)
@@ -387,10 +387,10 @@
var dim = Element.getDimensions(this.element);
// parent element
-// var top = screenOffset[1];
-// var left = screenOffset[0];
- var top = 0;
- var left = 0;
+ var top = screenOffset[1];
+ var left = screenOffset[0];
+ //var top = 0;
+ //var left = 0;
var bottom = top + dim.height;
var right = left + dim.width;
17 years, 9 months
JBoss Rich Faces SVN: r232 - trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-04-02 04:27:15 -0400 (Mon, 02 Apr 2007)
New Revision: 232
Modified:
trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
Log:
menu without menuLayer template
Modified: trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-04-02 08:25:31 UTC (rev 231)
+++ trunk/richfaces/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2007-04-02 08:27:15 UTC (rev 232)
@@ -24,9 +24,23 @@
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.richfaces.component.UIDropDownMenu;
+import org.richfaces.component.UIMenuGroup;
+import org.richfaces.component.UIMenuItem;
+import org.richfaces.component.UIMenuSeparator;
-public class DropDownMenuRendererBase extends MenuRendererBase {
+public class DropDownMenuRendererBase extends HeaderResourcesRendererBase {
protected Class getComponentClass() {
return UIDropDownMenu.class;
@@ -36,5 +50,126 @@
return true;
}
+ public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
+ List flatListOfNodes = new LinkedList();
+ String width = (String)component.getAttributes().get("popupWidth");
+
+ flatten(component.getChildren(), flatListOfNodes);
+ processLayer(context, component, width);
+
+ for (Iterator iter = flatListOfNodes.iterator(); iter.hasNext();) {
+ UIMenuGroup node = (UIMenuGroup) iter.next();
+ processLayer(context, node, width);
+ }
+ }
+
+ public void processLayer(FacesContext context, UIComponent layer, String width) throws IOException {
+ String clientId = layer.getClientId(context);
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement("div", layer);
+ writer.writeAttribute("id", clientId+"_menu", null);
+ writer.writeAttribute("class", "dr-menu-list-border rich-menu-list-border", null);
+ writer.writeAttribute("style", "visibility: hidden; z-index:100; " + (width!=null&&width.length()>0?"width: "+width:""), null);
+ writer.startElement("div", layer);
+ writer.writeAttribute("class", "dr-menu-list-bg rich-menu-list-bg", null);
+ encodeItems(context, layer);
+ writer.endElement("div");
+ writer.endElement("div");
+
+ writer.startElement("iframe", layer);
+ writer.writeAttribute("id", clientId+"_menu_iframe", null);
+ writer.writeAttribute("class", "underneath_iframe", null);
+ writer.writeAttribute("style", "position:absolute", null);
+ writer.endElement("iframe");
+ writer.startElement("iframe", layer);
+ writer.writeAttribute("id", clientId+"_menu_iframe1", null);
+ writer.writeAttribute("class", "underneath_iframe", null);
+ writer.writeAttribute("style", "position:absolute", null);
+ writer.endElement("iframe");
+
+ writer.startElement("script", layer);
+ writer.writeAttribute("id", clientId+"_menu_script", null);
+ writer.writeAttribute("type", "text/javascript", null);
+ encodeScript(context, layer);
+ writer.endElement("script");
+ AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_iframe");
+ AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_iframe1");
+ AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_script");
+ }
+
+ public void encodeItems(FacesContext context, UIComponent component) throws IOException {
+ List kids = component.getChildren();
+ Iterator it = kids.iterator();
+ while (it.hasNext()) {
+ UIComponent kid = (UIComponent)it.next();
+ if (kid instanceof UIMenuGroup || kid instanceof UIMenuItem || kid instanceof UIMenuSeparator) {
+ renderChild(context, kid);
+ }
+ }
+ }
+
+ private void flatten(List kids, List flatList){
+ if(kids != null){
+ for (Iterator iter = kids.iterator(); iter.hasNext();) {
+ UIComponent kid = (UIComponent) iter.next();
+ if (kid instanceof UIMenuGroup) {
+ UIMenuGroup node = (UIMenuGroup) kid;
+ flatList.add(node);
+ flatten(node.getChildren(), flatList);
+ }
+ }
+ }
+ }
+
+ public void encodeScript(FacesContext context, UIComponent component) throws IOException {
+ StringBuffer buffer =
+ new StringBuffer("new Exadel.Menu.Layer('")
+ .append(component.getClientId(context)+"_menu")
+ .append("',")
+ .append(component.getAttributes().get("showDelay"))
+ .append( ")");
+ if (component instanceof UIMenuGroup) {
+ buffer.append(".asSubMenu('")
+ .append(component.getParent().getClientId(context)+"_menu")
+ .append("','")
+ .append("ref")
+ .append(component.getClientId(context))
+ .append("')");
+ } else {
+ buffer
+ .append(".asDropDown('")
+ .append(component.getClientId(context))
+ .append("'");
+
+ String evt = (String) component.getAttributes().get("event");
+ if(evt == null || evt.trim().length() == 0){
+ evt = "onmouseover";
+ }
+ buffer.append(",'").append(evt).append("')");
+
+ }
+ List children = component.getChildren();
+ for(Iterator it = children.iterator();it.hasNext();) {
+ UIComponent kid = (UIComponent)it.next();
+ String itemId = null;
+ if (kid instanceof UIMenuItem) {
+ itemId = kid.getClientId(context);
+ } else if (kid instanceof UIMenuGroup) {
+ itemId = "ref" + kid.getClientId(context);
+ }
+ if(itemId != null){
+ buffer
+ .append(".addItem('")
+ .append(itemId)
+ .append("')");
+ }
+ }
+ ResponseWriter out = context.getResponseWriter();
+ String script =buffer.append(";").toString();
+ out.write(script);
+ }
+
+
}
17 years, 9 months
JBoss Rich Faces SVN: r231 - in trunk/richfaces/menu-components/src/main: resources/org/richfaces/renderkit/html and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-04-02 04:25:31 -0400 (Mon, 02 Apr 2007)
New Revision: 231
Removed:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuRendererBase.java
trunk/richfaces/menu-components/src/main/resources/org/richfaces/renderkit/html/template/
Modified:
trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
Log:
menu without menuLayer template
Modified: trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-03-30 23:15:15 UTC (rev 230)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuGroupRendererBase.java 2007-04-02 08:25:31 UTC (rev 231)
@@ -26,11 +26,12 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
import org.richfaces.component.UIMenuGroup;
-public class MenuGroupRendererBase extends MenuRendererBase {
+public class MenuGroupRendererBase extends HeaderResourcesRendererBase {
protected Class getComponentClass() {
return UIMenuGroup.class;
@@ -40,7 +41,4 @@
return true;
}
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- }
-
}
Deleted: trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuRendererBase.java
===================================================================
--- trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuRendererBase.java 2007-03-30 23:15:15 UTC (rev 230)
+++ trunk/richfaces/menu-components/src/main/java/org/richfaces/renderkit/html/MenuRendererBase.java 2007-04-02 08:25:31 UTC (rev 231)
@@ -1,153 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.renderkit.html;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
-import org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase;
-import org.ajax4jsf.framework.renderer.compiler.HtmlCompiler;
-import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
-import org.richfaces.component.UIMenuGroup;
-import org.richfaces.component.UIMenuItem;
-import org.richfaces.component.UIMenuSeparator;
-
-
-
-public abstract class MenuRendererBase extends HeaderResourcesRendererBase {
-
- public void encodeChildren(FacesContext context, UIComponent component) throws IOException {
- List flatListOfNodes = new LinkedList();
- MenuLayerRendererHelper helper = new MenuLayerRendererHelper(context);
-
- flatten(component.getChildren(), flatListOfNodes);
- helper.processLayer(component);
-
- for (Iterator iter = flatListOfNodes.iterator(); iter.hasNext();) {
- UIMenuGroup node = (UIMenuGroup) iter.next();
- helper.processLayer(node);
- }
- }
-
- public void encodeItems(FacesContext context, UIComponent component) throws IOException {
- List kids = component.getChildren();
- Iterator it = kids.iterator();
- while (it.hasNext()) {
- UIComponent kid = (UIComponent)it.next();
- if (kid instanceof UIMenuGroup || kid instanceof UIMenuItem || kid instanceof UIMenuSeparator) {
- renderChild(context, kid);
- }
- }
-
- }
-
- private class MenuLayerRendererHelper {
- private FacesContext context;
- private PreparedTemplate template;
-
- public MenuLayerRendererHelper(FacesContext context) {
- super();
- this.context = context;
- template = HtmlCompiler.compileResource("org/richfaces/renderkit/html/template/htmlMenuLayer.jspx");
-
- }
-
- public void processLayer(UIComponent layer) throws IOException{
- String clientId = layer.getClientId(context);
- template.encode(MenuRendererBase.this, context, layer);
- AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_iframe");
- AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_iframe1");
- AjaxRendererUtils.addRegionByName(context, layer, clientId + "_menu_script");
- }
-
- }
-
-
- private void flatten(List kids, List flatList){
- if(kids != null){
- for (Iterator iter = kids.iterator(); iter.hasNext();) {
- UIComponent kid = (UIComponent) iter.next();
- if (kid instanceof UIMenuGroup) {
- UIMenuGroup node = (UIMenuGroup) kid;
- flatList.add(node);
- flatten(node.getChildren(), flatList);
- }
- }
- }
- }
-
- public void encodeScript(FacesContext context, UIComponent component) throws IOException {
- StringBuffer buffer =
- new StringBuffer("new Exadel.Menu.Layer('")
- .append(component.getClientId(context)+"_menu")
- .append("',")
- .append(component.getAttributes().get("showDelay"))
- .append( ")");
- if (component instanceof UIMenuGroup) {
- buffer.append(".asSubMenu('")
- .append(component.getParent().getClientId(context)+"_menu")
- .append("','")
- .append("ref")
- .append(component.getClientId(context))
- .append("')");
- } else {
- buffer
- .append(".asDropDown('")
- .append(component.getClientId(context))
- .append("'");
-
- String evt = (String) component.getAttributes().get("event");
- if(evt == null || evt.trim().length() == 0){
- evt = "onmouseover";
- }
- buffer.append(",'").append(evt).append("')");
-
- }
- List children = component.getChildren();
- for(Iterator it = children.iterator();it.hasNext();) {
- UIComponent kid = (UIComponent)it.next();
- String itemId = null;
- if (kid instanceof UIMenuItem) {
- itemId = kid.getClientId(context);
- } else if (kid instanceof UIMenuGroup) {
- itemId = "ref" + kid.getClientId(context);
- }
- if(itemId != null){
- buffer
- .append(".addItem('")
- .append(itemId)
- .append("')");
- }
- }
- ResponseWriter out = context.getResponseWriter();
- String script =buffer.append(";").toString();
- out.write(script);
- }
-
-}
17 years, 9 months