JBoss Rich Faces SVN: r12510 - trunk/test-applications/realworld.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-01-30 13:04:53 -0500 (Fri, 30 Jan 2009)
New Revision: 12510
Modified:
trunk/test-applications/realworld/pom.xml
Log:
Modified: trunk/test-applications/realworld/pom.xml
===================================================================
--- trunk/test-applications/realworld/pom.xml 2009-01-30 18:01:09 UTC (rev 12509)
+++ trunk/test-applications/realworld/pom.xml 2009-01-30 18:04:53 UTC (rev 12510)
@@ -14,12 +14,12 @@
<properties>
<projectName>realworld</projectName>
- <richfacesVersion>3.3.1-SNAPSHOT</richfacesVersion>
+ <richfacesVersion>3.3.0.GA</richfacesVersion>
<seamVersion>2.1.0.SP1</seamVersion>
<faceletsVersion>1.1.14</faceletsVersion>
<jbosshome>${project.basedir}/target/installs/jboss-4.2.3.GA/jboss-4.2.3.GA</jbosshome>
<jbosscontext>default</jbosscontext>
- <jboss.installer.url>file:D:\Install\Java\jboss-4.2.3.GA.zip</jboss.installer.url>
+ <jboss.installer.url>file:E:\apps\jboss\jboss-4.2.3.GA.zip</jboss.installer.url>
</properties>
<repositories>
<repository>
15 years, 10 months
JBoss Rich Faces SVN: r12509 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/dataGrid and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-01-30 13:01:09 -0500 (Fri, 30 Jan 2009)
New Revision: 12509
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataGridBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGrid.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java
Log:
RF-5682
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataGridBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataGridBean.java 2009-01-30 17:54:05 UTC (rev 12508)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataGridBean.java 2009-01-30 18:01:09 UTC (rev 12509)
@@ -8,6 +8,7 @@
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
import javax.faces.event.ActionEvent;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
@@ -133,4 +134,20 @@
public Boolean getRendered() {
return rendered;
}
+
+ public Converter getRowKeyConverter() {
+ return new Converter(){
+
+ public Object getAsObject(FacesContext context,
+ UIComponent component, String value) {
+ return new Integer(value.substring(2));
+ }
+
+ public String getAsString(FacesContext context,
+ UIComponent component, Object value) {
+ return "c_" + value.toString();
+ }
+
+ };
+ }
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGrid.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGrid.xhtml 2009-01-30 17:54:05 UTC (rev 12508)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGrid.xhtml 2009-01-30 18:01:09 UTC (rev 12509)
@@ -24,7 +24,8 @@
elements="#{dataGrid.elements}" ajaxKeys="#{dataGrid.ajaxKeys}"
stateVar="stateVar" rowKeyVar="rowKeyVar"
componentState="#{componentState}"
- rendered="#{dataGrid.rendered}">
+ rendered="#{dataGrid.rendered}"
+ rowKeyConverter="#{dataGrid.rowKeyConverter}">
<h:panelGroup>
<h:outputText id="rowKeyVar" value="#{rowKeyVar} "></h:outputText>
<h:outputText id="first" value="#{stateVar.range.firstRow} "></h:outputText>
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java 2009-01-30 17:54:05 UTC (rev 12508)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java 2009-01-30 18:01:09 UTC (rev 12509)
@@ -97,11 +97,11 @@
@Test
public void testVars(Template template) {
init(template);
- Assert.assertEquals(selenium.getText(dataGrid + ":2:first"), "0", "Attribute 'stateVar' works wrong.");
- Assert.assertEquals(selenium.getText(dataGrid + ":2:rows"), "0", "Attribute 'stateVar' works wrong.");
+ Assert.assertEquals(selenium.getText(dataGrid + ":c_2:first"), "0", "Attribute 'stateVar' works wrong.");
+ Assert.assertEquals(selenium.getText(dataGrid + ":c_2:rows"), "0", "Attribute 'stateVar' works wrong.");
int rows = selenium.getXpathCount("id('"+ dataGrid + "')/tbody/tr").intValue();
for (int i = 0; i < rows; i++) {
- Assert.assertEquals(selenium.getText(dataGrid + ":" + i + ":rowKeyVar"), Integer.toString(i));
+ Assert.assertEquals(selenium.getText(dataGrid + ":c_" + i + ":rowKeyVar"), Integer.toString(i));
}
}
@@ -111,8 +111,8 @@
@Test
public void testComponentState(Template template) {
init(template);
- Assert.assertEquals(selenium.getText(dataGrid + ":2:firstState"), "0", "Attribute 'componentState' works wrong.");
- Assert.assertEquals(selenium.getText(dataGrid + ":2:rowsState"), "0", "Attribute 'componentState' works wrong.");
+ Assert.assertEquals(selenium.getText(dataGrid + ":c_2:firstState"), "0", "Attribute 'componentState' works wrong.");
+ Assert.assertEquals(selenium.getText(dataGrid + ":c_2:rowsState"), "0", "Attribute 'componentState' works wrong.");
}
/**
@@ -140,6 +140,15 @@
autoTester.testHTMLEvents();
}
+ /**
+ * rowKeyConverter outputs correct client ids
+ */
+ @Test
+ public void testRowKeyConverter(Template template) {
+ init(template);
+ Assert.assertTrue(selenium.getAttribute("xpath=id('"+ dataGrid + "')/tbody/tr[3]/td@id").endsWith(":c_2"), "Attribute 'rowKeyConverter' works wrong.");
+ }
+
private void chekStructure(int ... notEqualRows) {
String dataTableRowLocator = "id('"+ dataTable + "')/tbody/tr";
int count = selenium.getXpathCount(dataTableRowLocator).intValue();
15 years, 10 months
JBoss Rich Faces SVN: r12508 - in trunk/test-applications/realworld/web/src/main: java/org/richfaces/realworld/util and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: andrei_exadel
Date: 2009-01-30 12:54:05 -0500 (Fri, 30 Jan 2009)
New Revision: 12508
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileItem.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ImageUtils.java
trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/web.xml
trunk/test-applications/realworld/web/src/main/webapp/includes/fileUpload/multyMode.xhtml
Log:
Upload images to temp files
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileItem.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileItem.java 2009-01-30 17:17:05 UTC (rev 12507)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileItem.java 2009-01-30 17:54:05 UTC (rev 12508)
@@ -20,6 +20,8 @@
*/
package org.richfaces.realworld.fileupload;
+import java.io.File;
+
import org.richfaces.realworld.domain.Image;
public class FileItem {
@@ -32,6 +34,8 @@
private byte[] data;
+ private File file;
+
public byte[] getData() {
return data;
}
@@ -61,4 +65,12 @@
public void setImage(Image image) {
this.image = image;
}
+ public File getFile() {
+ return file;
+ }
+ public void setFile(File file) {
+ this.file = file;
+ }
+
+
}
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-01-30 17:17:05 UTC (rev 12507)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-01-30 17:54:05 UTC (rev 12508)
@@ -30,7 +30,6 @@
import javax.imageio.ImageIO;
import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.richfaces.realworld.service.Constants;
@@ -133,13 +132,17 @@
public boolean addImage(String fileName, byte[] data) {
createDirectoryIfNotExist(fileName);
+ /*
try {
+
writeFileTodisk(data, fileName, 0, 0, "" );
writeFileTodisk(data, fileName, 100, 100, _MINI );
writeFileTodisk(data, fileName, 500, 500, _MEDIUM );
+
} catch (IOException e) {
return false;
}
+ */
return true;
}
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-01-30 17:17:05 UTC (rev 12507)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-01-30 17:54:05 UTC (rev 12508)
@@ -21,7 +21,10 @@
package org.richfaces.realworld.fileupload;
-import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
@@ -46,6 +49,7 @@
import org.richfaces.realworld.navigation.NavigationEnum;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.util.ConversationState;
+import org.richfaces.realworld.util.ImageUtils;
import com.drew.imaging.jpeg.JpegMetadataReader;
import com.drew.imaging.jpeg.JpegProcessingException;
@@ -62,7 +66,7 @@
@Name("fileUploadBean")
@Scope(ScopeType.CONVERSATION)
public class FileUploadBean implements Serializable {
-
+
@In
private User user;
@In("#{messages['file_processing_error']}")
@@ -96,11 +100,16 @@
public synchronized void listener(UploadEvent event) throws Exception {
UploadItem item = event.getUploadItem();
+
FileItem file = new FileItem();
- file.setLength(item.getData().length);
- file.setData(item.getData());
+
+ file.setLength(item.getFileSize());
+ //file.setData(item.getData());
+ file.setFile(item.getFile());
file.setSelected(false);
Image image = constructImage(item, file);
+
+ resizeImages(item, fileManager.getUploadRoot() + image.getPath());
try {
extractMetadata(file, image);
} catch (JpegProcessingException e1) {
@@ -114,6 +123,10 @@
fileWrapper.getFiles().add(file);
}
+ private void resizeImages(UploadItem src, String pathToUpload) throws IOException {
+ ImageUtils.resizeImage(src, pathToUpload, ImageUtils.MINI, ImageUtils.MEDIUM);
+ }
+
@Observer(Constants.FILE_UPLOAD_CLEAR_EVENT)
public void clearUploadData() {
fileWrapper.getFiles().clear();
@@ -218,7 +231,7 @@
image.setUploaded(new Date());
image.setDescription(SAMPLE_DESCRIPTION);
image.setName(SAMPLE_NAME);
- image.setSize(file.getLength() / Constants.KB);
+ image.setSize(file.getLength());
String albumPath = conversationState.getSelectedAlbum().getAlbumPathFromParents(conversationState.getSelectedAlbum(),
Constants.SLASH, true);
image.setPath(user.getLogin() + Constants.SLASH + albumPath + item.getFileName());
@@ -243,8 +256,8 @@
}
private void extractMetadata(FileItem file, Image image)
- throws JpegProcessingException, MetadataException {
- InputStream in = new ByteArrayInputStream(file.getData());
+ throws JpegProcessingException, MetadataException, FileNotFoundException {
+ InputStream in = new FileInputStream(file.getFile());
Metadata metadata = JpegMetadataReader.readMetadata(in);
Directory exifDirectory = metadata.getDirectory(ExifDirectory.class);
Directory jpgDirectory = metadata.getDirectory(JpegDirectory.class);
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java 2009-01-30 17:17:05 UTC (rev 12507)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java 2009-01-30 17:54:05 UTC (rev 12508)
@@ -29,7 +29,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Serializable;
-import org.richfaces.realworld.service.Constants;
import javax.imageio.ImageIO;
@@ -38,6 +37,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.core.Events;
+import org.richfaces.realworld.service.Constants;
@Name("imageLoader")
@Scope(ScopeType.CONVERSATION)
@@ -58,7 +58,16 @@
}else{
index = ((Long)data).intValue();
}
- stream.write(fileWrapper.getFiles().get(index).getData());
+ FileInputStream fileInputStream = new FileInputStream(fileWrapper.getFiles().get(index).getFile());
+ int read = -1;
+ byte [] bytes = new byte [4096];
+ while ((read = fileInputStream.read(bytes)) != -1) {
+ if (read == 0) {
+ break;
+ }
+ stream.write(bytes);
+ }
+ //stream.write(fileWrapper.getFiles().get(index).getData());
}
public synchronized void paintSearchImage(OutputStream stream, Object object)
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ImageUtils.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ImageUtils.java 2009-01-30 17:17:05 UTC (rev 12507)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ImageUtils.java 2009-01-30 17:54:05 UTC (rev 12508)
@@ -4,17 +4,46 @@
package org.richfaces.realworld.util;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
+import java.io.File;
import java.io.IOException;
+import javax.imageio.ImageIO;
+import javax.imageio.stream.FileImageInputStream;
+import javax.imageio.stream.ImageInputStream;
+
+import org.richfaces.model.UploadItem;
+import org.richfaces.realworld.service.Constants;
+
/**
* @author Andrey Markavtsov
*
*/
public class ImageUtils {
+
+ public static class ImageDimension {
+ public int WIDTH;
+ public int HEIGHT;
+ public String POSTFIX_NAME;
+ public ImageDimension(int width, int height, String postfix_name) {
+ super();
+ WIDTH = width;
+ HEIGHT = height;
+ POSTFIX_NAME = postfix_name;
+ }
+ };
+
+ public static final String _MEDIUM = "_medium";
+ public static final String _MINI = "_mini";
+
+ public static ImageDimension MINI = new ImageDimension(100, 100, _MINI);
+ public static ImageDimension MEDIUM = new ImageDimension(640, 480, _MEDIUM);
+
+
BufferedImage bufferedImage;
double width;
@@ -24,30 +53,30 @@
if (bufferedImage == null) {
throw new NullPointerException("Buffered image is null");
}
-
+
this.height = bufferedImage.getHeight();
this.width = bufferedImage.getWidth();
this.bufferedImage = bufferedImage;
}
- private void scaleToWidth(int width) throws IOException {
+ private BufferedImage scaleToWidth(int width) throws IOException {
double height = width * this.height / this.width;
BufferedImage newImage = new BufferedImage(width, (int) height,
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = createGraphics(newImage);
graphics2D.drawImage(bufferedImage, 0, 0, (int) width, (int) height,
null);
- bufferedImage = newImage;
+ return newImage;
}
- private void scaleToHeight(int height) throws IOException {
+ private BufferedImage scaleToHeight(int height) throws IOException {
double width = height * this.width / this.height;
BufferedImage newImage = new BufferedImage((int) width, (int) height,
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = createGraphics(newImage);
graphics2D.drawImage(bufferedImage, 0, 0, (int) width, (int) height,
null);
- bufferedImage = newImage;
+ return newImage;
}
private Graphics2D createGraphics(BufferedImage image) {
@@ -61,20 +90,59 @@
public BufferedImage resizeImage(double width, double height)
throws IOException {
-
+
if (width > height) {
- if(this.bufferedImage.getWidth() < width){
+ if (this.bufferedImage.getWidth() < width) {
return bufferedImage;
}
- scaleToWidth((int) width);
+ return scaleToWidth((int) width);
} else {
- if(this.bufferedImage.getHeight() < height){
+ if (this.bufferedImage.getHeight() < height) {
return bufferedImage;
}
- scaleToHeight((int) height);
+ return scaleToHeight((int) height);
}
- return bufferedImage;
}
+ public static void resizeImage(UploadItem image, String pathToUpload, ImageDimension ... dimensions)
+ throws IOException {
+
+ BufferedImage bufferedImage = ImageIO.read(new FileImageInputStream(image.getFile()));
+
+ ImageUtils utils = new ImageUtils(bufferedImage);
+ int width, height;
+
+ ImageIO.write(bufferedImage, Constants.JPG, new File(pathToUpload));
+
+ for (ImageDimension dimension : dimensions) {
+ String fileName = transformPath(pathToUpload,dimension.POSTFIX_NAME);
+ width = dimension.WIDTH;
+ height = dimension.HEIGHT;
+ BufferedImage resizedBuffer = bufferedImage;
+
+ if (width > height) {
+ if (bufferedImage.getWidth() > width) {
+ resizedBuffer = utils.scaleToWidth((int) width);
+ }
+ } else {
+ if (bufferedImage.getHeight() > height) {
+ resizedBuffer = utils.scaleToHeight((int) height);
+ }
+ }
+
+ if (resizedBuffer != null) {
+ ImageIO.write(resizedBuffer, Constants.JPG, new File(fileName));
+ }
+
+ }
+
+ }
+
+ public static String transformPath(String target, String substitute){
+ String begin = target.substring(0, target.lastIndexOf(Constants.DOT));
+ String end = target.substring(target.lastIndexOf(Constants.DOT));
+ return begin + substitute + end;
+ }
+
}
Modified: trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/web.xml 2009-01-30 17:17:05 UTC (rev 12507)
+++ trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/web.xml 2009-01-30 17:54:05 UTC (rev 12508)
@@ -11,7 +11,7 @@
<filter-class>org.ajax4jsf.Filter</filter-class>
<init-param>
<param-name>createTempFiles</param-name>
- <param-value>false</param-value>
+ <param-value>true</param-value>
</init-param>
<init-param>
<param-name>maxRequestSize</param-name>
@@ -81,7 +81,7 @@
<context-param>
<param-name>uploadRoot</param-name>
<param-value>
- /home/richfaces/Upload/
+ D:\Work\Projects\RichFaces\SVN\trunk\test-applications\realworld\Upload\
</param-value>
</context-param>
Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/fileUpload/multyMode.xhtml
===================================================================
(Binary files differ)
15 years, 10 months
JBoss Rich Faces SVN: r12507 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces/testng and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-01-30 12:17:05 -0500 (Fri, 30 Jan 2009)
New Revision: 12507
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGridAutoTest.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java
Log:
RF-5683
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGridAutoTest.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGridAutoTest.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGridAutoTest.xhtml 2009-01-30 17:17:05 UTC (rev 12507)
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.autoTestTemplate}">
+ <ui:define name="component">
+ <rich:dataGrid id="componentId" value="#{dataGrid.model}" var="element"
+ style="width: 100%; color: yellow"
+ styleClass="noname"
+ onclick="EventQueue.fire('onclick')"
+ onmousedown="EventQueue.fire('onmousedown')"
+ onmousemove="EventQueue.fire('onmousemove')"
+ onmouseup="EventQueue.fire('onmouseup')"
+ onmouseout="EventQueue.fire('onmouseout')"
+ onmouseover="EventQueue.fire('onmouseover')"
+ onkeydown="EventQueue.fire('onkeydown')"
+ onkeypress="EventQueue.fire('onkeypress')"
+ onkeyup="EventQueue.fire('onkeyup')"
+ >
+ <h:panelGroup>
+ <h:inputText id="inputText" value="#{element.cell2}" validator="#{dataGrid.validate}"></h:inputText>
+ </h:panelGroup>
+ </rich:dataGrid>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java 2009-01-30 16:55:31 UTC (rev 12506)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java 2009-01-30 17:17:05 UTC (rev 12507)
@@ -1,8 +1,11 @@
package org.richfaces.testng;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -123,6 +126,20 @@
Assert.assertFalse(selenium.isElementPresent(dataGrid));
}
+ /**
+ * style and classes, standard HTML attributes are output to client
+ */
+ @Test
+ public void testStandardAttributes(Template template) {
+ AutoTester autoTester = getAutoTester(this);
+ autoTester.renderPage(template, "#{dataGrid.init}");
+ Map<String, String> styleAttributes = new HashMap<String, String>();
+ styleAttributes.put("width", "100%");
+ styleAttributes.put("color", "yellow");
+ autoTester.testStyleAndClasses(new String[]{"noname"}, styleAttributes);
+ autoTester.testHTMLEvents();
+ }
+
private void chekStructure(int ... notEqualRows) {
String dataTableRowLocator = "id('"+ dataTable + "')/tbody/tr";
int count = selenium.getXpathCount(dataTableRowLocator).intValue();
@@ -142,4 +159,9 @@
public String getTestUrl() {
return "pages/dataGrid/dataGrid.xhtml";
}
+
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/dataGrid/dataGridAutoTest.xhtml";
+ }
}
15 years, 10 months
JBoss Rich Faces SVN: r12506 - in trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces: testng and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2009-01-30 11:55:31 -0500 (Fri, 30 Jan 2009)
New Revision: 12506
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5888
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-01-30 16:37:38 UTC (rev 12505)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-01-30 16:55:31 UTC (rev 12506)
@@ -756,6 +756,18 @@
}
/**
+ * Sets a new value for DOM node with specified name.
+ *
+ * @param name -
+ * DOM element name (has to be unique)
+ * @param value -
+ * a new DOM element's value
+ */
+ public void setValueByName(String name, String value) {
+ runScript(String.format("document.getElementsByName('%1$s')[0].value='%2$s';", name, value));
+ }
+
+ /**
* Returns element's width
*
* @param id -
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-30 16:37:38 UTC (rev 12505)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-30 16:55:31 UTC (rev 12506)
@@ -64,6 +64,26 @@
}
@Test
+ public void testInvalidValueSubmission(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+
+ writeStatus("Check component displays submitted value after submission of invalid value");
+
+ //invalid value cannot be submitted due to smart client validation
+ //try a hack
+ String invalidValue = "invalid";
+ Assert.assertEquals(getSpinnerValue(), "20");
+ selenium.type("name=" + getParentId() + FORM_ID + "componentId", invalidValue);
+ setValueByName(getParentId() + FORM_ID + "componentId", invalidValue);
+ tester.clickSubmit();
+ tester.checkUpdateModel(false);
+ tester.checkValueChangeListener(false);
+ Assert.assertEquals(getSpinnerValue(), invalidValue);
+ AssertTextEquals(tester.getClientId("submittedValue"), "20", "Model has not to be updated in case of invalid submission");
+ }
+
+ @Test
public void testRequiredAndRequiredMessageAttributes(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, RESET_METHOD);
15 years, 10 months
JBoss Rich Faces SVN: r12505 - in trunk/test-applications/realworld/web/src/main/webapp: includes/index and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2009-01-30 11:37:38 -0500 (Fri, 30 Jan 2009)
New Revision: 12505
Modified:
trunk/test-applications/realworld/web/src/main/webapp/includes/index/login.xhtml
trunk/test-applications/realworld/web/src/main/webapp/index.xhtml
trunk/test-applications/realworld/web/src/main/webapp/layout/template2.xhtml
Log:
Fix some bugs in Realworld
Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/index/login.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/index.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/layout/template2.xhtml
===================================================================
(Binary files differ)
15 years, 10 months
JBoss Rich Faces SVN: r12504 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/layout/autotest and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2009-01-30 10:24:38 -0500 (Fri, 30 Jan 2009)
New Revision: 12504
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5887
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java 2009-01-30 13:08:33 UTC (rev 12503)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/autotest/bean/AutoTestBean.java 2009-01-30 15:24:38 UTC (rev 12504)
@@ -72,6 +72,8 @@
public static final String VALIDATOR_MESSAGE = "Validator message";
+ public static final String REQUIRED_MESSAGE = "Required message";
+
public static final String AUTOTEST_BEAN_NAME = "autoTestBean";
// private String input = INPUT_TEXT;
@@ -101,7 +103,9 @@
private String processInput;
private boolean processSet = false;
-
+
+ private boolean required;
+
public class AutoTestConverter implements Converter {
public static final String AS_OBJECT_STRING = "AUTO_TEST_CONVERTER_AS_OBJECT";
@@ -425,69 +429,95 @@
this.validatorId = validatorId;
}
- /**
- * @return the validatorMessage
- */
- public String getValidatorMessage() {
- return VALIDATOR_MESSAGE;
- }
+ /**
+ * @return the requiredMessage
+ */
+ public String getRequiredMessage() {
+ return REQUIRED_MESSAGE;
+ }
- /**
- * @return the converter
- */
- public Converter getConverter() {
- if (converterSet) {
- return converter;
- }
- return null;
- }
+ /**
+ * @return the validatorMessage
+ */
+ public String getValidatorMessage() {
+ return VALIDATOR_MESSAGE;
+ }
- /**
- * @return the converterSet
- */
- public boolean isConverterSet() {
- return converterSet;
- }
+ /**
+ * @return the converter
+ */
+ public Converter getConverter() {
+ if (converterSet) {
+ return converter;
+ }
+ return null;
+ }
- /**
- * @param converterSet the converterSet to set
- */
- public void setConverterSet(boolean converterSet) {
- this.converterSet = converterSet;
- }
+ /**
+ * @return the converterSet
+ */
+ public boolean isConverterSet() {
+ return converterSet;
+ }
- /**
- * @return the processSet
- */
- public boolean isProcessSet() {
- return processSet;
- }
+ /**
+ * @param converterSet
+ * the converterSet to set
+ */
+ public void setConverterSet(boolean converterSet) {
+ this.converterSet = converterSet;
+ }
- /**
- * @param processSet the processSet to set
- */
- public void setProcessSet(boolean processSet) {
- this.processSet = processSet;
- }
+ /**
+ * @return the processSet
+ */
+ public boolean isProcessSet() {
+ return processSet;
+ }
- /**
- * @return the processInput
- */
- public String getProcessInput() {
- return null;
- }
+ /**
+ * @param processSet
+ * the processSet to set
+ */
+ public void setProcessSet(boolean processSet) {
+ this.processSet = processSet;
+ }
- /**
- * @param processInput the processInput to set
- */
- public void setProcessInput(String processInput) {
- if (processSet) {
+ /**
+ * @return the processInput
+ */
+ public String getProcessInput() {
+ return null;
+ }
+
+ /**
+ * @param processInput
+ * the processInput to set
+ */
+ public void setProcessInput(String processInput) {
+ if (processSet) {
setStatus(getStatus() + PROCESS_INPUT_UPDATE_MODEL);
}
- }
+ }
- public String getProcess() {
- return (processSet) ? "_auto_process_input" : "_auto_input";
- }
+ public String getProcess() {
+ return (processSet) ? "_auto_process_input" : "_auto_input";
+ }
+ /**
+ * Gets value of required field.
+ * @return value of required field
+ */
+ public boolean isRequired() {
+ return required;
+ }
+
+ /**
+ * Set a new value for required field.
+ * @param required a new value for required field
+ */
+ public void setRequired(boolean required) {
+ this.required = required;
+ }
+
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml 2009-01-30 13:08:33 UTC (rev 12503)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/layout/autotest/autoTestControls.xhtml 2009-01-30 15:24:38 UTC (rev 12504)
@@ -67,7 +67,13 @@
</td>
</tr>
<tr>
+ <td>Required:</td>
<td>
+ <h:selectBooleanCheckbox id="_auto_required" value="#{autoTestBean.required}"></h:selectBooleanCheckbox>
+ </td>
+ </tr>
+ <tr>
+ <td>
<h:commandButton id="_auto_load" actionListener="#{templateBean.reset}" action="#{autoTestBean.load}" value="Load"></h:commandButton>
</td>
<td>
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2009-01-30 13:08:33 UTC (rev 12503)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/AutoTester.java 2009-01-30 15:24:38 UTC (rev 12504)
@@ -443,6 +443,10 @@
base.changeValue();
}
+ private void setValueEmpty() {
+ base.setValueEmpty();
+ }
+
public void setInternalValidation(boolean passed) {
setupControl(TestSetupEntry.validatorId, (passed) ? AutoTestBean.VALIDATOR_DEFAULT_ID : AutoTestBean.VALIDATOR_ID);
}
@@ -532,6 +536,28 @@
}
}
+ public void testRequiredAndRequiredMessageAttributes() {
+ reset();
+ setupControl(TestSetupEntry.required, true);
+ clickLoad();
+ setValueEmpty();
+ clickSubmit();
+
+ String errorMessage = getValidatorMessage();
+
+ if (null == errorMessage || !errorMessage.contains(AutoTestBean.REQUIRED_MESSAGE)) {
+ Assert.fail("requiredMessage attribute does not work. RequiredMessage expected: ["
+ + AutoTestBean.REQUIRED_MESSAGE + "].But was [" + errorMessage + "]");
+ }
+
+ try {
+ checkUpdateModel(false);
+ checkValueChangeListener(false);
+ } catch (AssertionError ae) {
+ Assert.fail("required attribute does not work. Cause: " + ae.getMessage());
+ }
+ }
+
public void checkActionListener(boolean passed) {
String status = getStatus();
if (passed && status != null && status.indexOf(AutoTestBean.ACTION_LISTENER_STATUS) == -1) {
@@ -659,6 +685,8 @@
public static final TestSetupEntry process = new TestSetupEntry("process", Boolean.class, Boolean.FALSE);
+ public static final TestSetupEntry required = new TestSetupEntry("required", Boolean.class, Boolean.FALSE);
+
public static final List<TestSetupEntry> list = new ArrayList<TestSetupEntry>();
static {
list.add(reRender);
@@ -671,6 +699,7 @@
list.add(oncomplete);
list.add(converter);
list.add(process);
+ list.add(required);
}
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-01-30 13:08:33 UTC (rev 12503)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-01-30 15:24:38 UTC (rev 12504)
@@ -1224,6 +1224,14 @@
}
/**
+ * This call back has to bring auto test component value to the state as if a user has not provided a submitted value for the component
+ * Used for auto testing only.
+ */
+ public void setValueEmpty() {
+ throw new UnsupportedOperationException("This method has always to be overridden before usage");
+ }
+
+ /**
* Returns the array of components' ids that are rerendering after ajax request from the component.
* This method should be overridden for auto test
*/
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-30 13:08:33 UTC (rev 12503)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-30 15:24:38 UTC (rev 12504)
@@ -64,6 +64,15 @@
}
@Test
+ public void testRequiredAndRequiredMessageAttributes(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+
+ writeStatus("Check required & requiredMessage attributes");
+ tester.testRequiredAndRequiredMessageAttributes();
+ }
+
+ @Test
public void testCycleMode(Template template) {
renderPage(template, RESET_METHOD);
writeStatus("Check cycled attribute");
@@ -261,6 +270,11 @@
}
@Override
+ public void setValueEmpty() {
+ selenium.type("name=" + getParentId() + FORM_ID + "componentId", " ");
+ }
+
+ @Override
public String getAutoTestUrl() {
return "pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml";
}
15 years, 10 months
JBoss Rich Faces SVN: r12503 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2009-01-30 08:08:33 -0500 (Fri, 30 Jan 2009)
New Revision: 12503
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5884
https://jira.jboss.org/jira/browse/RF-5885
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-01-30 02:02:00 UTC (rev 12502)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2009-01-30 13:08:33 UTC (rev 12503)
@@ -570,18 +570,17 @@
/**
* Asserts DOM node text equals to text defined
*
- * @param id -
- * DOM element id
+ * @param locator -
+ * locator an element locator
* @param value -
* text defined
* @param message = message to be displayed in failure case
*/
- public void AssertTextEquals(String id, String value, String message) {
- String _v = getTextById(id);
+ public void AssertTextEquals(String locator, String value, String message) {
+ String _v = selenium.getText(locator);
Assert.assertEquals(_v, value, message);
}
-
/**
* Asserts DOM node text does not equal to text defined
*
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-30 02:02:00 UTC (rev 12502)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-30 13:08:33 UTC (rev 12503)
@@ -41,6 +41,29 @@
private final static String CONTROL_FORM_ID = "control:";
@Test
+ public void testComponentIsPresentOnThePageAndShowsModelValue(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Component is present on the page and shows model value");
+
+ String spinnerId = tester.getClientId(AutoTester.COMPONENT_ID);
+ AssertPresentAndVisible(spinnerId, "Spinner is not rendered");
+ Assert.assertEquals(getSpinnerValue(), "20");
+ }
+
+ @Test
+ public void testValueChangeEventFiredAndModelUpdatedOnSubmit(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ String submittedValueId = tester.getClientId("submittedValue");
+
+ writeStatus("Check ValueChangeListeners invoked on submit and model binding is updated on value changed");
+ Assert.assertEquals(getSpinnerValue(), "20");
+ tester.testSubmit();
+ AssertTextEquals(submittedValueId, "30", "Model binding is not updated on value changed");
+ }
+
+ @Test
public void testCycleMode(Template template) {
renderPage(template, RESET_METHOD);
writeStatus("Check cycled attribute");
15 years, 10 months
JBoss Rich Faces SVN: r12502 - in trunk/framework: impl/src/main/java/org/ajax4jsf/context and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-01-29 21:02:00 -0500 (Thu, 29 Jan 2009)
New Revision: 12502
Modified:
trunk/framework/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
Log:
https://jira.jboss.org/jira/browse/RF-5838
Modified: trunk/framework/api/src/main/java/org/ajax4jsf/context/AjaxContext.java
===================================================================
--- trunk/framework/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2009-01-29 17:47:57 UTC (rev 12501)
+++ trunk/framework/api/src/main/java/org/ajax4jsf/context/AjaxContext.java 2009-01-30 02:02:00 UTC (rev 12502)
@@ -35,6 +35,8 @@
import org.ajax4jsf.resource.util.URLToStreamHelper;
public abstract class AjaxContext {
+
+ private boolean limitToList;
public static final String RESPONSE_DATA_KEY = "_ajax:data";
static final String SERVICE_RESOURCE = "META-INF/services/"
@@ -121,7 +123,16 @@
public abstract void setAjaxAreasToProcess(Set<String> ajaxAreasToProcess);
public abstract void setSubmittedRegionClientId(String submittedClientId);
+
+ public boolean isLimitToList() {
+ return limitToList;
+ }
+
+ public void setLimitToList(boolean limitToList) {
+ this.limitToList = limitToList;
+ }
+
/**
* Get instance of current AJAX Context. Instance get by
* variable {@link AjaxContext#AJAX_CONTEXT_KEY}
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2009-01-29 17:47:57 UTC (rev 12501)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/context/AjaxContextImpl.java 2009-01-30 02:02:00 UTC (rev 12502)
@@ -331,6 +331,10 @@
ajaxAreasToRender.add(convertId(component, id));
}
}
+ // Is that component limit to list ?
+ if(Boolean.TRUE.equals(component.getAttributes().get("limitToList"))){
+ setLimitToList(true);
+ }
}
/**
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java 2009-01-29 17:47:57 UTC (rev 12501)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java 2009-01-30 02:02:00 UTC (rev 12502)
@@ -33,27 +33,36 @@
import org.ajax4jsf.Messages;
import org.ajax4jsf.component.AjaxChildrenEncoder;
import org.ajax4jsf.component.AjaxOutput;
+import org.ajax4jsf.context.AjaxContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author shura
- *
+ *
*/
-public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase implements AjaxRenderer {
-
+public abstract class AjaxChildrenRenderer extends AjaxComponentRendererBase
+ implements AjaxRenderer {
+
public static final Log log = LogFactory.getLog(AjaxChildrenRenderer.class);
public static final String[] SPECIAL_COMPONENTS_TYPES = {
- "org.ajax4jsf.Bundle"/*UILoadBundle.COMPONENT_TYPE*/, "org.apache.myfaces.AliasBean",
- "org.apache.myfaces.AliasBeansScope" };
+ "org.ajax4jsf.Bundle"/* UILoadBundle.COMPONENT_TYPE */,
+ "org.apache.myfaces.AliasBean",
+ "org.apache.myfaces.AliasBeansScope" };
private static final String SPECIAL_TYPES_PARAMETER = "org.ajax4jsf.CONTROL_COMPONENTS";
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxChildren(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String, java.util.Set, java.util.Set)
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxChildren(javax.faces.context
+ * .FacesContext, javax.faces.component.UIComponent, java.lang.String,
+ * java.util.Set, java.util.Set)
*/
- public void encodeAjaxChildren(FacesContext context, UIComponent component, String path, Set<String> ids, Set<String> renderedAreas) throws IOException {
+ public void encodeAjaxChildren(FacesContext context, UIComponent component,
+ String path, Set<String> ids, Set<String> renderedAreas)
+ throws IOException {
if (log.isDebugEnabled()) {
log.debug(Messages.getMessage(Messages.ENCODE_CHILD_AJAX_INFO,
path, component.getId()));
@@ -61,69 +70,103 @@
String currentPath = path;
if (component instanceof NamingContainer) {
currentPath += component.getId() + NamingContainer.SEPARATOR_CHAR;
+ // Do not check children if we have no id to render under naming
+ // container.
+ if (AjaxContext.getCurrentInstance(context).isLimitToList()
+ && noIdUnderPath(path, ids)) {
+ return;
+ }
}
- for (Iterator<UIComponent> it = component.getFacetsAndChildren(); it.hasNext();) {
+ for (Iterator<UIComponent> it = component.getFacetsAndChildren(); it
+ .hasNext();) {
UIComponent element = (UIComponent) it.next();
- encodeAjaxComponent(context, element, currentPath, ids, renderedAreas);
+ encodeAjaxComponent(context, element, currentPath, ids,
+ renderedAreas);
}
}
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxComponent(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String, java.util.Set, java.util.Set)
+ private boolean noIdUnderPath(String path, Set<String> ids) {
+ // Do we have an any component for the rendering under that container ?
+ boolean noSuchId = true;
+ for (String id : ids) {
+ if (null != id && id.startsWith(path)) {
+ noSuchId = false;
+ break;
+ }
+ }
+ return noSuchId;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxComponent(javax.faces.context
+ * .FacesContext, javax.faces.component.UIComponent, java.lang.String,
+ * java.util.Set, java.util.Set)
*/
- public void encodeAjaxComponent(FacesContext context, UIComponent component, String currentPath, Set<String> ids, Set<String> renderedAreas) throws IOException {
- if (component.isRendered()) { // skip not-rendered components.
- boolean found = false;
- if (!ids.isEmpty()) {
- // list for rendering may contains absolute id ( best ),
- // component Id or client ID
- String elementId = component.getId();
- String absoluteId = currentPath + elementId;
- // String clientId = element.getClientId(context);
- if (ids.contains(absoluteId) || ids.contains(elementId)) {
- if (log.isDebugEnabled()) {
- log
- .debug(Messages.getMessage(
- Messages.RENDER_AJAX_AREA_INFO,
- absoluteId));
- }
- // renderChild(context, element);
- found = true;
- }
- }
- if (!found && component instanceof AjaxOutput) {
- if (((AjaxOutput) component).isAjaxRendered()) {
- // renderChild(context, element);
- found = true;
- }
-
- }
-
- if (!found) {
- if (component instanceof AjaxChildrenEncoder) {
- ((AjaxChildrenEncoder) component).encodeAjaxChild(
- context, currentPath, ids, renderedAreas);
- } else {
- // Special case - for control components, not produced
- // html code - such as message bundles loaders,
- // MyFaces aliases etc. we call encodeBegin/end methods
- // even if components not in rendered areas.
- boolean special = isSpecialElement(context, component);
- if (special) {
- component.encodeBegin(context);
- }
- encodeAjaxChildren(context, component, currentPath, ids,
- renderedAreas);
- if (special) {
- component.encodeEnd(context);
- }
-
- }
- } else {
- renderedAreas.add(component.getClientId(context));
- renderChild(context, component);
- }
- }
+ public void encodeAjaxComponent(FacesContext context,
+ UIComponent component, String currentPath, Set<String> ids,
+ Set<String> renderedAreas) throws IOException {
+ if (component.isRendered()) { // skip not-rendered components.
+ boolean found = false;
+ boolean limitToList = AjaxContext.getCurrentInstance(context).isLimitToList();
+ String elementId = component.getId();
+ String absoluteId = currentPath + elementId;
+ if (!ids.isEmpty()) {
+ // list for rendering may contains absolute id ( best ),
+ // component Id or client ID
+ // String clientId = element.getClientId(context);
+ if (ids.contains(absoluteId) || ids.contains(elementId)) {
+ if (log.isDebugEnabled()) {
+ log.debug(Messages.getMessage(
+ Messages.RENDER_AJAX_AREA_INFO, absoluteId));
+ }
+ // renderChild(context, element);
+ found = true;
+ }
+ }
+ //
+ if (!found && limitToList
+ && component instanceof NamingContainer
+ && noIdUnderPath(absoluteId
+ + NamingContainer.SEPARATOR_CHAR, ids)) {
+ return;
+ }
+ if (!found && !limitToList && component instanceof AjaxOutput) {
+ if (((AjaxOutput) component).isAjaxRendered()) {
+ // renderChild(context, element);
+ found = true;
+ }
+
+ }
+
+ if (!found) {
+ if (component instanceof AjaxChildrenEncoder
+ && (!limitToList)) {
+ ((AjaxChildrenEncoder) component).encodeAjaxChild(context,
+ currentPath, ids, renderedAreas);
+ } else {
+ // Special case - for control components, not produced
+ // html code - such as message bundles loaders,
+ // MyFaces aliases etc. we call encodeBegin/end methods
+ // even if components not in rendered areas.
+ boolean special = isSpecialElement(context, component);
+ if (special) {
+ component.encodeBegin(context);
+ }
+ encodeAjaxChildren(context, component, currentPath, ids,
+ renderedAreas);
+ if (special) {
+ component.encodeEnd(context);
+ }
+
+ }
+ } else {
+ renderedAreas.add(component.getClientId(context));
+ renderChild(context, component);
+ }
+ }
}
private Set<String> _specialComponentTypes = null;
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-01-29 17:47:57 UTC (rev 12501)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2009-01-30 02:02:00 UTC (rev 12502)
@@ -127,8 +127,7 @@
public static final String SIMILARITY_GROUPING_ID_ATTR = "similarityGroupingId";
/**
- * Static class - protect constructor TODO - make as subclass of chameleon
- * RendererUtils.
+ * Static class - protect constructor
*
*/
private AjaxRendererUtils() {
@@ -156,8 +155,7 @@
* @param facesContext
* @param eventName -
* name of event
- * @return <code>StringBuffer</code> with Javascript code TODO - for
- * key-based events build list of supported keys
+ * @return <code>StringBuffer</code> with Javascript code
*/
public static StringBuffer buildOnEvent(UIComponent uiComponent,
FacesContext facesContext, String eventName) {
@@ -182,8 +180,6 @@
// oncomplete - function for call after complete request.
// status - id of request status component.
// parameters - map of parameters name/value for append on request.
- // TODO
- // sync true/false - run script in sync mode.
// ..........
ajaxFunction.addParameter(buildEventOptions(facesContext, uiComponent));
@@ -288,23 +284,23 @@
options.put("parameters", parameters);
}
// parameter to render only current list of areas.
- if (isAjaxLimitToList(uiComponent)) {
- Set<? extends Object> ajaxAreas = getAjaxAreas(uiComponent);
- Set<String> areasIds = new HashSet<String>();
- if (null != ajaxAreas) {
- for (Iterator<? extends Object> iter = ajaxAreas.iterator(); iter.hasNext();) {
- String id = (String) iter.next();
- UIComponent comp = RendererUtils.getInstance().
- findComponentFor(uiComponent, id);
- if (null != comp) {
- areasIds.add(comp.getClientId(facesContext));
- } else {
- areasIds.add(id);
- }
- }
- }
- options.put("affected", areasIds);
- }
+// if (isAjaxLimitToList(uiComponent)) {
+// Set<? extends Object> ajaxAreas = getAjaxAreas(uiComponent);
+// Set<String> areasIds = new HashSet<String>();
+// if (null != ajaxAreas) {
+// for (Iterator<? extends Object> iter = ajaxAreas.iterator(); iter.hasNext();) {
+// String id = (String) iter.next();
+// UIComponent comp = RendererUtils.getInstance().
+// findComponentFor(uiComponent, id);
+// if (null != comp) {
+// areasIds.add(comp.getClientId(facesContext));
+// } else {
+// areasIds.add(id);
+// }
+// }
+// }
+// options.put("affected", areasIds);
+// }
String oncomplete = getAjaxOncomplete(uiComponent);
if (null != oncomplete) {
options.put(ONCOMPLETE_ATTR_NAME, buildAjaxOncomplete(oncomplete));
@@ -380,7 +376,6 @@
* @param uiComponent
* @param facesContext
* @param functionName
- * TODO
* @return
*/
public static JSFunction buildAjaxFunction(UIComponent uiComponent,
@@ -398,7 +393,6 @@
* @param uiComponent
* @param facesContext
* @param functionName
- * TODO
* @return
*/
public static JSFunction buildAjaxFunction(UIComponent uiComponent,
@@ -534,13 +528,13 @@
/**
* Convert parameter ( Collection, List, array, String, comma-separated
- * String ) to list of srings. TODO - when move to JDK 5, change to
- * List<String>
+ * String ) to list of srings.
*
* @param valueToSet -
* obect for convert to List.
* @return - list of strings.
*/
+ @SuppressWarnings("unchecked")
public static Set<String> asSet(Object valueToSet) {
if (null != valueToSet) {
@@ -894,7 +888,6 @@
ResponseWriter out = context.getResponseWriter();
// DebugUtils.traceView("ViewRoot in AJAX Page encode begin");
out.startElement("html", component);
- // TODO - html attributes. lang - from current locale ?
Locale locale = context.getViewRoot().getLocale();
out.writeAttribute(HTML.lang_ATTRIBUTE, locale.toString(), "lang");
out.startElement("body", component);
15 years, 10 months
JBoss Rich Faces SVN: r12501 - in trunk/test-applications/realworld/web/src/main: java/org/richfaces/realworld/manager and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-01-29 12:47:57 -0500 (Thu, 29 Jan 2009)
New Revision: 12501
Modified:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchParamHolder.java
trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/pages.xml
trunk/test-applications/realworld/web/src/main/webapp/includes/contextMenu/CMForAlbum.xhtml
trunk/test-applications/realworld/web/src/main/webapp/includes/index/login.xhtml
trunk/test-applications/realworld/web/src/main/webapp/layout/template2.xhtml
Log:
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-01-29 17:24:46 UTC (rev 12500)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-01-29 17:47:57 UTC (rev 12501)
@@ -173,6 +173,9 @@
public void showFileUpload(boolean result) {
this.setFileUploadRendered(result);
clearUploadData();
+ setFileQuantity(Constants.MULTY_MODE_FILE_QUANTITY);
+ setImmediateUpload(false);
+ setSelectedMode("multy");
}
public void changeMode() {
@@ -207,6 +210,7 @@
@Observer(Constants.CHANGE_MODE_FILE_UPLOAD_EVENT)
public void setSelectedMode(String selectedMode) {
this.selectedMode = selectedMode;
+ changeMode();
}
private Image constructImage(UploadItem item, FileItem file) {
@@ -278,6 +282,8 @@
if (exifDirectory.containsTag(ExifDirectory.TAG_MODEL)) {
String cameraModel = exifDirectory.getString(ExifDirectory.TAG_MODEL);
image.setCameraModel(cameraModel);
+ }else{
+ image.setCameraModel("");
}
}
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-01-29 17:24:46 UTC (rev 12500)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-01-29 17:47:57 UTC (rev 12501)
@@ -25,6 +25,7 @@
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.security.auth.login.LoginException;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.End;
@@ -38,6 +39,7 @@
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
+import org.jboss.seam.web.Session;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.navigation.NavigationEnum;
@@ -112,10 +114,32 @@
return Constants.INDEX_OUTCOME;
}
+ public String logout(){
+ identity.logout();
+ identity.unAuthenticate();
+ credentials.clear();
+ credentials.invalidate();
+ Session.instance().invalidate();
+ return "logout";
+ }
+
+ public String goToRegister(){
+ identity.logout();
+ identity.unAuthenticate();
+ credentials.clear();
+ credentials.invalidate();
+ return "register";
+ }
+
public String loginAnonymous(){
credentials.setUsername(null);
credentials.setPassword(null);
- this.authenticate();
+ try {
+ identity.authenticate();
+ } catch (LoginException e) {
+ facesMessages.add(INVALID_LOGIN_OR_PASSWORD);
+ return "";
+ }
return Constants.MAIN_OUTCOME;
}
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchParamHolder.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchParamHolder.java 2009-01-29 17:24:46 UTC (rev 12500)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchParamHolder.java 2009-01-29 17:47:57 UTC (rev 12501)
@@ -81,11 +81,11 @@
}
public String getSearchPattern() {
- return searchPattern;
+ return searchPattern != null? searchPattern:"";
}
public void setSearchPattern(String searchPattern) {
- this.searchPattern = searchPattern;
+ this.searchPattern = searchPattern!=null?searchPattern:"";
}
public Long getSpinnerChoice() {
@@ -129,11 +129,11 @@
}
public String getCamera() {
- return camera;
+ return camera != null? camera:"";
}
public void setCamera(String camera) {
- this.camera = camera;
+ this.camera = camera!=null?camera:"";
}
public int getHeight() {
Modified: trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/pages.xml
===================================================================
--- trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/pages.xml 2009-01-29 17:24:46 UTC (rev 12500)
+++ trunk/test-applications/realworld/web/src/main/webapp/WEB-INF/pages.xml 2009-01-29 17:47:57 UTC (rev 12501)
@@ -25,13 +25,22 @@
<page view-id="/index.xhtml" action="#{conversation.begin}">
- <navigation>
- <rule if="#{identity.loggedIn}">
+ <navigation from-action="#{identity.login}">
+ <rule if="#{identity.loggedIn and identity.hasRole('admin')}">
<redirect view-id="/main.xhtml"/>
</rule>
</navigation>
</page>
+
+ <page view-id="/main.xhtml" login-required="true">
+ <navigation from-action="#{authenticator.logout}">
+ <rule if-outcome="logout">
+ <end-conversation />
+ <redirect view-id="/index.xhtml" />
+ </rule>
+ </navigation>
+ </page>
<exception class="org.jboss.seam.framework.EntityNotFoundException">
<redirect view-id="/error.xhtml">
Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/contextMenu/CMForAlbum.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/index/login.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/layout/template2.xhtml
===================================================================
(Binary files differ)
15 years, 10 months