JBoss Rich Faces SVN: r12438 - trunk/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: atsebro
Date: 2009-01-27 10:46:10 -0500 (Tue, 27 Jan 2009)
New Revision: 12438
Modified:
trunk/docs/userguide/en/src/main/resources/images/modalPanel2.png
Log:
Modified: trunk/docs/userguide/en/src/main/resources/images/modalPanel2.png
===================================================================
(Binary files differ)
15 years, 11 months
JBoss Rich Faces SVN: r12437 - trunk/docs/userguide/en/src/main/resources/images.
by richfaces-svn-commits@lists.jboss.org
Author: atsebro
Date: 2009-01-27 10:37:59 -0500 (Tue, 27 Jan 2009)
New Revision: 12437
Modified:
trunk/docs/userguide/en/src/main/resources/images/modalPanel2.png
Log:
Modified: trunk/docs/userguide/en/src/main/resources/images/modalPanel2.png
===================================================================
(Binary files differ)
15 years, 11 months
JBoss Rich Faces SVN: r12436 - 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-27 09:15:24 -0500 (Tue, 27 Jan 2009)
New Revision: 12436
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-5676
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-27 13:36:43 UTC (rev 12435)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataGridBean.java 2009-01-27 14:15:24 UTC (rev 12436)
@@ -3,6 +3,9 @@
import java.util.ArrayList;
import java.util.List;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
public class DataGridBean {
public class Element {
@@ -44,17 +47,23 @@
private List<Element> model;
private int elements;
+ private String trace;
public DataGridBean() {
+ init();
+ }
+
+ public void init() {
model = new ArrayList<Element>(10);
for (int i = 0; i < 10; i++) {
model.add(new Element(Integer.toString(i)));
}
- init();
+ elements = 0;
+ trace = "";
}
- public void init() {
- elements = 0;
+ public void submit(ActionEvent event) {
+ trace = event.getComponent().getClientId(FacesContext.getCurrentInstance());
}
public void setModel(List<Element> model) {
@@ -72,4 +81,12 @@
public int getElements() {
return elements;
}
+
+ public void setTrace(String trace) {
+ this.trace = trace;
+ }
+
+ public String getTrace() {
+ return trace;
+ }
}
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-27 13:36:43 UTC (rev 12435)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGrid.xhtml 2009-01-27 14:15:24 UTC (rev 12436)
@@ -23,16 +23,19 @@
</h:selectBooleanCheckbox-->
</h:form>
<h:form id="mainForm">
- <rich:dataGrid id="dataGrid" value="#{dataGrid.model}" var="row" elements="#{dataGrid.elements}">
+ <rich:dataGrid id="dataGrid" value="#{dataGrid.model}" var="element" elements="#{dataGrid.elements}">
<h:panelGroup>
- <h:outputText value="#{row.cell1}"></h:outputText>
- <h:inputText value="#{row.cell2}"></h:inputText>
- <h:outputText value="#{row.cell3}"></h:outputText>
+ <h:outputText value="#{element.cell1}"></h:outputText>
+ <h:inputText value="#{element.cell2}"></h:inputText>
+ <h:outputText value="#{element.cell3}"></h:outputText>
+ <h:commandButton id="submit" value="submit" actionListener="#{dataGrid.submit}"></h:commandButton>
+ <a4j:commandButton id="ajaxSubmit" value="ajaxSubmit" actionListener="#{dataGrid.submit}"></a4j:commandButton>
+ <a4j:commandButton id="ajaxSingleSubmit" value="ajaxSingleSubmit" actionListener="#{dataGrid.submit}" ajaxSingle="true"></a4j:commandButton>
</h:panelGroup>
</rich:dataGrid>
</h:form>
<a4j:outputPanel ajaxRendered="true">
- <h:outputText id="outputText" value="#{treeNodesAdaptor.trace}"></h:outputText>
+ <h:outputText id="outputText" value="#{dataGrid.trace}"></h:outputText>
<h:dataTable id="dataTable" value="#{dataGrid.model}" var="row" rows="#{dataGrid.elements}">
<h:column>
<h:outputText value="#{row.cell2}"></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-27 13:36:43 UTC (rev 12435)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java 2009-01-27 14:15:24 UTC (rev 12436)
@@ -27,7 +27,7 @@
/**
* items from collection defined as value attribute are output to the client;
- * number of items is limited using rows attribute and not
+ * number of items is limited using elements attribute and not
*/
@Test
public void testStructure(Template template) {
@@ -39,6 +39,30 @@
chekStructure();
}
+ /**
+ * nested input and command components work correctly
+ */
+ @Test
+ public void testComponentsProcessing(Template template) {
+ init(template);
+ String trLocator = "xpath=id('"+ dataGrid + "')/tbody/tr[";
+ String inputLocator = trLocator + "6]/td/input[";
+ Assert.assertEquals(selenium.getText(outputText), "");
+ selenium.click(inputLocator + "2]");
+ waitForPageToLoad();
+ Assert.assertTrue(selenium.getText(outputText).endsWith("5:submit"));
+ selenium.click(inputLocator + "3]");
+ waitForAjaxCompletion();
+ Assert.assertTrue(selenium.getText(outputText).endsWith("5:ajaxSubmit"));
+ selenium.click(inputLocator + "4]");
+ waitForAjaxCompletion();
+ Assert.assertTrue(selenium.getText(outputText).endsWith("5:ajaxSingleSubmit"));
+ selenium.type(inputLocator + "1]", "abc5");
+ selenium.click(inputLocator + "3]");
+ waitForAjaxCompletion();
+ chekStructure();
+ }
+
private void chekStructure() {
String dataTableRowLocator = "id('"+ dataTable + "')/tbody/tr";
int count = selenium.getXpathCount(dataTableRowLocator).intValue();
15 years, 11 months
JBoss Rich Faces SVN: r12435 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/WEB-INF and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2009-01-27 08:36:43 -0500 (Tue, 27 Jan 2009)
New Revision: 12435
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSpinnerBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5892
https://jira.jboss.org/jira/browse/RF-5893
Added: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSpinnerBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSpinnerBean.java (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSpinnerBean.java 2009-01-27 13:36:43 UTC (rev 12435)
@@ -0,0 +1,27 @@
+package org.ajax4jsf.bean;
+
+public class InputNumberSpinnerBean {
+
+ private Integer value = 20;
+
+ /**
+ * Gets value of value field.
+ * @return value of value field
+ */
+ public Integer getValue() {
+ return value;
+ }
+
+ /**
+ * Set a new value for value field.
+ * @param value a new value for value field
+ */
+ public void setValue(Integer value) {
+ this.value = value;
+ }
+
+ public void reset() {
+ this.value = 20;
+ }
+
+}
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/InputNumberSpinnerBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-01-26 19:39:21 UTC (rev 12434)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-01-27 13:36:43 UTC (rev 12435)
@@ -179,6 +179,11 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
+ <managed-bean-name>spinnerBean</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.InputNumberSpinnerBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>a4jOutputPanelBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.A4JOutputPanelTestBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/inputNumberSpinnerTest.xhtml
===================================================================
(Binary files differ)
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-26 19:39:21 UTC (rev 12434)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-01-27 13:36:43 UTC (rev 12435)
@@ -21,6 +21,7 @@
package org.richfaces.testng;
import org.ajax4jsf.template.Template;
+import org.richfaces.AutoTester;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -28,6 +29,10 @@
public class InputNumberSpinnerTest extends SeleniumTestBase {
+ private final static String RESET_METHOD = "#{spinnerBean.reset}";
+
+ private final static String FORM_ID = "autoTestForm:";
+
@Test
public void testInputNumberSpinnerComponent(Template template) {
renderPage(template);
@@ -61,22 +66,49 @@
Assert.assertEquals(getSpinnerValue(), "40");
}
+ @Test
+ public void testRenderedAttribute(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Test component with rendered = false is not present on the page");
+ tester.testRendered();
+ }
+
+ @Test
+ public void testImmediate(Template template) {
+ AutoTester tester = getAutoTester(this);
+ tester.renderPage(template, RESET_METHOD);
+ writeStatus("Test immediate attribute");
+ tester.testSubmitImmediate();
+ }
+
private void clickUp() {
- String id = getParentId() + "_form:" + "spinnerButtons";
+ String id = getParentId() + FORM_ID + "spinnerButtons";
selenium.fireEvent("xpath=//table[@id='" + id + "']/tbody/tr[1]/td", "mousedown");
selenium.fireEvent("xpath=//table[@id='" + id + "']/tbody/tr[1]/td", "mouseup");
}
private void clickDown() {
- String id = getParentId() + "_form:" + "spinnerButtons";
+ String id = getParentId() + FORM_ID + "spinnerButtons";
selenium.fireEvent("xpath=//table[@id='" + id + "']/tbody/tr[2]/td", "mousedown");
selenium.fireEvent("xpath=//table[@id='" + id + "']/tbody/tr[2]/td", "mouseup");
}
private String getSpinnerValue() {
- return selenium.getValue("name=" + getParentId() + "_form:spinner");
+ return selenium.getValue("name=" + getParentId() + FORM_ID + "spinner");
}
+ @Override
+ public void changeValue() {
+ clickUp();
+ }
+
+ @Override
+ public String getAutoTestUrl() {
+ return "pages/inputNumberSpinner/inputNumberSpinnerAutoTest.xhtml";
+ }
+
+ @Override
public String getTestUrl() {
return "pages/inputNumberSpinner/inputNumberSpinnerTest.xhtml";
}
15 years, 11 months
JBoss Rich Faces SVN: r12434 - trunk/test-applications/realworld/web/src/main/webapp/layout.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-01-26 14:39:21 -0500 (Mon, 26 Jan 2009)
New Revision: 12434
Modified:
trunk/test-applications/realworld/web/src/main/webapp/layout/template2.xhtml
Log:
Modified: trunk/test-applications/realworld/web/src/main/webapp/layout/template2.xhtml
===================================================================
(Binary files differ)
15 years, 11 months
JBoss Rich Faces SVN: r12432 - in trunk/test-applications/realworld/web/src/main: java/org/richfaces/realworld/manager and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-01-26 14:30:57 -0500 (Mon, 26 Jan 2009)
New Revision: 12432
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/manager/Authenticator.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/UserManager.java
trunk/test-applications/realworld/web/src/main/webapp/includes/image/breadCrumb.xhtml
Log:
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-26 19:28:18 UTC (rev 12431)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-01-26 19:30:57 UTC (rev 12432)
@@ -186,6 +186,11 @@
}
}
+ public String getPathOfImage(String path){
+ int i = path.lastIndexOf(Constants.SLASH);
+ return path.substring(i);
+ }
+
public void renameImage(String fileNameOld, String fileNameNew) {
createDirectoryIfNotExist(fileNameNew);
String fullPath = getAbsolutePath(fileNameOld);
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-26 19:28:18 UTC (rev 12431)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-01-26 19:30:57 UTC (rev 12432)
@@ -96,16 +96,6 @@
}
return false;
}
-
- private void setupCatalogForUser() {
- if (!fileManager.isDirectoryPresent(credentials.getUsername())) {
- fileManager.addDirectory(credentials.getUsername());
- }
- }
-
- private boolean wantLoginAnonymous() {
- return null == credentials.getUsername() || credentials.getUsername().equals("");
- }
@End
public String register(User user){
@@ -117,6 +107,23 @@
return Constants.INDEX_OUTCOME;
}
+ public String loginAnonymous(){
+ credentials.setUsername(null);
+ credentials.setPassword(null);
+ this.authenticate();
+ return Constants.MAIN_OUTCOME;
+ }
+
+ private void setupCatalogForUser() {
+ if (!fileManager.isDirectoryPresent(credentials.getUsername())) {
+ fileManager.addDirectory(credentials.getUsername());
+ }
+ }
+
+ private boolean wantLoginAnonymous() {
+ return null == credentials.getUsername() || credentials.getUsername().equals("");
+ }
+
private boolean checkUserExist(User user) {
if(userAction.isUserExist(user.getLogin())){
UIComponent root = FacesContext.getCurrentInstance().getViewRoot();
@@ -138,11 +145,4 @@
}
return false;
}
-
- public String loginAnonymous(){
- credentials.setUsername(null);
- credentials.setPassword(null);
- this.authenticate();
- return Constants.MAIN_OUTCOME;
- }
}
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-01-26 19:28:18 UTC (rev 12431)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-01-26 19:30:57 UTC (rev 12432)
@@ -68,30 +68,48 @@
}
private void handleRoot(Album dragValue) {
- TreeAlbumItem itemParent = null;
- if(!dragValue.getOwner().equals(user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.WRONG_DND));
+ TreeAlbumItem itemParent = removeAlbumFromParentAlbum(dragValue);
+ if(null == itemParent){
+ //Tree root contain this album
return;
}
+ if(!renameDirectory(dragValue)){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
+ return;
+ }
+ renameImagesFromAlbum(dragValue);
+ updateRootTreeNode(dragValue, itemParent);
+ addTreeToRerender();
+ }
+
+ private TreeAlbumItem removeAlbumFromParentAlbum(Album dragValue) {
+ TreeAlbumItem itemParent = null;
if(dragValue.getParent() != null ){
itemParent = (TreeAlbumItem)treeMyAlbumsItem.getNode(dragValue.getParent().getName());
dragValue.getParent().removeChildAlbum(dragValue);
}else{
- return;
+ //Tree root contain this album
+ return null;
}
- String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue, fileManager.getFileSeparator(), true );
- String directoryNew = user.getLogin() + fileManager.getFileSeparator() + dragValue.getName();
- if(!fileManager.renameDirectory(directoryOld, directoryNew)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
- return;
- }
- String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, Constants.SLASH, false );
+ return itemParent;
+ }
+
+ private boolean renameDirectory(Album dragValue) {
+ String directoryOld = fileManager.concat(user.getLogin(), dragValue.getAlbumPathFromParents(dragValue, fileManager.getFileSeparator(), true ));
+ String directoryNew = fileManager.concat(user.getLogin(), dragValue.getName());
+ return fileManager.renameDirectory(directoryOld, directoryNew);
+ }
+
+ private void renameImagesFromAlbum(Album dragValue) {
+ String albumOld = fileManager.concatwithSlash(user.getLogin(), dragValue.getAlbumPathFromParents(dragValue, Constants.SLASH, false ));
String albumNew = user.getLogin() + Constants.SLASH;
+ albumAction.renameAllImagesFromAlbumAndChilds(dragValue, albumOld, albumNew);
+ }
+
+ private void updateRootTreeNode(Album dragValue, TreeAlbumItem itemParent) {
TreeAlbumItem item = (TreeAlbumItem)treeMyAlbumsItem.getNode(dragValue.getName());
itemParent.removeChild(item.getId());
treeMyAlbumsItem.addChild(item.getId(), item);
- albumAction.renameAllImagesFromAlbumAndChilds(dragValue, albumOld, albumNew);
- addTreeToRerender();
}
private void addTreeToRerender() {
@@ -107,47 +125,60 @@
private void handleAlbum(Album dragValue, Album dropValue) {
TreeNode<Object> itemParent = null;
- if(!dragValue.getOwner().equals(user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.WRONG_DND));
- return;
- }
if(dragValue.getParent() != null ){
itemParent = treeMyAlbumsItem.getNode(dragValue.getParent().getName());
if(dragValue.getParent().equals(dropValue)){
+ //Parent album contain this album
return;
}
}else{
itemParent = treeMyAlbumsItem;
}
- String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue, fileManager.getFileSeparator(), true );
- String directoryNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue, fileManager.getFileSeparator(), false) + dragValue.getName();
- String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, Constants.SLASH, false );
- String albumNew = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, Constants.SLASH, false);
- dropValue.addChildAlbum(dragValue);
- TreeAlbumItem itemParentNew = (TreeAlbumItem)treeMyAlbumsItem.getNode(dropValue.getName());
- TreeAlbumItem item = (TreeAlbumItem)treeMyAlbumsItem.getNode(dragValue.getName());
- itemParent.removeChild(item.getId());
- itemParentNew.addAlbum(item);
+ String directoryOld = fileManager.concat(user.getLogin(), dragValue.getAlbumPathFromParents(dragValue, fileManager.getFileSeparator(), true ));
+ String directoryNew = fileManager.concat(user.getLogin() ,dropValue.getAlbumPathFromParents(dropValue, fileManager.getFileSeparator(), false), dragValue.getName());
if(!fileManager.renameDirectory(directoryOld, directoryNew)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
return;
}
- albumAction.renameAllImagesFromAlbumAndChilds(dragValue, albumOld, albumNew);
+
+ updateAlbums(dragValue, dropValue, itemParent);
addTreeToRerender();
}
+ private void updateAlbums(Album dragValue, Album dropValue,
+ TreeNode<Object> itemParent) {
+ String albumOld = fileManager.concatwithSlash(user.getLogin(), dragValue.getAlbumPathFromParents(dragValue, Constants.SLASH, false ));
+ String albumNew = fileManager.concatwithSlash(user.getLogin() ,dropValue.getAlbumPathFromParents(dropValue, Constants.SLASH, false));
+ albumAction.renameAllImagesFromAlbumAndChilds(dragValue, albumOld, albumNew);
+ dropValue.addChildAlbum(dragValue);
+ updateTree(dragValue, dropValue, itemParent);
+ }
+
+ private void updateTree(Album dragValue, Album dropValue,
+ TreeNode<Object> itemParent) {
+ TreeAlbumItem itemParentNew = (TreeAlbumItem)treeMyAlbumsItem.getNode(dropValue.getName());
+ TreeAlbumItem item = (TreeAlbumItem)treeMyAlbumsItem.getNode(dragValue.getName());
+ itemParent.removeChild(item.getId());
+ itemParentNew.addAlbum(item);
+ }
+
private void handleImage(Image dragValue, Album dropValue) {
if(dragValue.getAlbum().equals(dropValue)){
return;
}
+ String newPath = getNewPathOfImage(dragValue, dropValue);
+ dragValue.setPath(newPath);
+ dropValue.addImage(dragValue);
+ albumAction.flush();
+ }
+
+ private String getNewPathOfImage(Image dragValue, Album dropValue) {
String fileNameOld = fileManager.transformToServerPath(dragValue.getPath());
int lastIndexOf = dragValue.getPath().lastIndexOf(Constants.SLASH);
String prevPathEnd = dragValue.getPath().substring(lastIndexOf);
- String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue, fileManager.getFileSeparator(), true) + prevPathEnd;
- String newPath = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, Constants.SLASH, true) + prevPathEnd;
- dragValue.setPath(newPath);
- dropValue.addImage(dragValue);
+ String fileNameNew = fileManager.concat(user.getLogin(), dropValue.getAlbumPathFromParents(dropValue, fileManager.getFileSeparator(), true), prevPathEnd);
+ String newPath = fileManager.concatwithSlash(user.getLogin() , dropValue.getAlbumPathFromParents(dropValue, Constants.SLASH, true), prevPathEnd);
fileManager.renameImage(fileNameOld, fileNameNew);
- albumAction.flush();
+ return newPath;
}
}
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-01-26 19:28:18 UTC (rev 12431)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-01-26 19:30:57 UTC (rev 12432)
@@ -20,7 +20,6 @@
*/
package org.richfaces.realworld.manager;
-import java.util.ArrayList;
import java.util.Date;
import org.jboss.seam.ScopeType;
@@ -36,12 +35,12 @@
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.navigation.NavigationEnum;
+import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IImageAction;
import org.richfaces.realworld.tree.TreeAlbumItem;
import org.richfaces.realworld.tree.TreeMyAlbumsItem;
import org.richfaces.realworld.ui.RatingBinder;
import org.richfaces.realworld.util.ConversationState;
-import org.richfaces.realworld.service.Constants;
@Name("imageManager")
@Scope(ScopeType.CONVERSATION)
@@ -72,17 +71,11 @@
public void editImage(Image image){
TreeAlbumItem parent = (TreeAlbumItem)treeMyAlbumsItem.getNode(image.getAlbum().getName());
- boolean parentChanged = !parent.getAlbum().getName().equals(image.getAlbumName());
+ boolean parentChanged = parentChanged(image, parent);
if(parentChanged){
TreeAlbumItem albumItem = (TreeAlbumItem)treeMyAlbumsItem.getNode(image.getAlbumName());
- String fileNameOld = fileManager.transformToServerPath(image.getPath());
- int lastIndexOf = image.getPath().lastIndexOf(Constants.SLASH);
- String prevPathEnd = image.getPath().substring(lastIndexOf);
- Album dropValue = ((TreeAlbumItem)treeMyAlbumsItem.getNode(image.getAlbumName())).getAlbum();
- String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue , fileManager.getFileSeparator(), true) + prevPathEnd;
- String newPath = user.getLogin() + Constants.SLASH + albumItem.getAlbum().getAlbumPathFromParents(albumItem.getAlbum(), Constants.SLASH, true) + prevPathEnd;
+ String newPath = getNewPathOfImage(image, albumItem);
image.setPath(newPath);
- fileManager.renameImage(fileNameOld, fileNameNew);
conversationState.setSelectedImage(image);
conversationState.setSelectedAlbum(albumItem.getAlbum());
}
@@ -123,4 +116,19 @@
public void vote(Image image){
imageAction.vote(image, Long.valueOf(ratingBinder.getInputSlider().getValue().toString()));
}
+
+ private boolean parentChanged(Image image, TreeAlbumItem parent) {
+ return !parent.getAlbum().getName().equals(image.getAlbumName());
+ }
+
+ private String getNewPathOfImage(Image image, TreeAlbumItem albumItem) {
+ String fileNameOld = fileManager.transformToServerPath(image.getPath());
+ int lastIndexOf = image.getPath().lastIndexOf(Constants.SLASH);
+ String prevPathEnd = image.getPath().substring(lastIndexOf);
+ Album dropValue = ((TreeAlbumItem)treeMyAlbumsItem.getNode(image.getAlbumName())).getAlbum();
+ String fileNameNew = fileManager.concat(user.getLogin(), dropValue.getAlbumPathFromParents(dropValue , fileManager.getFileSeparator(), true), prevPathEnd);
+ String newPath = fileManager.concatwithSlash(user.getLogin(), albumItem.getAlbum().getAlbumPathFromParents(albumItem.getAlbum(), Constants.SLASH, true), prevPathEnd);
+ fileManager.renameImage(fileNameOld, fileNameNew);
+ return newPath;
+ }
}
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/UserManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/UserManager.java 2009-01-26 19:28:18 UTC (rev 12431)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/UserManager.java 2009-01-26 19:30:57 UTC (rev 12432)
@@ -125,9 +125,4 @@
public List<Album> getRootAlbums(User user2) {
return userAction.getRootAlbums(user2);
}
-
- public String getPathOfImage(String path){
- int i = path.lastIndexOf(Constants.SLASH);
- return path.substring(i);
- }
}
Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/image/breadCrumb.xhtml
===================================================================
(Binary files differ)
15 years, 11 months
JBoss Rich Faces SVN: r12431 - in trunk/test-applications/realworld: ejb/src/main/java/org/richfaces/realworld/service and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-01-26 14:28:18 -0500 (Mon, 26 Jan 2009)
New Revision: 12431
Added:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java
Removed:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.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/manager/AlbumManager.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/manager/DnDManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ConversationState.java
trunk/test-applications/realworld/web/src/main/webapp/includes/fileUpload/fileUploader.xhtml
trunk/test-applications/realworld/web/src/main/webapp/includes/search.xhtml
trunk/test-applications/realworld/web/src/main/webapp/includes/search/advancedSearch.xhtml
trunk/test-applications/realworld/web/src/main/webapp/includes/search/searchResults.xhtml
Log:
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -53,7 +53,11 @@
*
* @author Andrey Markhel
*/
-@NamedQueries( { @NamedQuery(name = "album-byAlbumNameAndLogin", query = "from Album a where a.name=:albumName and a.owner.login=:login") })
+@NamedQueries(
+ {
+ @NamedQuery(name = "album-byAlbumNameAndLogin", query = "from Album a where a.name=:albumName and a.owner.login=:login")
+ }
+ )
@Entity
@Name("album")
@Table(name = "albums")
@@ -106,12 +110,6 @@
@org.hibernate.annotations.ForeignKey(name = "FK_ALBUM_PARENT_ID")
private Album parent;
- /**
- * No-arg constructor for JavaBean tools
- */
- public Album() {
- }
-
// ********************** Accessor Methods ********************** //
public List<Album> getChildAlbums() {
@@ -120,7 +118,7 @@
public void addChildAlbum(Album album) {
if (album == null)
- throw new IllegalArgumentException("Null child category!");
+ throw new IllegalArgumentException("Null child!");
if (album.getParent() != null)
album.getParent().getChildAlbums().remove(album);
album.setParent(this);
@@ -129,7 +127,7 @@
public void removeChildAlbum(Album album) {
if (album == null)
- throw new IllegalArgumentException("Null child category!");
+ throw new IllegalArgumentException("Null child!");
album.setParent(null);
childAlbums.remove(album);
}
@@ -142,17 +140,28 @@
this.parent = parent;
}
+ public String getAlbumPathFromParents(Album album,
+ String delimiter, boolean includeSelf) {
+ return this.getAlbumPathFromParents(album, new ArrayList<String>(), delimiter, includeSelf);
+ }
+
public String getAlbumPathFromParents(Album album, List<String> list,
- String delimiter) {
+ String delimiter, boolean includeSelf) {
if (album.getParent() == null) {
+ //If this album haven't parent - it is root, so add them first
list.add(album.getName() + delimiter);
- return "";
+ //If it's method invoke on root album returned value will be dependent on flag
+ return includeSelf ? album.getName() + delimiter : "";
} else {
+ //recursive call
album.getParent().getAlbumPathFromParents(album.getParent(), list,
- delimiter);
+ delimiter, includeSelf);
}
- list.add(this.getName() + delimiter);
+ if(includeSelf){
+ list.add(this.getName() + delimiter);
+ }
String path = "";
+ //Create string representation of path
for (int i = 0; i < list.size(); i++) {
path += list.get(i);
}
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -153,28 +153,12 @@
)
private List<User> sharedOwners = new ArrayList<User>();
- /**
- * No-arg constructor for JavaBean tools
- */
- public Image() {
- }
-
- /**
- * Constructor
- *
- * @param name - name of album
- * @param parent - link for parent album
- */
- public Image(String name) {
- this.name = name;
- }
-
// ********************** Accessor Methods ********************** //
/**
* Getter for property id
*
- * @return id of album
+ * @return id of image
*/
public Long getId() {
return id;
@@ -183,7 +167,7 @@
/**
* Getter for property name
*
- * @return name of album
+ * @return name of image
*/
public String getName() {
return name;
@@ -192,7 +176,7 @@
/**
* Setter for property name
*
- * @param name - name of album
+ * @param name - name of image
*/
public void setName(String name) {
this.name = name;
@@ -209,7 +193,7 @@
/**
* Getter for property description
*
- * @return description of album
+ * @return description of image
*/
public String getDescription() {
return description;
@@ -218,7 +202,7 @@
/**
* Setter for property description
*
- * @param description - description of album
+ * @param description - description of image
*/
public void setDescription(String description) {
this.description = description;
@@ -320,10 +304,6 @@
return comments;
}
- public void setComments(List<Comment> comments) {
- this.comments = comments;
- }
-
public Rank getRank() {
return rank;
}
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -169,12 +169,6 @@
@OneToMany(mappedBy = "user", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
private List<FriendshipRequest> friendshipRequests = new ArrayList<FriendshipRequest>();
- /**
- * No-arg constructor for JavaBean tools
- */
- public User() {
- }
-
public String getFirstName() {
return firstName;
}
@@ -230,18 +224,9 @@
public List<Album> getChildAlbums() {
return childAlbums;
}
-
- public void setChildAlbums(List<Album> childAlbums) {
- this.childAlbums = childAlbums;
- }
//---------------------------Business methods
- /**
- * This method add image to collection of images of current album
- *
- * @param image - image to add
- */
public void addAlbum(Album album) {
if (album == null) {
throw new IllegalArgumentException("Null album!");
@@ -253,11 +238,6 @@
childAlbums.add(album);
}
- /**
- * This method remove image from collection of images of album
- *
- * @param image - image to remove
- */
public void removeAlbum(Album album) {
if (album == null) {
throw new IllegalArgumentException("Null album");
@@ -304,34 +284,18 @@
return friends;
}
- public void setFriends(List<User> friends) {
- this.friends = friends;
- }
-
public List<Album> getFavoriteAlbums() {
return favoriteAlbums;
}
- public void setFavoriteAlbums(List<Album> favoriteAlbums) {
- this.favoriteAlbums = favoriteAlbums;
- }
-
public List<Message> getMessages() {
return messages;
}
- public void setMessages(List<Message> messages) {
- this.messages = messages;
- }
-
public List<FriendshipRequest> getFriendshipRequests() {
return friendshipRequests;
}
- public void setFriendshipRequests(List<FriendshipRequest> friendshipRequests) {
- this.friendshipRequests = friendshipRequests;
- }
-
public void addFriendshipRequest(User owner) {
if (getFriendshipRequest(owner, this) != null) {
return;
@@ -359,15 +323,6 @@
return null;
}
- public Album getAlbumByName(String albumName){
- for(Album a : this.getChildAlbums()){
- if(a.getName().equals(albumName)){
- return a;
- }
- }
- return null;
- }
-
public void removeFromFavoriteAlbums(Album album) {
favoriteAlbums.remove(album);
}
@@ -399,8 +354,4 @@
public List<Image> getFavoriteImages() {
return favoriteImages;
}
-
- public void setFavoriteImages(List<Image> favoriteImages) {
- this.favoriteImages = favoriteImages;
- }
}
\ No newline at end of file
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -1,8 +1,25 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.richfaces.realworld.service;
-import org.jboss.seam.annotations.In;
-import org.richfaces.realworld.service.IUserAction;
-
public class Constants {
public static final String ERROR_ID = "mainform:error";
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -78,12 +78,8 @@
}
public void vote(Image image, Long value) {
- Long total = image.getRank().getTotal();
- Long votes = image.getRank().getHits();
- total += value;
- votes++;
- image.getRank().setHits(votes);
- image.getRank().setTotal(total);
+ image.getRank().setHits(image.getRank().getHits() + 1);
+ image.getRank().setTotal(value += image.getRank().getTotal());
em.flush();
}
}
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -26,7 +26,7 @@
public class MessageComparator implements Comparator<Message> {
- public int compare(Message mes1, Message mes2) {
- return mes1.getDate().after(mes2.getDate())?-1:1;
- }
+ public int compare(Message mes1, Message mes2) {
+ return mes1.getDate().after(mes2.getDate()) ? -1 : 1;
+ }
}
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -52,14 +52,7 @@
return null;
}
String fullQuery = null;
- if(paramMap != null && paramMap.get(Constants.CASE_SENSITIVE_PARAMETER) != null){
- boolean sensitive = (Boolean)paramMap.get(Constants.CASE_SENSITIVE_PARAMETER);
- if(sensitive){
- fullQuery = Constants.SEARCH_SENSITIVE_QUERY_BEGIN + additionalParams + Constants.SEARCH_QUERY_END;
- }else{
- fullQuery = Constants.SEARCH_QUERY_BEGIN + additionalParams + Constants.SEARCH_QUERY_END;
- }
- }
+ fullQuery = setupCaseForQuery(additionalParams, paramMap, fullQuery);
Query prepared = prepareQuery(fullQuery, additions.get(0), additionalParams, paramMap);
List<Image> tempResult = prepared.getResultList();
additions.remove(0);
@@ -92,6 +85,19 @@
return (List<String>)query.getResultList();
}
+ private String setupCaseForQuery(String additionalParams,
+ Map<String, Object> paramMap, String fullQuery) {
+ if(paramMap != null && paramMap.get(Constants.CASE_SENSITIVE_PARAMETER) != null){
+ boolean sensitive = (Boolean)paramMap.get(Constants.CASE_SENSITIVE_PARAMETER);
+ if(sensitive){
+ fullQuery = Constants.SEARCH_SENSITIVE_QUERY_BEGIN + additionalParams + Constants.SEARCH_QUERY_END;
+ }else{
+ fullQuery = Constants.SEARCH_QUERY_BEGIN + additionalParams + Constants.SEARCH_QUERY_END;
+ }
+ }
+ return fullQuery;
+ }
+
private Query prepareQuery(String fullQuery ,String searchPattern, String additionalParams,
Map<String, Object> paramMap) {
Query prepared = em.createQuery(fullQuery);
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-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -70,8 +70,12 @@
File file = new File(fullPath);
return file.exists() && file.isDirectory();
}
-
- public void deleteDirectory(String directory) {
+
+ public void deleteDirectory(String... directories) {
+ String directory = new String();
+ for (String chunk: directories){
+ directory += chunk + getFileSeparator();
+ }
String fullPath = getAbsolutePath(directory);
File file = new File(fullPath);
if(file.exists()){
@@ -82,6 +86,22 @@
file.delete();
}
}
+
+ public String concat(String... directories){
+ String directory = new String();
+ for (String chunk: directories){
+ directory += chunk + getFileSeparator();
+ }
+ return directory;
+ }
+
+ public String concatwithSlash(String... directories){
+ String directory = new String();
+ for (String chunk: directories){
+ directory += chunk + Constants.SLASH;
+ }
+ return directory;
+ }
public boolean renameDirectory(String directoryOld, String directoryNew){
String fullPath = getAbsolutePath(directoryOld);
@@ -90,7 +110,6 @@
createDirectoryIfNotExist(directoryNew);
if(fileNew.exists())
if( fileNew.isDirectory() ){
- //throw new Exception(Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
return false;
}else{
fileNew.delete();
@@ -98,18 +117,31 @@
fileOld.renameTo(fileNew);
return true;
}
-
- public void addDirectory(String directory) {
- String fullPath = getAbsolutePath(directory);
+
+ public void addDirectory(String... directories) {
+ String directory = new String();
+ for (String chunk: directories){
+ directory += chunk + getFileSeparator();
+ }
+ String fullPath = getAbsolutePath(removeSlashFromEnd(directory));
File file = new File(fullPath);
file.mkdirs();
}
- public void addImage(String fileName, byte[] data) throws IOException {
+ private String removeSlashFromEnd(String directory) {
+ return directory.substring(0, directory.length() - 2);
+ }
+
+ public boolean addImage(String fileName, byte[] data) {
createDirectoryIfNotExist(fileName);
- writeFileTodisk(data, fileName, 0, 0, "" );
- writeFileTodisk(data, fileName, 50, 50, _MINI );
- writeFileTodisk(data, fileName, 600, 400, _MEDIUM );
+ try {
+ writeFileTodisk(data, fileName, 0, 0, "" );
+ writeFileTodisk(data, fileName, 50, 50, _MINI );
+ writeFileTodisk(data, fileName, 600, 400, _MEDIUM );
+ } catch (IOException e) {
+ return false;
+ }
+ return true;
}
private void writeFileTodisk(byte[] data, String fileName, int width, int height, String format) throws IOException{
@@ -140,57 +172,33 @@
String end = target.substring(target.lastIndexOf(Constants.DOT));
return begin + substitute + end;
}
-
- public void deleteAllFromDirectory(String directory){
- String fullPath = getAbsolutePath(directory);
- File file = new File(fullPath);
- if(file.exists()){
- for(String f :file.list()){
- File temp = new File(fullPath+getFileSeparator()+f);
- temp.delete();
- }
- }else{
- file.mkdirs();
- }
- }
public void deleteImage(String fileName) {
String fullPath = getAbsolutePath(fileName);
- File file = new File(fullPath);
+ deleteImage(new File(fullPath));
+ deleteImage(new File(transformPath(fullPath, _MINI)));
+ deleteImage(new File(transformPath(fullPath, _MEDIUM)));
+ }
+
+ private void deleteImage(File file){
if(file.exists()){
file.delete();
}
- file = new File(transformPath(fullPath, _MINI));
- if(file.exists()){
- file.delete();
- }
- file = new File(transformPath(fullPath, _MEDIUM));
- if(file.exists()){
- file.delete();
- }
}
-
+
public void renameImage(String fileNameOld, String fileNameNew) {
createDirectoryIfNotExist(fileNameNew);
String fullPath = getAbsolutePath(fileNameOld);
- File fileOld = new File(fullPath);
- File fileNew = new File(getAbsolutePath(fileNameNew));
+ renameImage(new File(getAbsolutePath(fileNameNew)), new File(fullPath));
+ renameImage(new File(getAbsolutePath(transformPath(fileNameNew, _MINI))), new File(transformPath(fullPath, _MINI)));
+ renameImage(new File(getAbsolutePath(transformPath(fileNameNew, _MEDIUM))), new File(transformPath(fullPath, _MEDIUM)));
+ }
+
+ private void renameImage(File fileNew, File fileOld){
if(fileNew.exists()){
fileNew.delete();
}
fileOld.renameTo(fileNew);
- fileOld = new File(transformPath(fullPath, _MINI));
- fileNew = new File(getAbsolutePath(transformPath(fileNameNew, _MINI)));
- if(fileNew.exists()){
- fileNew.delete();
- }
- fileOld.renameTo(fileNew);
- fileOld = new File(transformPath(fullPath, _MEDIUM));
- fileNew = new File(getAbsolutePath(transformPath(fileNameNew, _MEDIUM)));
- if(fileNew.exists()){
- fileNew.delete();
- }
- fileOld.renameTo(fileNew);
}
private void createDirectoryIfNotExist(String fileNameNew) {
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-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -22,7 +22,6 @@
package org.richfaces.realworld.fileupload;
import java.io.ByteArrayInputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
@@ -30,7 +29,6 @@
import java.util.List;
import javax.faces.model.SelectItem;
-import org.richfaces.realworld.service.Constants;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
@@ -45,6 +43,7 @@
import org.richfaces.realworld.domain.MetaTag;
import org.richfaces.realworld.domain.Rank;
import org.richfaces.realworld.domain.User;
+import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.util.ConversationState;
import com.drew.imaging.jpeg.JpegMetadataReader;
@@ -86,6 +85,8 @@
private String selectedMode;
private int fileQuantity = 1;
+
+ private boolean immediateUpload = false;
private boolean fileUploadRendered;
@@ -128,11 +129,8 @@
if (file.isSelected()) {
// Save file to disk
String fileName = fileManager.transformToServerPath(file.getImage().getPath());
- try {
- fileManager.addImage(fileName, file.getData());
- } catch (IOException e) {
+ if(!fileManager.addImage(fileName, file.getData())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_SAVE_ERROR));
- return;
}
// Update domain model
Events.instance().raiseEvent(Constants.ADD_IMAGE_EVENT, file.getImage());
@@ -149,11 +147,8 @@
// Save file to disk
String fileName = fileManager.transformToServerPath(file.getImage()
.getPath());
- try {
- fileManager.addImage(fileName, file.getData());
- } catch (IOException e) {
+ if(!fileManager.addImage(fileName, file.getData())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_SAVE_ERROR));
- return;
}
// Update domain model
Events.instance().raiseEvent(Constants.ADD_IMAGE_EVENT, file.getImage());
@@ -176,10 +171,12 @@
}
public void changeMode() {
- if (this.getSelectedMode().equals(Constants.SINGLE)) {
- this.setFileQuantity(Constants.SINGLE_MODE_FILE_QUANTITY);
- } else if (this.getSelectedMode().equals(Constants.MULTY)) {
- this.setFileQuantity(Constants.MULTY_MODE_FILE_QUANTITY);
+ if (getSelectedMode().equals(Constants.SINGLE)) {
+ setFileQuantity(Constants.SINGLE_MODE_FILE_QUANTITY);
+ setImmediateUpload(false);
+ } else if (getSelectedMode().equals(Constants.MULTY)) {
+ setFileQuantity(Constants.MULTY_MODE_FILE_QUANTITY);
+ setImmediateUpload(true);
}
}
@@ -214,7 +211,7 @@
image.setName(SAMPLE_NAME);
image.setSize(file.getLength() / Constants.KB);
String albumPath = conversationState.getSelectedAlbum().getAlbumPathFromParents(conversationState.getSelectedAlbum(),
- new ArrayList<String>(), Constants.SLASH)+ conversationState.getSelectedAlbum().getName() + Constants.SLASH;
+ Constants.SLASH, true);
image.setPath(user.getLogin() + Constants.SLASH + albumPath + item.getFileName());
image.setAlbumName(conversationState.getSelectedAlbum().getName());
image.setAlbum(conversationState.getSelectedAlbum());
@@ -278,4 +275,12 @@
image.setCameraModel(cameraModel);
}
}
+
+ public boolean isImmediateUpload() {
+ return immediateUpload;
+ }
+
+ public void setImmediateUpload(boolean immediateUpload) {
+ this.immediateUpload = immediateUpload;
+ }
}
\ No newline at end of file
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-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -37,6 +37,7 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Events;
@Name("imageLoader")
@Scope(ScopeType.CONVERSATION)
@@ -73,8 +74,8 @@
paintData = bufferedInputStream;
paintData.read(data);
} catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_PROCESSING_ERROR));
+ return;
} finally {
fileInputStream.close();
bufferedInputStream.close();
@@ -94,14 +95,15 @@
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
InputStream paintData = bufferedInputStream;
if (null == paintData) {
- // throw new Exception("");
- // TODO
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_PROCESSING_ERROR));
+ return;
}
try {
BufferedImage images = ImageIO.read(paintData);
ImageIO.write(images, Constants.JPEG, out);
} catch (Exception e) {
-
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_PROCESSING_ERROR));
+ return;
} finally {
fileInputStream.close();
bufferedInputStream.close();
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -20,9 +20,6 @@
*/
package org.richfaces.realworld.manager;
-import java.util.ArrayList;
-import java.util.List;
-
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
@@ -33,10 +30,10 @@
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.fileupload.FileManager;
+import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IAlbumAction;
import org.richfaces.realworld.tree.TreeAlbumItem;
import org.richfaces.realworld.tree.TreeMyAlbumsItem;
-import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.util.ConversationState;
@Name("albumManager")
@@ -61,61 +58,98 @@
private ConversationState conversationState;
public void addAlbum(){
- //Update domain model
albumAction.addAlbum(album);
- //Correcting tree
- TreeNode<Object> parent = findParentTreeNode();
- TreeAlbumItem albumItem = new TreeAlbumItem(album.getId(), parent, album, treeMyAlbumsItem);
- treeMyAlbumsItem.addAlbumToTree(parent, albumItem);
- //Create directory on disk
- List<String> list = new ArrayList<String>();
- String albumPath = album.getAlbumPathFromParents(album, list, fileManager.getFileSeparator()) + album.getName();
- fileManager.addDirectory(user.getLogin() + fileManager.getFileSeparator() + albumPath);
+ addAlbumToTree();
+ addDirectory();
//Update conversation state
conversationState.setSelectedImage(null);
- conversationState.setSelectedAlbum(albumItem.getAlbum());
-
+ conversationState.setSelectedAlbum(album);
}
-
- private TreeNode<Object> findParentTreeNode() {
- TreeNode<Object> parent = null;
- if(null == album.getParent()){
- parent = treeMyAlbumsItem;
- }else{
- parent = treeMyAlbumsItem.getNode(album.getParent().getName());
- }
- return parent;
- }
-
+
public void editAlbum(Album album){
boolean nameChanged = !album.getName().equals(album.getChangedName());
if(nameChanged){
- String directoryOld = user.getLogin() + fileManager.getFileSeparator() + album.getAlbumPathFromParents(album, new ArrayList<String>(),fileManager.getFileSeparator() )+album.getName();
- Album oldAlbum = ((TreeAlbumItem)treeMyAlbumsItem.getNode(album.getName())).getAlbum();
- String directoryNew = user.getLogin() + fileManager.getFileSeparator() + oldAlbum.getAlbumPathFromParents(oldAlbum, new ArrayList<String>(),fileManager.getFileSeparator() )+album.getChangedName();
- if(!fileManager.renameDirectory(directoryOld, directoryNew)){
+ Album oldAlbum = getOldTreeNode(album);
+ if(!renameDirectory(album, oldAlbum)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
return;
}
- String albumOld = user.getLogin() + Constants.SLASH + album.getAlbumPathFromParents(album, new ArrayList<String>(),Constants.SLASH )+album.getName();
- String albumNew = user.getLogin() + Constants.SLASH + oldAlbum.getAlbumPathFromParents(oldAlbum, new ArrayList<String>(),Constants.SLASH )+album.getChangedName();
- albumAction.renameAllImagesFromAlbumAndChilds(album, albumOld, albumNew);
+ renameImagesFromAlbum(album, oldAlbum);
album.setName(album.getChangedName());
album.setChangedName(null);
}
albumAction.editAlbum(album);
treeMyAlbumsItem.updateChild(album);
+ conversationState.setSelectedAlbum(album);
}
-
+
public void deleteAlbum(Album album){
//Update domain model
- String albumName = album.getName();
+ String albumName = album.getAlbumPathFromParents(album, fileManager.getFileSeparator(), true);
albumAction.deleteAlbum(album);
- //Update tree
+ removeFromTree(album);
+ deleteDirectory(albumName);
+ conversationState.setSelectedImage(null);
+ conversationState.setSelectedAlbum(null);
+ }
+
+ private void renameImagesFromAlbum(Album album, Album oldAlbum) {
+ String albumOld = getOldAlbumPath(album);
+ String albumNew = getNewAlbumPath(album, oldAlbum);
+ albumAction.renameAllImagesFromAlbumAndChilds(album, albumOld, albumNew);
+ }
+
+ private boolean renameDirectory(Album album, Album oldAlbum) {
+ String directoryOld = getOldDirectory(album);
+ String directoryNew = getNewDirectory(album, oldAlbum);
+ return fileManager.renameDirectory(directoryOld, directoryNew);
+ }
+
+ private String getNewAlbumPath(Album album, Album oldAlbum) {
+ return fileManager.concatwithSlash(user.getLogin(), oldAlbum.getAlbumPathFromParents(oldAlbum, Constants.SLASH, false ), album.getChangedName());
+ }
+
+ private String getOldAlbumPath(Album album) {
+ return fileManager.concatwithSlash(user.getLogin(), album.getAlbumPathFromParents(album, Constants.SLASH, true ));
+ }
+
+ private String getNewDirectory(Album album, Album oldAlbum) {
+ return fileManager.concat(user.getLogin(), oldAlbum.getAlbumPathFromParents(oldAlbum, fileManager.getFileSeparator(), false ), album.getChangedName());
+ }
+
+ private Album getOldTreeNode(Album album) {
+ return ((TreeAlbumItem)treeMyAlbumsItem.getNode(album.getName())).getAlbum();
+ }
+
+ private String getOldDirectory(Album album) {
+ return fileManager.concat(user.getLogin() ,album.getAlbumPathFromParents(album, fileManager.getFileSeparator(), true ));
+ }
+
+ private void removeFromTree(Album album) {
TreeAlbumItem oldAlbum = (TreeAlbumItem)treeMyAlbumsItem.getNode(album.getName());
oldAlbum.getParent().removeChild(album.getId());
- //Delete from disk
- fileManager.deleteDirectory(user.getLogin() + fileManager.getFileSeparator() + albumName);
}
+ private void deleteDirectory(String albumName) {
+ fileManager.deleteDirectory(user.getLogin(), albumName);
+ }
+
+ private void addDirectory() {
+ String albumPath = album.getAlbumPathFromParents(album, fileManager.getFileSeparator(), true) ;
+ fileManager.addDirectory(user.getLogin(), albumPath);
+ }
+
+ private void addAlbumToTree() {
+ TreeNode<Object> parent = findParentTreeNode();
+ TreeAlbumItem albumItem = new TreeAlbumItem(album.getId(), parent, album, treeMyAlbumsItem);
+ treeMyAlbumsItem.addAlbumToTree(parent, albumItem);
+ }
+
+ private TreeNode<Object> findParentTreeNode() {
+ if(null == album.getParent()){
+ return treeMyAlbumsItem;
+ }else{
+ return treeMyAlbumsItem.getNode(album.getParent().getName());
+ }
+ }
}
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-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -75,7 +75,7 @@
public boolean authenticate()
{
- if (null == credentials.getUsername() || credentials.getUsername().equals("")) {
+ if (wantLoginAnonymous()) {
identity.addRole(Constants.GUEST_ROLE);
userAction.loginAnonymous();
Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,NavigationEnum.SEARCH);
@@ -85,9 +85,7 @@
User user = userAction.login(credentials.getUsername(), credentials.getPassword());
if (user != null) {
identity.addRole(Constants.ADMIN_ROLE);
- if (!fileManager.isDirectoryPresent(credentials.getUsername())) {
- fileManager.addDirectory(credentials.getUsername());
- }
+ setupCatalogForUser();
conversationState.setSelectedUser(user);
Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,NavigationEnum.IMAGE_PREVIEW);
return true;
@@ -98,6 +96,16 @@
}
return false;
}
+
+ private void setupCatalogForUser() {
+ if (!fileManager.isDirectoryPresent(credentials.getUsername())) {
+ fileManager.addDirectory(credentials.getUsername());
+ }
+ }
+
+ private boolean wantLoginAnonymous() {
+ return null == credentials.getUsername() || credentials.getUsername().equals("");
+ }
@End
public String register(User user){
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -20,8 +20,6 @@
*/
package org.richfaces.realworld.manager;
-import java.util.ArrayList;
-
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import org.richfaces.realworld.service.Constants;
@@ -81,13 +79,13 @@
}else{
return;
}
- String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(), fileManager.getFileSeparator() )+ dragValue.getName();
+ String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue, fileManager.getFileSeparator(), true );
String directoryNew = user.getLogin() + fileManager.getFileSeparator() + dragValue.getName();
if(!fileManager.renameDirectory(directoryOld, directoryNew)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
return;
}
- String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(), Constants.SLASH );
+ String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, Constants.SLASH, false );
String albumNew = user.getLogin() + Constants.SLASH;
TreeAlbumItem item = (TreeAlbumItem)treeMyAlbumsItem.getNode(dragValue.getName());
itemParent.removeChild(item.getId());
@@ -121,10 +119,10 @@
}else{
itemParent = treeMyAlbumsItem;
}
- String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(), fileManager.getFileSeparator() ) + dragValue.getName();
- String directoryNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue, new ArrayList<String>(), fileManager.getFileSeparator()) + dragValue.getName();
- String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(), Constants.SLASH );
- String albumNew = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, new ArrayList<String>(), Constants.SLASH);
+ String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue, fileManager.getFileSeparator(), true );
+ String directoryNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue, fileManager.getFileSeparator(), false) + dragValue.getName();
+ String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, Constants.SLASH, false );
+ String albumNew = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, Constants.SLASH, false);
dropValue.addChildAlbum(dragValue);
TreeAlbumItem itemParentNew = (TreeAlbumItem)treeMyAlbumsItem.getNode(dropValue.getName());
TreeAlbumItem item = (TreeAlbumItem)treeMyAlbumsItem.getNode(dragValue.getName());
@@ -145,12 +143,11 @@
String fileNameOld = fileManager.transformToServerPath(dragValue.getPath());
int lastIndexOf = dragValue.getPath().lastIndexOf(Constants.SLASH);
String prevPathEnd = dragValue.getPath().substring(lastIndexOf);
- String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue, new ArrayList<String>(), fileManager.getFileSeparator()) + prevPathEnd;
- String newPath = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, new ArrayList<String>(), Constants.SLASH) + prevPathEnd;
+ String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue, fileManager.getFileSeparator(), true) + prevPathEnd;
+ String newPath = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, Constants.SLASH, true) + prevPathEnd;
dragValue.setPath(newPath);
dropValue.addImage(dragValue);
fileManager.renameImage(fileNameOld, fileNameNew);
albumAction.flush();
}
-
}
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -79,8 +79,8 @@
int lastIndexOf = image.getPath().lastIndexOf(Constants.SLASH);
String prevPathEnd = image.getPath().substring(lastIndexOf);
Album dropValue = ((TreeAlbumItem)treeMyAlbumsItem.getNode(image.getAlbumName())).getAlbum();
- String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue , new ArrayList<String>(), fileManager.getFileSeparator()) + prevPathEnd;
- String newPath = user.getLogin() + Constants.SLASH + albumItem.getAlbum().getAlbumPathFromParents(albumItem.getAlbum(), new ArrayList<String>(), Constants.SLASH) + prevPathEnd;
+ String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue , fileManager.getFileSeparator(), true) + prevPathEnd;
+ String newPath = user.getLogin() + Constants.SLASH + albumItem.getAlbum().getAlbumPathFromParents(albumItem.getAlbum(), Constants.SLASH, true) + prevPathEnd;
image.setPath(newPath);
fileManager.renameImage(fileNameOld, fileNameNew);
conversationState.setSelectedImage(image);
Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -0,0 +1,163 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.realworld.manager;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.search.SearchBeanHelper;
+import org.richfaces.realworld.search.SearchParamHolder;
+import org.richfaces.realworld.service.Constants;
+import org.richfaces.realworld.service.ISearchService;
+
+@Name("searchManager")
+(a)Scope(ScopeType.CONVERSATION)
+public class SearchManager implements Serializable {
+
+ @In(required = false)
+ private SearchBeanHelper helper;
+
+ @In(required = false)
+ private SearchParamHolder searchParams;
+
+ private static final long serialVersionUID = 5071655218132021316L;
+
+ @In(create=true)
+ private ISearchService searchService;
+
+ private List<Image> findedImages = new ArrayList<Image>();
+
+ public List<String> getAllCameras(){
+ return searchService.getAllCameras();
+ }
+
+ public List<String> getAllMetatags(){
+ return searchService.getAllMetatags();
+ }
+
+ public List<Image> searchImages(){
+ String additionalParams = populateAdditionalParams();
+ findedImages = searchService.searchImages(searchParams.getSearchPattern(), additionalParams, populateMap(additionalParams));
+ return findedImages;
+ }
+
+ public List<Image> popularImages(){
+ return searchService.popularImages();
+ }
+
+ public List<Image> worstImages(){
+ return searchService.worstImages();
+ }
+
+ private Map<String, Object> populateMap(String additionalParams) {
+ Map<String, Object> map = new HashMap<String, Object>();
+ populateParameter(map, additionalParams, Constants.SPINNER_VALUE_NAMED_PARAMETER, Long.valueOf(helper.getInputSpinner().getValue().toString()));
+ populateParameter(map, additionalParams, Constants.CHOICE_NAMED_PARAMETER, searchParams.getNumberOfVotes());
+ populateParameter(map, additionalParams, Constants.DATE_NAMED_PARAMETER, searchParams.getDate());
+ populateParameter(map, additionalParams, Constants.UPLOAD_NAMED_PARAMETER, searchParams.getUploadDate());
+ populateParameter(map, additionalParams, Constants.SIZE_NAMED_PARAMETER, searchParams.getSize());
+ populateParameter(map, additionalParams, Constants.WIDTH_NAMED_PARAMETER, searchParams.getWidth());
+ populateParameter(map, additionalParams, Constants.HEIGHT_NAMED_PARAMETER, searchParams.getHeight());
+ populateParameter(map, additionalParams, Constants.CAMERA_NAMED_PARAMETER, searchParams.getCamera());
+ if(searchParams.getMatcherChoice() != null){
+ map.put(Constants.STRICT_PARAMETER, getMatcher(searchParams.getMatcherChoice()));
+ }
+ map.put(Constants.CASE_SENSITIVE_PARAMETER, searchParams.isCaseSensitive());
+ return map;
+ }
+
+ private String populateAdditionalParams() {
+ StringBuilder additionalParams = new StringBuilder("");
+ populateChoiceAddon(additionalParams, searchParams.getSpinnerChoice(), Constants.SPINNER_ADDON, Constants.SPINNER_VALUE_NAMED_PARAMETER);
+ populateChoiceAddon(additionalParams, searchParams.getVotesChoice(), Constants.VOTES_ADDON, Constants.CHOICE_NAMED_PARAMETER);
+ populateDateAddon(additionalParams, searchParams.getDateChoice(), Constants.DATE_ADDON, Constants.DATE_NAMED_PARAMETER, searchParams.getDate());
+ populateDateAddon(additionalParams, searchParams.getUploadChoice(), Constants.UPLOAD_ADDON, Constants.UPLOAD_NAMED_PARAMETER, searchParams.getUploadDate());
+ populateChoiceAddon(additionalParams, searchParams.getWidthChoice(), Constants.WIDTH_ADDON, Constants.WIDTH_NAMED_PARAMETER);
+ populateChoiceAddon(additionalParams, searchParams.getHeightChoice(), Constants.HEIGHT_ADDON, Constants.HEIGHT_NAMED_PARAMETER);
+ populateChoiceAddon(additionalParams, searchParams.getSizeChoice(), Constants.SIZE_ADDON, Constants.SIZE_NAMED_PARAMETER);
+ if(searchParams.getCamera()!= null && !searchParams.getCamera().equals("")){
+ additionalParams.append(Constants.CAMERA_ADDON);
+ additionalParams.append(Constants.EQUALS);
+ additionalParams.append(Constants.CAMERA_NAMED_PARAMETER);
+ }
+ return additionalParams.toString();
+ }
+
+ private String getAstFromIndex(Long item){
+ if(item == 1L){
+ return Constants.GREATTHEN;
+ }else if(item == 2L){
+ return Constants.LESSTHEN;
+ }else if(item == 3L){
+ return Constants.EQUALS;
+ }
+ return null;
+ }
+
+ private String getMatcher(Long item){
+ if(item == 1L){
+ return Constants.START;
+ }else if(item == 2L){
+ return Constants.END;
+ }else if(item == 3L){
+ return Constants.INCLUDE;
+ }else if(item == 0L){
+ return Constants.STRICT;
+ }
+ return null;
+ }
+
+ private void populateParameter(Map<String, Object> map, String additionalParams, String parameter, Object value){
+ if(additionalParams.lastIndexOf(parameter) != -1){
+ map.put(parameter, value);
+ }
+ }
+
+ private void populateChoiceAddon(StringBuilder additionalParams, Long choice, String addon, String namedParameter){
+ if(choice != null && choice > 0L){
+ additionalParams.append(addon);
+ additionalParams.append(getAstFromIndex(choice));
+ additionalParams.append(namedParameter);
+ }
+ }
+
+ private void populateDateAddon(StringBuilder additionalParams, Long choice, String addon, String namedParameter, Date date){
+ if(choice != null && choice > 0L && date != null ){
+ additionalParams.append(addon);
+ additionalParams.append(getAstFromIndex(choice));
+ additionalParams.append(namedParameter);
+ }
+ }
+
+ public List<Image> getFindedImages() {
+ return findedImages;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Deleted: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -1,161 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.realworld.search;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.service.Constants;
-import org.richfaces.realworld.service.ISearchService;
-
-@Name("searchBean")
-(a)Scope(ScopeType.CONVERSATION)
-public class SearchBean implements Serializable {
-
- @In(required = false)
- private SearchBeanHelper helper;
-
- @In(required = false)
- private SearchParamHolder searchParams;
-
- private static final long serialVersionUID = 5071655218132021316L;
-
- @In(create=true)
- private ISearchService searchService;
-
- private List<Image> findedImages = new ArrayList<Image>();
-
- public List<String> getAllCameras(){
- return searchService.getAllCameras();
- }
-
- public List<String> getAllMetatags(){
- return searchService.getAllMetatags();
- }
-
- public List<Image> searchImages(){
- String additionalParams = populateAdditionalParams();
- findedImages = searchService.searchImages(searchParams.getSearchPattern(), additionalParams, populateMap(additionalParams));
- return findedImages;
- }
-
- public List<Image> popularImages(){
- return searchService.popularImages();
- }
-
- public List<Image> worstImages(){
- return searchService.worstImages();
- }
-
- private Map<String, Object> populateMap(String additionalParams) {
- Map<String, Object> map = new HashMap<String, Object>();
- populateParameter(map, additionalParams, Constants.SPINNER_VALUE_NAMED_PARAMETER, Long.valueOf(helper.getInputSpinner().getValue().toString()));
- populateParameter(map, additionalParams, Constants.CHOICE_NAMED_PARAMETER, searchParams.getNumberOfVotes());
- populateParameter(map, additionalParams, Constants.DATE_NAMED_PARAMETER, searchParams.getDate());
- populateParameter(map, additionalParams, Constants.UPLOAD_NAMED_PARAMETER, searchParams.getUploadDate());
- populateParameter(map, additionalParams, Constants.SIZE_NAMED_PARAMETER, searchParams.getSize());
- populateParameter(map, additionalParams, Constants.WIDTH_NAMED_PARAMETER, searchParams.getWidth());
- populateParameter(map, additionalParams, Constants.HEIGHT_NAMED_PARAMETER, searchParams.getHeight());
- populateParameter(map, additionalParams, Constants.CAMERA_NAMED_PARAMETER, searchParams.getCamera());
- if(searchParams.getMatcherChoice() != null){
- map.put(Constants.STRICT_PARAMETER, getMatcher(searchParams.getMatcherChoice()));
- }
- map.put(Constants.CASE_SENSITIVE_PARAMETER, searchParams.isCaseSensitive());
- return map;
- }
-
- private String populateAdditionalParams() {
- StringBuilder additionalParams = new StringBuilder("");
- populateChoiceAddon(additionalParams, searchParams.getSpinnerChoice(), Constants.SPINNER_ADDON, Constants.SPINNER_VALUE_NAMED_PARAMETER);
- populateChoiceAddon(additionalParams, searchParams.getVotesChoice(), Constants.VOTES_ADDON, Constants.CHOICE_NAMED_PARAMETER);
- populateDateAddon(additionalParams, searchParams.getDateChoice(), Constants.DATE_ADDON, Constants.DATE_NAMED_PARAMETER, searchParams.getDate());
- populateDateAddon(additionalParams, searchParams.getUploadChoice(), Constants.UPLOAD_ADDON, Constants.UPLOAD_NAMED_PARAMETER, searchParams.getUploadDate());
- populateChoiceAddon(additionalParams, searchParams.getWidthChoice(), Constants.WIDTH_ADDON, Constants.WIDTH_NAMED_PARAMETER);
- populateChoiceAddon(additionalParams, searchParams.getHeightChoice(), Constants.HEIGHT_ADDON, Constants.HEIGHT_NAMED_PARAMETER);
- populateChoiceAddon(additionalParams, searchParams.getSizeChoice(), Constants.SIZE_ADDON, Constants.SIZE_NAMED_PARAMETER);
- if(searchParams.getCamera()!= null && !searchParams.getCamera().equals("")){
- additionalParams.append(Constants.CAMERA_ADDON);
- additionalParams.append(Constants.EQUALS);
- additionalParams.append(Constants.CAMERA_NAMED_PARAMETER);
- }
- return additionalParams.toString();
- }
-
- private String getAstFromIndex(Long item){
- if(item == 1L){
- return Constants.GREATTHEN;
- }else if(item == 2L){
- return Constants.LESSTHEN;
- }else if(item == 3L){
- return Constants.EQUALS;
- }
- return null;
- }
-
- private String getMatcher(Long item){
- if(item == 1L){
- return Constants.START;
- }else if(item == 2L){
- return Constants.END;
- }else if(item == 3L){
- return Constants.INCLUDE;
- }else if(item == 0L){
- return Constants.STRICT;
- }
- return null;
- }
-
- private void populateParameter(Map<String, Object> map, String additionalParams, String parameter, Object value){
- if(additionalParams.lastIndexOf(parameter) != -1){
- map.put(parameter, value);
- }
- }
-
- private void populateChoiceAddon(StringBuilder additionalParams, Long choice, String addon, String namedParameter){
- if(choice != null && choice > 0L){
- additionalParams.append(addon);
- additionalParams.append(getAstFromIndex(choice));
- additionalParams.append(namedParameter);
- }
- }
-
- private void populateDateAddon(StringBuilder additionalParams, Long choice, String addon, String namedParameter, Date date){
- if(choice != null && choice > 0L && date != null ){
- additionalParams.append(addon);
- additionalParams.append(getAstFromIndex(choice));
- additionalParams.append(namedParameter);
- }
- }
-
- public List<Image> getFindedImages() {
- return findedImages;
- }
-
-}
\ No newline at end of file
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -142,7 +142,7 @@
List<SelectItem> items = new ArrayList<SelectItem>();
for(TreeNode<Object> item: this.getAlbums()){
TreeAlbumItem a = (TreeAlbumItem)item;
- String pathFromParents = a.getAlbum().getAlbumPathFromParents(a.getAlbum(), new ArrayList<String>(), "/");
+ String pathFromParents = a.getAlbum().getAlbumPathFromParents(a.getAlbum(), Constants.SLASH, true);
SelectItem e = new SelectItem(pathFromParents);
items.add(e);
a.getArrayOfChildsAlbumsNames(items);
@@ -153,7 +153,7 @@
public void getArrayOfChildsAlbumsNames(List<SelectItem> list) {
for(TreeNode<Object> item: this.getAlbums()){
TreeAlbumItem a = (TreeAlbumItem)item;
- String pathFromParents = this.getAlbum().getAlbumPathFromParents(this.getAlbum(), new ArrayList<String>(), "/");
+ String pathFromParents = this.getAlbum().getAlbumPathFromParents(this.getAlbum(), Constants.SLASH, true);
SelectItem e = new SelectItem(pathFromParents);
list.add(e);
a.getArrayOfChildsAlbumsNames(list);
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ConversationState.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ConversationState.java 2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ConversationState.java 2009-01-26 19:28:18 UTC (rev 12431)
@@ -21,7 +21,6 @@
package org.richfaces.realworld.util;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -47,11 +46,11 @@
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.navigation.NavigationEnum;
+import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.tree.TreeAlbumItem;
import org.richfaces.realworld.tree.TreeFriendItem;
import org.richfaces.realworld.tree.TreeFriendsItem;
import org.richfaces.realworld.tree.TreeMyAlbumsItem;
-import org.richfaces.realworld.service.Constants;
@Name("conversationState")
@Scope(ScopeType.CONVERSATION)
@@ -115,7 +114,7 @@
if(null == selectedAlbum){
return "";
}
- return selectedAlbum.getAlbumPathFromParents(selectedAlbum, new ArrayList<String>(), Constants.SLASH);
+ return selectedAlbum.getAlbumPathFromParents(selectedAlbum, Constants.SLASH, true);
}
public void setSelectedAlbumName(String selectedAlbumName) {
Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/fileUpload/fileUploader.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/search/advancedSearch.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/search/searchResults.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/search.xhtml
===================================================================
(Binary files differ)
15 years, 11 months
JBoss Rich Faces SVN: r12430 - trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-01-26 12:03:40 -0500 (Mon, 26 Jan 2009)
New Revision: 12430
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java
Log:
small fix
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-26 16:25:30 UTC (rev 12429)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java 2009-01-26 17:03:40 UTC (rev 12430)
@@ -34,6 +34,7 @@
init(template);
chekStructure();
selenium.type(elements, "3");
+ waitForAjaxCompletion();
Assert.assertEquals(selenium.getXpathCount("id('"+ dataGrid + "')/tbody/tr"), 3);
chekStructure();
}
15 years, 11 months
JBoss Rich Faces SVN: r12429 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/WEB-INF and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-01-26 11:25:30 -0500 (Mon, 26 Jan 2009)
New Revision: 12429
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataGridBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/
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
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
Log:
RF-5674
Added: 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 (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/DataGridBean.java 2009-01-26 16:25:30 UTC (rev 12429)
@@ -0,0 +1,75 @@
+package org.ajax4jsf.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DataGridBean {
+
+ public class Element {
+
+ private String cell1;
+ private String cell2;
+ private String cell3;
+
+ public Element(String index) {
+ this.cell1 = index + "A";
+ this.cell2 = index + "B";
+ this.cell3 = index + "C";
+ }
+
+ public String getCell1() {
+ return cell1;
+ }
+
+ public void setCell1(String cell1) {
+ this.cell1 = cell1;
+ }
+
+ public String getCell2() {
+ return cell2;
+ }
+
+ public void setCell2(String cell2) {
+ this.cell2 = cell2;
+ }
+
+ public String getCell3() {
+ return cell3;
+ }
+
+ public void setCell3(String cell3) {
+ this.cell3 = cell3;
+ }
+ }
+
+ private List<Element> model;
+ private int elements;
+
+ public DataGridBean() {
+ model = new ArrayList<Element>(10);
+ for (int i = 0; i < 10; i++) {
+ model.add(new Element(Integer.toString(i)));
+ }
+ init();
+ }
+
+ public void init() {
+ elements = 0;
+ }
+
+ public void setModel(List<Element> model) {
+ this.model = model;
+ }
+
+ public List<Element> getModel() {
+ return model;
+ }
+
+ public void setElements(int elements) {
+ this.elements = elements;
+ }
+
+ public int getElements() {
+ return elements;
+ }
+}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-01-26 16:24:43 UTC (rev 12428)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2009-01-26 16:25:30 UTC (rev 12429)
@@ -169,6 +169,11 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
+ <managed-bean-name>dataGrid</managed-bean-name>
+ <managed-bean-class>org.ajax4jsf.bean.DataGridBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>sliderBean</managed-bean-name>
<managed-bean-class>org.ajax4jsf.bean.InputNumberSliderBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGrid.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGrid.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/dataGrid/dataGrid.xhtml 2009-01-26 16:25:30 UTC (rev 12429)
@@ -0,0 +1,44 @@
+<!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.template}">
+ <ui:define name="component">
+ <h:form id="attrForm">
+ <h:outputText value="elements" />
+ <h:inputText id="elements" value="#{dataGrid.elements}">
+ <a4j:support event="onchange" reRender="dataGrid"/>
+ </h:inputText>
+ <!--h:outputText value="includedNode" />
+ <h:selectBooleanCheckbox id="includedNode" value="#{treeNodesAdaptor.includedNode}">
+ <a4j:support event="onchange" reRender="tree"/>
+ </h:selectBooleanCheckbox>
+ <h:outputText value="includedRoot" />
+ <h:selectBooleanCheckbox id="includedRoot" value="#{treeNodesAdaptor.includedRoot}">
+ <a4j:support event="onchange" reRender="tree"/>
+ </h:selectBooleanCheckbox-->
+ </h:form>
+ <h:form id="mainForm">
+ <rich:dataGrid id="dataGrid" value="#{dataGrid.model}" var="row" elements="#{dataGrid.elements}">
+ <h:panelGroup>
+ <h:outputText value="#{row.cell1}"></h:outputText>
+ <h:inputText value="#{row.cell2}"></h:inputText>
+ <h:outputText value="#{row.cell3}"></h:outputText>
+ </h:panelGroup>
+ </rich:dataGrid>
+ </h:form>
+ <a4j:outputPanel ajaxRendered="true">
+ <h:outputText id="outputText" value="#{treeNodesAdaptor.trace}"></h:outputText>
+ <h:dataTable id="dataTable" value="#{dataGrid.model}" var="row" rows="#{dataGrid.elements}">
+ <h:column>
+ <h:outputText value="#{row.cell2}"></h:outputText>
+ </h:column>
+ </h:dataTable>
+ </a4j:outputPanel>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/DataGridTest.java 2009-01-26 16:25:30 UTC (rev 12429)
@@ -0,0 +1,54 @@
+package org.richfaces.testng;
+
+import org.ajax4jsf.template.Template;
+import org.richfaces.SeleniumTestBase;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class DataGridTest extends SeleniumTestBase {
+
+ private String elements;
+
+ private String dataGrid;
+
+ private String outputText;
+
+ private String dataTable;
+
+ private void init(Template template) {
+ renderPage(null, template, "#{dataGrid.init}");
+ String attrForm = getParentId() + "attrForm";
+ elements = attrForm + ":elements";
+ String mainForm = getParentId() + "mainForm";
+ dataGrid = mainForm + ":dataGrid";
+ outputText = getParentId() + "outputText";
+ dataTable = getParentId() + "dataTable";
+ }
+
+ /**
+ * items from collection defined as value attribute are output to the client;
+ * number of items is limited using rows attribute and not
+ */
+ @Test
+ public void testStructure(Template template) {
+ init(template);
+ chekStructure();
+ selenium.type(elements, "3");
+ Assert.assertEquals(selenium.getXpathCount("id('"+ dataGrid + "')/tbody/tr"), 3);
+ chekStructure();
+ }
+
+ private void chekStructure() {
+ String dataTableRowLocator = "id('"+ dataTable + "')/tbody/tr";
+ int count = selenium.getXpathCount(dataTableRowLocator).intValue();
+ for (int i = 1; i <= count; i++) {
+ Assert.assertEquals(selenium.getValue("xpath=id('"+ dataGrid + "')/tbody/tr[" + i + "]/td/input"),
+ selenium.getText("xpath=" + dataTableRowLocator + "[" + i + "]"));
+ }
+ }
+
+ @Override
+ public String getTestUrl() {
+ return "pages/dataGrid/dataGrid.xhtml";
+ }
+}
15 years, 11 months