JBoss Rich Faces SVN: r745 - trunk/richfaces/modal-panel/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-05-14 05:13:55 -0400 (Mon, 14 May 2007)
New Revision: 745
Modified:
trunk/richfaces/modal-panel/src/test/java/org/richfaces/component/ModalPanelComponentTest.java
Log:
test fixed
Modified: trunk/richfaces/modal-panel/src/test/java/org/richfaces/component/ModalPanelComponentTest.java
===================================================================
--- trunk/richfaces/modal-panel/src/test/java/org/richfaces/component/ModalPanelComponentTest.java 2007-05-14 09:11:22 UTC (rev 744)
+++ trunk/richfaces/modal-panel/src/test/java/org/richfaces/component/ModalPanelComponentTest.java 2007-05-14 09:13:55 UTC (rev 745)
@@ -56,7 +56,7 @@
static {
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("prototype.js");
+ javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
javaScripts.add("scripts/utils.js");
javaScripts.add("scripts/modalPanel.js");
javaScripts.add("scripts/modalPanelBorders.js");
17 years, 8 months
JBoss Rich Faces SVN: r744 - trunk/richfaces/panel/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-05-14 05:11:22 -0400 (Mon, 14 May 2007)
New Revision: 744
Modified:
trunk/richfaces/panel/src/test/java/org/richfaces/component/PanelComponentTest.java
Log:
test fixed
Modified: trunk/richfaces/panel/src/test/java/org/richfaces/component/PanelComponentTest.java
===================================================================
--- trunk/richfaces/panel/src/test/java/org/richfaces/component/PanelComponentTest.java 2007-05-14 09:09:41 UTC (rev 743)
+++ trunk/richfaces/panel/src/test/java/org/richfaces/component/PanelComponentTest.java 2007-05-14 09:11:22 UTC (rev 744)
@@ -96,7 +96,7 @@
List elementsByTagName = page.getDocumentElement().getHtmlElementsByTagName("link");
assertEquals(1, elementsByTagName.size());
HtmlElement link = (HtmlElement) elementsByTagName.get(0);
- assertTrue(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/panel.xcss"));
+ assertTrue(link.getAttributeValue("href").contains("css/panel.xcss"));
}
/**
17 years, 8 months
JBoss Rich Faces SVN: r743 - trunk/richfaces/tabPanel/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-05-14 05:09:41 -0400 (Mon, 14 May 2007)
New Revision: 743
Modified:
trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
Log:
test fixed
Modified: trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java
===================================================================
--- trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-05-14 09:08:21 UTC (rev 742)
+++ trunk/richfaces/tabPanel/src/test/java/org/richfaces/component/TabPanelComponentTest.java 2007-05-14 09:09:41 UTC (rev 743)
@@ -48,11 +48,11 @@
static {
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("prototype.js");
+ javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
javaScripts.add("org.ajax4jsf.framework.ajax.ImageCacheScript");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
javaScripts.add("org/ajax4jsf/renderkit/html/scripts/form.js");
- javaScripts.add("org/richfaces/renderkit/html/scripts/tabPanel.js");
+ javaScripts.add("scripts/tabPanel.js");
}
private UITabPanel tabPanel;
@@ -179,7 +179,7 @@
List links = page.getDocumentElement().getHtmlElementsByTagName("link");
assertEquals(1, links.size());
HtmlElement link = (HtmlElement) links.get(0);
- assertTrue(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/tabPanel.xcss"));
+ assertTrue(link.getAttributeValue("href").contains("css/tabPanel.xcss"));
}
/**
@@ -218,7 +218,7 @@
System.out.println(view.asXml());
InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
- InternetResource resource = builder.getResource("org/richfaces/renderkit/html/css/tabPanel.xcss");
+ InternetResource resource = builder.getResource("css/tabPanel.xcss");
assertNotNull(resource);
String uri = "http:" + resource.getUri(facesContext, null);
Page page = webClient.getPage(uri);
17 years, 8 months
JBoss Rich Faces SVN: r742 - trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-05-14 05:08:21 -0400 (Mon, 14 May 2007)
New Revision: 742
Modified:
trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
Log:
tests fixed
Modified: trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java
===================================================================
--- trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-05-14 09:06:57 UTC (rev 741)
+++ trunk/richfaces/inputnumber-slider/src/test/java/org/richfaces/component/InputNumberSliderComponentTest.java 2007-05-14 09:08:21 UTC (rev 742)
@@ -21,24 +21,9 @@
package org.richfaces.component;
-import java.awt.Dimension;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.faces.component.UICommand;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIViewRoot;
-import javax.faces.component.html.HtmlCommandLink;
-import javax.faces.component.html.HtmlForm;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.PropertyNotFoundException;
-import javax.faces.el.ValueBinding;
-import javax.servlet.http.HttpServletResponse;
-
+import com.gargoylesoftware.htmlunit.KeyValuePair;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.html.*;
import org.ajax4jsf.framework.resource.InternetResource;
import org.ajax4jsf.framework.resource.InternetResourceBuilder;
import org.ajax4jsf.framework.resource.Java2Dresource;
@@ -51,18 +36,23 @@
import org.richfaces.renderkit.html.images.SliderFieldGradient;
import org.richfaces.renderkit.html.images.SliderTrackGradient;
-import com.gargoylesoftware.htmlunit.KeyValuePair;
-import com.gargoylesoftware.htmlunit.Page;
-import com.gargoylesoftware.htmlunit.html.DomNode;
-import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlInput;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlScript;
+import javax.faces.component.UICommand;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlCommandLink;
+import javax.faces.component.html.HtmlForm;
+import javax.faces.context.FacesContext;
+import javax.faces.el.EvaluationException;
+import javax.faces.el.PropertyNotFoundException;
+import javax.faces.el.ValueBinding;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
-/**
- * Unit test for simple Component.
- */
+/** Unit test for simple Component. */
public class InputNumberSliderComponentTest extends AbstractAjax4JsfTestCase {
private UIForm form = null;
@@ -71,108 +61,128 @@
private static Set javaScripts = new HashSet();
/**
- * Create the test case
- *
- * @param testName
- * name of the test case
- */
-
+ * Create the test case
+ *
+ * @param testName
+ * name of the test case
+ */
+
static {
- javaScripts.add("prototype.js");
+ javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
- javaScripts.add("org/richfaces/renderkit/html/script/SliderScript.js");
+ javaScripts.add("script/SliderScript.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/browser_info.js");
javaScripts.add("org/richfaces/renderkit/html/scripts/events.js");
}
-
+
public InputNumberSliderComponentTest(String testName) {
- super(testName);
+ super(testName);
}
public void setUp() throws Exception {
- super.setUp();
+ super.setUp();
- form = new HtmlForm();
- facesContext.getViewRoot().getChildren().add(form);
+ form = new HtmlForm();
+ facesContext.getViewRoot().getChildren().add(form);
- command = new HtmlCommandLink();
- command.setId("command");
- form.getChildren().add(command);
-
- slider = application.createComponent(UIInputNumberSlider.COMPONENT_TYPE);
- slider.setId("slider");
- form.getChildren().add(slider);
+ command = new HtmlCommandLink();
+ command.setId("command");
+ form.getChildren().add(command);
+
+ slider = application.createComponent(
+ UIInputNumberSlider.COMPONENT_TYPE);
+ slider.setId("slider");
+ form.getChildren().add(slider);
}
public void tearDown() throws Exception {
- super.tearDown();
- this.form = null;
- this.slider = null;
- this.command = null;
+ super.tearDown();
+ this.form = null;
+ this.slider = null;
+ this.command = null;
}
/**
* Test component renders correctly
- *
+ *
* @throws Exception
*/
public void testComponent() throws Exception {
- HtmlPage renderedView = renderView();
+ HtmlPage renderedView = renderView();
- HtmlElement htmlSlider = renderedView.getHtmlElementById(slider.getClientId(facesContext));
+ HtmlElement htmlSlider = renderedView.getHtmlElementById(
+ slider.getClientId(facesContext));
- assertNotNull(htmlSlider);
+ assertNotNull(htmlSlider);
- assertTrue(htmlSlider.getAttributeValue("class").contains("rich-slider"));
-
- HtmlInput htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(slider.getClientId(facesContext) + "Input");
-
- assertNotNull(htmlSliderInput);
-
- assertTrue(htmlSliderInput.getClassAttribute().contains("dr-insldr-field rich-inslider-field"));
- assertTrue(htmlSliderInput.getTypeAttribute().equals("text"));
-
- DomNode numContainer = htmlSliderInput.getParentNode().getPreviousSibling();
- assertTrue(((HtmlElement)numContainer).getAttributeValue("class").contains("dr-insldr-right-num rich-inslider-right-num"));
- assertTrue(((HtmlElement)(numContainer.getPreviousSibling())).getAttributeValue("class").contains("dr-insldr-left-num rich-inslider-left-num"));
-
- HtmlElement tip = renderedView.getHtmlElementById(slider.getClientId(facesContext) + "Tip");
- assertTrue(tip.getAttributeValue("class").contains("dr-insldr-tip rich-inslider-tip"));
-
- HtmlElement handle = renderedView.getHtmlElementById(slider.getClientId(facesContext) + "Handle");
- assertTrue(handle.getAttributeValue("class").contains("dr-insldr-handler rich-inslider-handler"));
-
- HtmlElement track = (HtmlElement)tip.getParentNode().getNextSibling();
- assertTrue(track.getAttributeValue("class").contains("dr-insldr-track rich-inslider-track"));
+ assertTrue(htmlSlider.getAttributeValue("class").contains(
+ "rich-slider"));
+
+ HtmlInput htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(
+ slider.getClientId(facesContext) + "Input");
+
+ assertNotNull(htmlSliderInput);
+
+ assertTrue(htmlSliderInput.getClassAttribute().contains(
+ "dr-insldr-field rich-inslider-field"));
+ assertTrue(htmlSliderInput.getTypeAttribute().equals("text"));
+
+ DomNode numContainer = htmlSliderInput.getParentNode()
+ .getPreviousSibling();
+ assertTrue(((HtmlElement) numContainer).getAttributeValue(
+ "class").contains(
+ "dr-insldr-right-num rich-inslider-right-num"));
+ assertTrue(((HtmlElement) (numContainer.getPreviousSibling()))
+ .getAttributeValue("class").contains(
+ "dr-insldr-left-num rich-inslider-left-num"));
+
+ HtmlElement tip = renderedView.getHtmlElementById(slider.getClientId(
+ facesContext) + "Tip");
+ assertTrue(tip.getAttributeValue("class").contains(
+ "dr-insldr-tip rich-inslider-tip"));
+
+ HtmlElement handle = renderedView.getHtmlElementById(slider.getClientId(
+ facesContext) + "Handle");
+ assertTrue(handle.getAttributeValue("class").contains(
+ "dr-insldr-handler rich-inslider-handler"));
+
+ HtmlElement track = (HtmlElement) tip.getParentNode().getNextSibling();
+ assertTrue(track.getAttributeValue("class").contains(
+ "dr-insldr-track rich-inslider-track"));
}
-
+
public void testHiddenInput() throws Exception {
- slider.getAttributes().put("showInput",Boolean.FALSE);
- HtmlPage renderedView = renderView();
- HtmlInput htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(slider.getClientId(facesContext) + "Input");
- assertTrue(htmlSliderInput.getTypeAttribute().equals("hidden"));
+ slider.getAttributes().put("showInput", Boolean.FALSE);
+ HtmlPage renderedView = renderView();
+ HtmlInput htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(
+ slider.getClientId(facesContext) + "Input");
+ assertTrue(htmlSliderInput.getTypeAttribute().equals("hidden"));
}
-
+
public void testRenderStyle() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
+ //System.out.println(page.asXml());
List links = page.getDocumentElement().getHtmlElementsByTagName("link");
assertEquals(1, links.size());
HtmlElement link = (HtmlElement) links.get(0);
- assertTrue(link.getAttributeValue("href").contains("org/richfaces/renderkit/html/css/slider.xcss"));
+ assertTrue(link.getAttributeValue("href").contains("css/slider.xcss"));
}
-
+
public void testRenderScript() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
- List scripts = page.getDocumentElement().getHtmlElementsByTagName("script");
+ //System.out.println(page.asXml());
+ List scripts = page.getDocumentElement().getHtmlElementsByTagName(
+ "script");
for (Iterator it = scripts.iterator(); it.hasNext();) {
HtmlScript item = (HtmlScript) it.next();
String srcAttr = item.getSrcAttribute();
if (StringUtils.isNotBlank(srcAttr)) {
boolean found = false;
- for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
+ for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();)
+ {
String src = (String) srcIt.next();
found = srcAttr.contains(src);
@@ -185,148 +195,176 @@
}
}
}
-
+
public void testImages() throws Exception {
- InternetResource image = InternetResourceBuilder.getInstance().createResource(null, SliderFieldGradient.class.getName());
- Dimension imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
- assertTrue( imageDim.getWidth() == 31 && imageDim.getHeight() == 55);
-
- image = InternetResourceBuilder.getInstance().createResource(null, SliderTrackGradient.class.getName());
- imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
- assertTrue( imageDim.getWidth() == 7 && imageDim.getHeight() == 10);
+ InternetResource image = InternetResourceBuilder.getInstance()
+ .createResource(null, SliderFieldGradient.class.getName());
+ Dimension imageDim = ((Java2Dresource) image).getDimensions(
+ facesContext, null);
+ assertTrue(imageDim.getWidth() == 31 && imageDim.getHeight() == 55);
- image = InternetResourceBuilder.getInstance().createResource(null, SliderArrowImage.class.getName());
- imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
- assertTrue( imageDim.getWidth() == 7 && imageDim.getHeight() == 8);
+ image = InternetResourceBuilder.getInstance().createResource(null,
+ SliderTrackGradient.class.getName());
+ imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
+ assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 10);
- image = InternetResourceBuilder.getInstance().createResource(null, SliderArrowSelectedImage.class.getName());
- imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
- assertTrue( imageDim.getWidth() == 7 && imageDim.getHeight() == 8);
+ image = InternetResourceBuilder.getInstance().createResource(null,
+ SliderArrowImage.class.getName());
+ imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
+ assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8);
+
+ image = InternetResourceBuilder.getInstance().createResource(null,
+ SliderArrowSelectedImage.class.getName());
+ imageDim = ((Java2Dresource) image).getDimensions(facesContext, null);
+ assertTrue(imageDim.getWidth() == 7 && imageDim.getHeight() == 8);
}
-
+
public void testRenderImages() throws Exception {
- renderView();
- InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
- InternetResource resource = builder.getResource("org/richfaces/renderkit/html/css/slider.xcss");
- assertNotNull(resource);
- String uri = "http:" + resource.getUri(facesContext, null);
- Page page = webClient.getPage(uri);
- assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
+ renderView();
+ InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
+ InternetResource resource = builder.getResource("css/slider.xcss");
+ assertNotNull(resource);
+ String uri = "http:" + resource.getUri(facesContext, null);
+ Page page = webClient.getPage(uri);
+ assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse
+ .SC_OK);
- String[] resources = new String[] {
- SliderArrowImage.class.getName(),
- SliderArrowSelectedImage.class.getName(),
- SliderFieldGradient.class.getName(),
- SliderTrackGradient.class.getName()
- };
-
- for (int i = 0; i < resources.length; i++) {
- resource = builder.getResource(resources[i]);
- assertNotNull(resource);
- uri = "http:" + resource.getUri(facesContext, null);
- page = webClient.getPage(uri);
- assertTrue(page.getWebResponse().getStatusCode() == HttpServletResponse.SC_OK);
- ImageInfo info = new ImageInfo();
- info.setInput(page.getWebResponse().getContentAsStream());
- //image recognizable?
- assertTrue(info.check());
- assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());
- }
+ String[] resources = new String[]{
+ SliderArrowImage.class.getName(),
+ SliderArrowSelectedImage.class.getName(),
+ SliderFieldGradient.class.getName(),
+ SliderTrackGradient.class.getName()
+ };
+
+ for (int i = 0; i < resources.length; i++) {
+ resource = builder.getResource(resources[i]);
+ assertNotNull(resource);
+ uri = "http:" + resource.getUri(facesContext, null);
+ page = webClient.getPage(uri);
+ assertTrue(page.getWebResponse().getStatusCode()
+ == HttpServletResponse.SC_OK);
+ ImageInfo info = new ImageInfo();
+ info.setInput(page.getWebResponse().getContentAsStream());
+ //image recognizable?
+ assertTrue(info.check());
+ assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());
+ }
}
-
+
public void testUpdate() throws Exception {
- //tests if component handles value bindings correctly
- HtmlPage renderedView = renderView();
-
- String value = "66";
-
- HtmlInput htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(slider.getClientId(facesContext) + "Input");
- htmlSliderInput.setValueAttribute(value);
-
- HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
- htmlLink.click();
+ //tests if component handles value bindings correctly
+ HtmlPage renderedView = renderView();
- 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());
- }
+ String value = "66";
- UIViewRoot root = facesContext.getViewRoot();
- root.processDecodes(facesContext);
- root.processValidators(facesContext);
- root.processUpdates(facesContext);
- root.processApplication(facesContext);
-
- renderedView = renderView();
- assertTrue( value.equals(((UIInputNumberSlider)slider).getValue()) );
+ HtmlInput htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(
+ slider.getClientId(facesContext) + "Input");
+ htmlSliderInput.setValueAttribute(value);
+
+ 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());
+ }
+ externalContext.addRequestParameterMap(slider.getClientId(facesContext),
+ value);
+
+ slider.processDecodes(facesContext);
+ slider.processValidators(facesContext);
+ slider.processUpdates(facesContext);
+
+ renderedView = renderView();
+ assertTrue(value.equals(((UIInputNumberSlider) slider).getValue()));
}
-
- public void testDecode() throws Exception{
- //Tests if component accepts request parameters and stores them in submittedValue().
- //If component is immediate, validation (possibly with conversion) should occur on that phase.
- final SliderBean bean = new SliderBean();
- ((UIInputNumberSlider)slider).setValueBinding("value",
- new ValueBinding() {
- public Class getType(FacesContext context) throws EvaluationException, PropertyNotFoundException {
- return String.class;
- }
- public Object getValue(FacesContext context) throws EvaluationException, PropertyNotFoundException {
- return bean.getValue();
- }
- public boolean isReadOnly(FacesContext context) throws EvaluationException, PropertyNotFoundException {
- return false;
- }
- public void setValue(FacesContext context, Object value) throws EvaluationException, PropertyNotFoundException {
- bean.setValue((String)value);
- }
- });
- HtmlPage renderedView = renderView();
- HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
- htmlLink.click();
- externalContext.addRequestParameterMap(slider.getClientId(facesContext),"66");
- slider.processDecodes(facesContext);
- assertTrue(bean.getValue().equals("66"));
-
- ((UIInputNumberSlider)slider).setImmediate(true);
- renderedView = renderView();
- htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
- htmlLink.click();
- externalContext.addRequestParameterMap(slider.getClientId(facesContext),"wrong value");
- slider.processDecodes(facesContext);
- assertTrue(facesContext.getMessages().hasNext());
+
+ public void testDecode() throws Exception {
+ //Tests if component accepts request parameters and stores them in submittedValue().
+ //If component is immediate, validation (possibly with conversion) should occur on that phase.
+ final SliderBean bean = new SliderBean();
+ ((UIInputNumberSlider) slider).setValueBinding("value",
+ new ValueBinding() {
+ public Class getType(FacesContext context) throws
+ EvaluationException,
+ PropertyNotFoundException {
+ return String.class;
+ }
+
+ public Object getValue(FacesContext context) throws
+ EvaluationException,
+ PropertyNotFoundException {
+ return bean.getValue();
+ }
+
+ public boolean isReadOnly(FacesContext context) throws
+ EvaluationException,
+ PropertyNotFoundException {
+ return false;
+ }
+
+ public void setValue(FacesContext context, Object value)
+ throws EvaluationException,
+ PropertyNotFoundException {
+ bean.setValue((String) value);
+ }
+ });
+ HtmlPage renderedView = renderView();
+ HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(
+ command.getClientId(facesContext));
+ htmlLink.click();
+ externalContext.addRequestParameterMap(slider.getClientId(facesContext),
+ "66");
+ slider.processDecodes(facesContext);
+ assertTrue(bean.getValue().equals("66"));
+
+ ((UIInputNumberSlider) slider).setImmediate(true);
+ renderedView = renderView();
+ htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(
+ command.getClientId(facesContext));
+ htmlLink.click();
+ externalContext.addRequestParameterMap(slider.getClientId(facesContext),
+ "wrong value");
+ slider.processDecodes(facesContext);
+ assertTrue(facesContext.getMessages().hasNext());
}
-
- public void testValidate() throws Exception{
- HtmlPage renderedView = renderView();
- HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
- htmlLink.click();
- externalContext.addRequestParameterMap(slider.getClientId(facesContext),"wrong value");
- slider.processDecodes(facesContext);
- slider.processValidators(facesContext);
-
- assertTrue(facesContext.getMessages().hasNext());
-
+ public void testValidate() throws Exception {
+ HtmlPage renderedView = renderView();
+
+ HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(
+ command.getClientId(facesContext));
+ htmlLink.click();
+ externalContext.addRequestParameterMap(slider.getClientId(facesContext),
+ "wrong value");
+ slider.processDecodes(facesContext);
+ slider.processValidators(facesContext);
+
+ assertTrue(facesContext.getMessages().hasNext());
+
}
-
- private class SliderBean {
-
- private String value;
-
- SliderBean (){
- this.value = "66";
- }
- public String getValue() {
- return value;
- }
+ private class SliderBean {
- public void setValue(String value) {
- this.value = value;
- }
-
+ private String value;
+
+ SliderBean() {
+ this.value = "66";
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
}
-
+
}
\ No newline at end of file
17 years, 8 months
JBoss Rich Faces SVN: r741 - trunk/richfaces/panelbar/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-05-14 05:06:57 -0400 (Mon, 14 May 2007)
New Revision: 741
Modified:
trunk/richfaces/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java
Log:
test fixed
Modified: trunk/richfaces/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java
===================================================================
--- trunk/richfaces/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java 2007-05-14 09:05:50 UTC (rev 740)
+++ trunk/richfaces/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java 2007-05-14 09:06:57 UTC (rev 741)
@@ -215,7 +215,7 @@
assertNotNull(links);
HtmlElement link = (HtmlElement) links.get(0);
assertTrue(link.getAttributeValue("href").contains(
- "org/richfaces/renderkit/html/css/panelbar.xcss"));
+ "css/panelbar.xcss"));
}
/**
17 years, 8 months
JBoss Rich Faces SVN: r740 - trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: a.izobov
Date: 2007-05-14 05:05:50 -0400 (Mon, 14 May 2007)
New Revision: 740
Modified:
trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java
Log:
test fixed
Modified: trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java
===================================================================
--- trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java 2007-05-14 08:34:21 UTC (rev 739)
+++ trunk/richfaces/menu-components/src/test/java/org/richfaces/renderkit/html/MenuItemRendererBaseTest.java 2007-05-14 09:05:50 UTC (rev 740)
@@ -94,7 +94,7 @@
menuItem.setSubmitMode(null);
assertEquals(menuItem.getParent(), menu);
String resultMode = renderer.resolveSubmitMode(menuItem);
- assertEquals(resultMode, MenuComponent.MODE_AJAX);
+ assertEquals(resultMode, MenuComponent.MODE_SERVER);
menuItem.setSubmitMode(MenuComponent.MODE_NONE);
resultMode = renderer.resolveSubmitMode(menuItem);
17 years, 8 months
JBoss Rich Faces SVN: r739 - trunk/richfaces/dataFilterSlider/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: A.Skokov
Date: 2007-05-14 04:34:21 -0400 (Mon, 14 May 2007)
New Revision: 739
Modified:
trunk/richfaces/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
Log:
tests fixed
Modified: trunk/richfaces/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java
===================================================================
--- trunk/richfaces/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-05-11 17:29:23 UTC (rev 738)
+++ trunk/richfaces/dataFilterSlider/src/test/java/org/richfaces/component/DataFilterSliderComponentTest.java 2007-05-14 08:34:21 UTC (rev 739)
@@ -74,17 +74,17 @@
/**
* Create the test case
- *
+ *
* @param testName
* name of the test case
*/
-
+
static {
javaScripts.add("org.ajax4jsf.framework.resource.PrototypeScript");
javaScripts.add("org.ajax4jsf.framework.ajax.AjaxScript");
javaScripts.add("scripts/scriptaculous-js-1.6.5/src/slider.js");
}
-
+
public DataFilterSliderComponentTest(String testName) {
super(testName);
}
@@ -98,7 +98,7 @@
command = new HtmlCommandLink();
command.setId("command");
form.getChildren().add(command);
-
+
dfSlider = application.createComponent(UIDataFltrSlider.COMPONENT_TYPE);
dfSlider.setId("slider");
((UIDataFltrSlider)dfSlider).setStartRange(Integer.valueOf(0));
@@ -116,7 +116,7 @@
/**
* Test component renders correctly
- *
+ *
* @throws Exception
*/
public void testComponent() throws Exception {
@@ -124,36 +124,36 @@
HtmlPage renderedView = renderView();
HtmlElement htmlSlider = renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider-range");
- assertTrue(htmlSlider.getAttributeValue("class").contains("range"));
+ assertTrue(htmlSlider.getAttributeValue("class").contains("range"));
assertTrue(((HtmlElement)htmlSlider.getParentNode()).getAttributeValue("class").contains("slider-container"));
-
+
HtmlElement htmlSliderTrailer = renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider-trailer");
assertTrue(htmlSliderTrailer.getAttributeValue("class").contains("trailer"));
-
+
HtmlElement htmlSliderTrack = renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider-track");
assertTrue(htmlSliderTrack.getAttributeValue("class").contains("track"));
assertTrue(htmlSliderTrack.getAttributeValue("style").equals("width:" + dfSlider.getAttributes().get("width")));
HtmlElement htmlSliderHandle = renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider-handle");
assertTrue(htmlSliderHandle.getAttributeValue("class").contains("handle"));
-
+
HtmlElement htmlSliderInput = renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider_val");
assertTrue(((HtmlInput)htmlSliderInput).getTypeAttribute().equals("text"));
assertTrue(htmlSliderInput.getAttributeValue("class").contains("slider-input-field"));
assertTrue(htmlSliderInput.getAttributeValue("onchange").equals("dataFilterSlider.setValue(this.value);"));
}
-
+
public void testImages() throws Exception {
InternetResource image = InternetResourceBuilder.getInstance().createResource(null, SliderFieldGradient.class.getName());
Dimension imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
assertTrue( imageDim.getWidth() == 31 && imageDim.getHeight() == 55);
-
+
image = InternetResourceBuilder.getInstance().createResource(null, SliderTrackGradient.class.getName());
imageDim = ((Java2Dresource)image).getDimensions(facesContext, null);
assertTrue( imageDim.getWidth() == 7 && imageDim.getHeight() == 10);
}
-
+
public void testRenderImages() throws Exception {
renderView();
InternetResourceBuilder builder = ResourceBuilderImpl.getInstance();
@@ -167,7 +167,7 @@
SliderFieldGradient.class.getName(),
SliderTrackGradient.class.getName(),
};
-
+
for (int i = 0; i < resources.length; i++) {
resource = builder.getResource(resources[i]);
assertNotNull(resource);
@@ -181,14 +181,14 @@
assertEquals(ImageInfo.FORMAT_GIF, info.getFormat());
}
}
-
+
public void testHiddenInput() throws Exception {
((UIDataFltrSlider)dfSlider).setManualInput(false);
HtmlPage renderedView = renderView();
HtmlElement htmlSliderInput = renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider_val");
assertTrue(((HtmlInput)htmlSliderInput).getTypeAttribute().equals("hidden"));
}
-
+
public void testRenderStyle() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
@@ -197,7 +197,7 @@
HtmlElement link = (HtmlElement) links.get(0);
assertTrue(link.getAttributeValue("href").contains("css/dataFilterSlider.xcss"));
}
-
+
public void testRenderScript() throws Exception {
HtmlPage page = renderView();
assertNotNull(page);
@@ -225,37 +225,37 @@
public void testUpdate() throws Exception {
//tests if component handles value bindings correctly
HtmlPage renderedView = renderView();
-
+
String value = "5";
-
+
HtmlInput htmlSliderInput = (HtmlInput) renderedView.getHtmlElementById(dfSlider.getClientId(facesContext)+"slider_val");
htmlSliderInput.setValueAttribute(value);
-
+
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());
}
- UIViewRoot root = facesContext.getViewRoot();
- root.processDecodes(facesContext);
- root.processValidators(facesContext);
- root.processUpdates(facesContext);
- root.processApplication(facesContext);
-
- renderedView = renderView();
- assertTrue( value.equals(String.valueOf(((UIDataFltrSlider)dfSlider).getHandleValue())));
+ externalContext.addRequestParameterMap(dfSlider.getClientId(facesContext)+"slider_val", value);
+
+ dfSlider.processDecodes(facesContext);
+ dfSlider.processValidators(facesContext);
+ dfSlider.processUpdates(facesContext);
+
+ renderedView = renderView();
+ assertTrue( value.equals(String.valueOf(((UIDataFltrSlider)dfSlider).getHandleValue())));
}
-
+
public void testDecode() throws Exception{
- //Tests if component accepts request parameters and stores them in submittedValue().
+ //Tests if component accepts request parameters and stores them in submittedValue().
//If component is immediate, validation (possibly with conversion) should occur on that phase.
final SliderBean bean = new SliderBean();
- ((UIDataFltrSlider)dfSlider).setValueBinding("value",
+ ((UIDataFltrSlider)dfSlider).setValueBinding("value",
new ValueBinding() {
public Class getType(FacesContext context) throws EvaluationException, PropertyNotFoundException {
return String.class;
@@ -277,33 +277,33 @@
dfSlider.processDecodes(facesContext);
assertTrue(bean.getValue().equals("66"));
}
-
+
public void testListener() throws Exception{
HtmlPage renderedView = renderView();
-
+
HtmlAnchor htmlLink = (HtmlAnchor) renderedView.getHtmlElementById(command.getClientId(facesContext));
htmlLink.click();
-
- MethodBinding binding = new MethodBinding(){
+
+ MethodBinding binding = new MethodBinding(){
public Object invoke(FacesContext context, Object[] params) throws EvaluationException, MethodNotFoundException {
facesContext.addMessage(dfSlider.getClientId(facesContext), new FacesMessage("Method invoked!"));
- return "invoked";
+ return "invoked";
}
public Class getType(FacesContext context) throws MethodNotFoundException {
return String.class;
}
};
-
+
DataFilterSliderEvent event = new DataFilterSliderEvent( ((UIDataFltrSlider) dfSlider), new Integer(20), new Integer (50 ) );
new DataFilterSliderAdapter(binding).processSlider(event);
assertTrue(facesContext.getMessages().hasNext());
- }
-
+ }
+
private final class SliderBean {
-
+
private String value;
-
+
SliderBean (){
this.value = "66";
}
@@ -315,6 +315,6 @@
public void setValue(String value) {
this.value = value;
}
-
+
}
}
\ No newline at end of file
17 years, 8 months
JBoss Rich Faces SVN: r738 - trunk/richfaces/assembly.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-11 13:29:23 -0400 (Fri, 11 May 2007)
New Revision: 738
Modified:
trunk/richfaces/assembly/pom.xml
Log:
Bug AJSF-24
Modified: trunk/richfaces/assembly/pom.xml
===================================================================
--- trunk/richfaces/assembly/pom.xml 2007-05-11 15:32:24 UTC (rev 737)
+++ trunk/richfaces/assembly/pom.xml 2007-05-11 17:29:23 UTC (rev 738)
@@ -18,13 +18,16 @@
<configuration>
<library>
<prefix>org.richfaces</prefix>
+ <description>RichFaces components</description>
<taglib>
<shortName>rich</shortName>
<taglib>richfaces</taglib>
<uri>
http://richfaces.ajax4jsf.org/rich
</uri>
+ <displayName>RichFaces</displayName>
</taglib>
+
</library>
</configuration>
<executions>
17 years, 8 months
JBoss Rich Faces SVN: r737 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-11 11:32:24 -0400 (Fri, 11 May 2007)
New Revision: 737
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-05-11 15:32:13 UTC (rev 736)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ColumnWalker.java 2007-05-11 15:32:24 UTC (rev 737)
@@ -21,7 +21,7 @@
public class ColumnWalker {
static void iterateOverHeadersFooters(FacesContext context, UIComponent component,
- ColumnVisitor visitor, ResponseWriter writer) throws IOException{
+ ColumnVisitor visitor, ResponseWriter writer, GridRendererState state) throws IOException{
if(context == null || component == null){
throw new NullPointerException();
@@ -41,7 +41,11 @@
UIComponent kid = (UIComponent) iter.next();
if (kid.isRendered()) {
if (kid instanceof UIScrollableGridColumn){
- visitor.visit(context, (UIScrollableGridColumn)kid, writer, null);
+ if(state.isFrozenColumn()){
+ int i = state.getFrozenColumnCount() - 1;
+ state.setFrozenColumnCount(i);
+ }
+ visitor.visit(context, (UIScrollableGridColumn)kid, writer, state);
}
}
}
@@ -68,14 +72,16 @@
UIComponent kid = (UIComponent) iter.next();
if (kid.isRendered()) {
if (kid instanceof UIScrollableGridColumn){
-
UIScrollableGridColumn column = (UIScrollableGridColumn)kid;
- Boolean frozen = ((Boolean)column.getAttributes().get("frozen"));
+
+ if(state.isFrozenColumn()){
+ int i = state.getFrozenColumnCount();
+ i--;
+ state.setFrozenColumnCount(i);
+ visitor.visit(context, column, writer,state);
- if(state.is_isFrozenColumn() && frozen.booleanValue()){
- visitor.visit(context, (UIScrollableGridColumn)kid, writer,state);
- } else if(!state.is_isFrozenColumn() && !frozen.booleanValue()){
- visitor.visit(context, (UIScrollableGridColumn)kid, writer, state);
+ } else if(!state.isFrozenColumn()){
+ visitor.visit(context,column, writer, state);
}
state.nextCell();
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-05-11 15:32:13 UTC (rev 736)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/GridRendererState.java 2007-05-11 15:32:24 UTC (rev 737)
@@ -11,6 +11,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
+import org.apache.commons.digester.xmlrules.FromXmlRuleSet;
import org.richfaces.component.UIScrollableGrid;
/**
@@ -32,7 +33,7 @@
private int _columns = 0;
- private boolean _isFrozenColumn = false;
+ private int _frozenColumnCount = -1;
private UIScrollableGrid _grid;
@@ -260,11 +261,16 @@
this.rowKey = rowKey;
}
- public boolean is_isFrozenColumn() {
- return _isFrozenColumn;
+ public boolean isFrozenColumn() {
+ return _frozenColumnCount < 0 ? false:true;
}
- public void set_isFrozenColumn(boolean frozenColumn) {
- _isFrozenColumn = frozenColumn;
+ public void setFrozenColumnCount(int columnCount) {
+ _frozenColumnCount = columnCount;
}
+
+ public int getFrozenColumnCount() {
+ return _frozenColumnCount;
+ }
+
}
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-11 15:32:13 UTC (rev 736)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer.java 2007-05-11 15:32:24 UTC (rev 737)
@@ -10,6 +10,7 @@
import org.ajax4jsf.ajax.repeat.DataVisitor;
import org.ajax4jsf.framework.ajax.AjaxContext;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.ComponentVariables;
import org.ajax4jsf.framework.renderer.ComponentsVariableResolver;
@@ -43,7 +44,8 @@
ResponseWriter writer, GridRendererState state) throws IOException {
writer.startElement(HTML.td_ELEM, column);
- getUtils().writeAttribute(writer, "frozen", column.getAttributes().get("frozen"));
+ String frozen = Boolean.toString(state.isFrozenColumn());
+ getUtils().writeAttribute(writer, "frozen",frozen );
getUtils().writeAttribute(writer, "style",column.getAttributes().get("style"));
writer.writeText("\n", null);
@@ -89,6 +91,21 @@
}
};
+ private final DataVisitor rowsRenderer = new DataVisitor(){
+
+ public void process(FacesContext context, Object rowIndex, Object argument) throws IOException {
+ GridRendererState state = (GridRendererState)argument;
+ UIScrollableGrid grid = state.getGrid();
+ int index = ((Integer)rowIndex).intValue();
+ grid.setRowKey(rowIndex);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.TR_ELEMENT, grid);
+ getUtils().writeAttribute(writer, "id","row_"+ index);
+ getUtils().writeAttribute(writer, "class","ClientUI_Grid_BR");
+ ColumnWalker.iterateOverCells(context, grid, cellRenderer, writer, state);
+ writer.endElement(HTML.TR_ELEMENT);
+ }
+ };
protected String getJavaScriptVarName(FacesContext context, UIScrollableGrid grid) {
String id = grid.getBaseClientId(context);
@@ -132,13 +149,13 @@
getUtils().writeAttribute(writer, "style","position: absolute; left: 0px; top: 0px; display: block; width: 100%");
writer.writeText("\n", null);
writer.startElement("tbody", grid);
+// state.setGrid(grid);
DataVisitor rowsRenderer = new DataVisitor(){
public void process(FacesContext context, Object rowIndex, Object argument) throws IOException {
-
+
int index = ((Integer)rowIndex).intValue();
- state.setRowIndex(index);
grid.setRowKey(rowIndex);
ResponseWriter writer = context.getResponseWriter();
writer.startElement(HTML.TR_ELEMENT, grid);
@@ -149,7 +166,8 @@
}
};
- state.set_isFrozenColumn(true);
+ state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
+
grid.walk(context, rowsRenderer, state);
writer.endElement("tbody");
@@ -168,7 +186,8 @@
getUtils().writeAttribute(writer, "style","position: absolute; left: 0px; top: 0px; display: block; width: 100%");
writer.writeText("\n", null);
- state.set_isFrozenColumn(false);
+ state.setFrozenColumnCount(-1);
+
grid.walk(context, rowsRenderer, state);
writer.endElement("tbody");
writer.endElement("table");
@@ -177,18 +196,22 @@
}
- public void renderHeaders(FacesContext context, UIComponent component
+ public void renderHeaders(FacesContext context, UIScrollableGrid component
)throws IOException{
ResponseWriter writer = context.getResponseWriter();
- ColumnWalker.iterateOverHeadersFooters(context, component, headerRenderer, writer);
+ final GridRendererState state = GridRendererState.getRendererState(context);
+ state.setFrozenColumnCount(((Integer)component.getAttributes().get("frozenColCount")).intValue());
+ ColumnWalker.iterateOverHeadersFooters(context, component, headerRenderer, writer, state);
}
- public void renderFooters(FacesContext context, UIComponent component
+ public void renderFooters(FacesContext context, UIScrollableGrid component
) throws IOException{
ResponseWriter writer = context.getResponseWriter();
- ColumnWalker.iterateOverHeadersFooters(context, component, footerRenderer, writer);
+ final GridRendererState state = GridRendererState.getRendererState(context);
+ state.setFrozenColumnCount(((Integer)component.getAttributes().get("frozenColCount")).intValue());
+ ColumnWalker.iterateOverHeadersFooters(context, component, footerRenderer, writer, state);
}
public void setUpState(FacesContext context, UIScrollableGrid grid) {
@@ -210,67 +233,63 @@
protected void doDecode(FacesContext context, UIComponent component) {
- String value = null;
+ super.doDecode(context, component);
if(component instanceof UIScrollableGrid){
+
UIScrollableGrid grid = (UIScrollableGrid)component;
ExternalContext externalContext = context.getExternalContext();
String clientId = grid.getClientId(context) + "_state_input";
Map parameters = externalContext.getRequestParameterMap();
if(parameters.containsKey(clientId)){
- value = (String)parameters.get(clientId);
-
+ String submitedState = (String)parameters.get(clientId);
+ String [] values = submitedState.split(",");
+ grid.setRow_count(Integer.getInteger(values[0]));
+ grid.setDataIndex(Integer.getInteger(values[1]));
+ grid.setStartRow(Integer.getInteger(values[2]));
+ grid.queueEvent(new AjaxEvent(grid));
}
+
}
- super.doDecode(context, component);
}
-
-// for benchmark
- public void encodeBegin(FacesContext context, UIComponent component
- ) throws IOException {
-
- if(AjaxContext.getCurrentInstance().isAjaxRequest()){
- }else{
- super.encodeBegin(context, component);
- }
+ public void renderAjaxChildren(FacesContext context, UIComponent component)throws IOException{
+ UIScrollableGrid grid = (UIScrollableGrid)component;
+ grid.setFirst(grid.getDataIndex().intValue());
+ grid.setRows(grid.getRow_count().intValue());
+ GridRendererState state = GridRendererState.getRendererState(context);
+ grid.walk(context, rowsRenderer, state);
}
- public void encodeEnd(FacesContext context, UIComponent component
- ) throws IOException {
- if(AjaxContext.getCurrentInstance().isAjaxRequest()){
- }else{
- super.encodeEnd(context, component);
- }
- }
+// for benchmark
+// public void encodeBegin(FacesContext context, UIComponent component
+// ) throws IOException {
+//
+// if(AjaxContext.getCurrentInstance().isAjaxRequest()){
+// }else{
+// super.encodeBegin(context, component);
+// }
+// }
+//
+// public void encodeEnd(FacesContext context, UIComponent component
+// ) throws IOException {
+//
+// if(AjaxContext.getCurrentInstance().isAjaxRequest()){
+// }else{
+// super.encodeEnd(context, component);
+// }
+// }
-
-
public void encodeChildren(FacesContext context, UIComponent component
) throws IOException {
-
- ResponseWriter writer = context.getResponseWriter();
AjaxContext ajaxContext = AjaxContext.getCurrentInstance();
if(ajaxContext.isAjaxRequest()){
- writer.startElement("div", component);
- for (int i = 0; i < 100; i++) {
- for (int j = 0; j < 18; j++) {
- writer.startElement("span", component);
-
- String id = "bc_" + i + "_" + j;
- getUtils().writeAttribute(writer,"id", id);
- writer.writeText(i + ":" + j + " test" + i, null);
- writer.endElement("span");
- ajaxContext.addRenderedArea(id);
- }
-
- }
- writer.endElement("div");
-
+// renderAjaxChildren(context, component);
}else{
super.encodeChildren(context, component);
}
}
+
}
17 years, 8 months
JBoss Rich Faces SVN: r736 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-11 11:32:13 -0400 (Fri, 11 May 2007)
New Revision: 736
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-05-11 15:32:03 UTC (rev 735)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/component/UIScrollableGrid.java 2007-05-11 15:32:13 UTC (rev 736)
@@ -3,14 +3,20 @@
*/
package org.richfaces.component;
+import java.io.IOException;
import java.util.Iterator;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
+import javax.faces.model.DataModel;
+import org.ajax4jsf.ajax.repeat.DataVisitor;
+import org.ajax4jsf.ajax.repeat.ExtendedDataModel;
import org.ajax4jsf.ajax.repeat.UIRepeat;
+import org.ajax4jsf.framework.ajax.AjaxContext;
import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.apache.commons.collections.iterators.IteratorChain;
@@ -22,10 +28,67 @@
public class UIScrollableGrid extends UIRepeat{
- public UIScrollableGrid() {
- super();
+ private Integer _row_count = new Integer(0) ;
+
+ private Integer _dataIndex = new Integer(0);
+
+ private Integer _startRow = new Integer(0);
+
+
+ public Integer getDataIndex() {
+ return _dataIndex;
}
+
+
+
+ public void setDataIndex(Integer dataIndex) {
+ this._dataIndex = dataIndex;
+ }
+
+
+
+ public Integer getRow_count() {
+ return _row_count;
+ }
+
+
+
+ public void setRow_count(Integer row_count) {
+ this._row_count = row_count;
+ }
+
+
+
+ public Integer getStartRow() {
+ return _startRow;
+ }
+
+
+
+ public void setStartRow(Integer startRow) {
+ this._startRow = startRow;
+ }
+ public Object saveState(FacesContext context) {
+ Object values[] = new Object[4];
+ values[0] = super.saveState(context);
+ values[1] = _row_count;
+ values[2] = _startRow;
+ values[3] = _dataIndex;
+
+ return (Object)values;
+
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[])state;
+ super.restoreState(context, values[0]);
+ _row_count = (Integer)values[1];
+ _startRow = (Integer)values[2];
+ _dataIndex = (Integer)values[3];
+
+ }
+
protected Iterator dataChildren() {
IteratorChain chain = new IteratorChain();
@@ -55,10 +118,22 @@
return chain;
}
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+ if(event instanceof AjaxEvent){
+ AjaxContext.getCurrentInstance().addComponentToAjaxRender(this);
+ }
+ }
+
public void queueEvent(FacesEvent event) {
if(event instanceof AjaxEvent){
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
}
super.queueEvent(event);
}
+
+ public void walk(FacesContext faces, DataVisitor visitor, Object argument) throws IOException {
+
+ super.walk(faces, visitor, argument);
+ }
}
17 years, 8 months