You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@labs.apache.org by si...@apache.org on 2008/09/16 16:36:12 UTC

svn commit: r695912 - in /labs/magma/trunk/website-beansview: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/magma/ src/main/java/org/apache/magma/website/ src/main/java/org/apache/magma/website/b...

Author: simoneg
Date: Tue Sep 16 07:36:10 2008
New Revision: 695912

URL: http://svn.apache.org/viewvc?rev=695912&view=rev
Log:
Initial import.

Added:
    labs/magma/trunk/website-beansview/pom.xml
    labs/magma/trunk/website-beansview/src/
    labs/magma/trunk/website-beansview/src/main/
    labs/magma/trunk/website-beansview/src/main/java/
    labs/magma/trunk/website-beansview/src/main/java/org/
    labs/magma/trunk/website-beansview/src/main/java/org/apache/
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Cell.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Row.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Table.java
    labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/TableFactory.java
    labs/magma/trunk/website-beansview/src/test/
    labs/magma/trunk/website-beansview/src/test/java/
    labs/magma/trunk/website-beansview/src/test/java/org/
    labs/magma/trunk/website-beansview/src/test/java/org/apache/
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/BeanFormProducerTest.java
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowBeanTest.java
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowListTest.java
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/SmartFormBindingTest.java
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person.java
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person2.java
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person3.java
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person4.java
    labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person5.java

Added: labs/magma/trunk/website-beansview/pom.xml
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/pom.xml?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/pom.xml (added)
+++ labs/magma/trunk/website-beansview/pom.xml Tue Sep 16 07:36:10 2008
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<artifactId>magma-parent</artifactId>
+		<groupId>org.apache.magma</groupId>
+		<version>1</version>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>org.apache.magma</groupId>
+	<artifactId>website-beansview</artifactId>
+	<name>Website Beans View</name>
+	<version>0.0.1-SNAPSHOT</version>
+	<description>Adds beans view system to the web</description>
+	<packaging>magma</packaging>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.magma.tools</groupId>
+				<artifactId>maven-magma-plugin</artifactId>
+				<extensions>true</extensions>
+			</plugin>
+		</plugins>
+	</build>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.magma</groupId>
+			<artifactId>foundation-beans-view</artifactId>
+			<version>0.0.1-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.magma</groupId>
+			<artifactId>foundation-website</artifactId>
+			<version>0.0.1-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.4</version>
+			<scope>test</scope>
+		</dependency>		
+	</dependencies>
+</project>

Added: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java (added)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/BeanFormProducer.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,282 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview;
+
+import org.apache.magma.basics.LocalizableString;
+import org.apache.magma.basics.LocalizableStringWithSubject;
+import org.apache.magma.basics.MagmaException;
+import org.apache.magma.beans.MagmaBeanSupport;
+import org.apache.magma.beans.PropertyInfo;
+import org.apache.magma.conversion.BooleanConverter;
+import org.apache.magma.database.Database;
+import org.apache.magma.validation.CompoundValidator;
+import org.apache.magma.view.tree.FieldNode;
+import org.apache.magma.view.tree.LabelNode;
+import org.apache.magma.view.tree.Node;
+import org.apache.magma.view.tree.ViewCustomizer;
+import org.apache.magma.view.tree.ViewUtils;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.magma.conversion.Converter;
+
+public class BeanFormProducer extends ShowBean {
+
+	private static int MAX_FIELD_SIZE = 0;
+	private Map<String, String> binding;
+	private List<LocalizableStringWithSubject> errors;
+	private String code;
+	private Map<String, List<?>> lists = new HashMap<String, List<?>>();
+
+	public BeanFormProducer(Object bean, Map<String, String> binding, List<LocalizableStringWithSubject> errors, ViewCustomizer filter, String code) {
+		super(bean, filter);
+		this.binding = binding;
+		this.errors = errors;
+		this.code = code;
+	}
+	
+	
+	
+	@Override
+	public void produce(OutputStream stream) {
+		OutputStreamWriter out = new OutputStreamWriter(stream);
+		try {
+			out.write("<form action=\"filled\" method=\"POST\">");
+			out.flush();
+			super.produce(stream);
+			out.write("<input type=\"submit\" name=\"submit\"/>");
+			out.write("</form>");
+			out.flush();
+		} catch (IOException e) {
+			throw new MagmaException(e, "Error writing to output");
+		}
+	}
+	
+	@Override
+	protected void createLabelNodeOutput(LabelNode node, Writer out) throws IOException {
+		out.append("<label for=\"" + node.getCorrespondingFieldId() + "\">");
+		super.createLabelNodeOutput(node, out);
+		PropertyInfo property = node.getProperty();
+		List<LocalizableString> errs = findErrors(property);
+		if (errs.size() > 0) {
+			createErrorsOutput(node, out, errs);
+		}
+		
+		CompoundValidator allvals = property.getValidator();
+		if (allvals == null) return;
+		if (!allvals.acceptsNulls()) {
+			out.append(" *");
+		}
+		out.append("</label>");
+	}
+
+	private void createErrorsOutput(LabelNode node, Writer out, List<LocalizableString> errs) throws IOException {
+		out.append("<a href=\"#\" title=\"");
+		for (LocalizableString err : errs) {
+			out.append(err.toString());
+			out.append("\n");
+		}
+		out.append("\">!</a>");
+	}
+	
+	protected List<LocalizableString> findErrors(PropertyInfo property) {
+		List<LocalizableString> errs = new ArrayList<LocalizableString>();
+		for (LocalizableStringWithSubject acerr : this.errors) {
+			if (acerr.getSubject().equals(property)) errs.add(acerr);
+		}
+		return errs;
+	}
+
+	@Override
+	protected void createMain(Node node, Writer out) throws IOException {
+		if (node instanceof FieldNode) {
+			createField((FieldNode) node, out);
+		} else {
+			super.createMain(node, out);
+		}
+	}
+
+	protected void createField(FieldNode node, Writer out) throws IOException {
+		PropertyInfo property = node.getProperty();
+		if (property.getType().isEnum() || MagmaBeanSupport.class.isAssignableFrom(property.getType())) {
+			createSelectionListField(node, out);
+		} else if (property.getType().equals(Boolean.class) || property.getType().equals(Boolean.TYPE)) {
+			createBooleanField(node, out);
+		} else {
+			createTextField(node, out);
+		}
+	}
+
+	protected void createBooleanField(FieldNode node, Writer out) throws IOException {
+		out.append("<input type=\"checkbox\"");
+		createNameAndId(node, out);
+		out.append(" value=\"true\"");
+		String val = binding.get(node.getId());
+		if (((BooleanConverter)node.getProperty().getConverter()).fromString(val)) {
+			out.append(" checked=\"checked\"");
+		}
+		out.append("/>");
+	}
+
+	protected void createSelectionListField(FieldNode node, Writer out) throws IOException {
+		PropertyInfo property = node.getProperty();
+		List<?> elements = this.lists .get(node.getId());
+		if (elements == null) {
+			elements = this.lists.get(property.getType().getName());
+		}
+		if (elements == null) {
+			if (property.getType().isEnum()) {
+				elements = new ArrayList<Object>(Arrays.asList(property.getType().getEnumConstants()));
+			} else {
+				elements = new Database().query(property.getType(), "");
+			}
+		}
+		if (elements != null && elements.size() > 0) {
+			if (elements.size() < 5) {
+				createRadioField(node, elements, out);
+			} else if (elements.size() < 50) {
+				createDropDownField(node, elements, out);				
+			} else {
+				// TODO
+				out.write("TODO .. too many to use drop down");
+			}
+		}
+	}
+	
+	
+	private void createRadioField(FieldNode node, List<?> elements, Writer out) throws IOException {
+		PropertyInfo property = node.getProperty();		
+		Converter conv = (Converter)property.getConverter();
+		for (Object object : elements) {
+			String val = conv.toString(object);
+			out.append("<input type=\"radio\"");
+			createNameAndId(node, out);
+			out.append(" value=\"");
+			out.append(val);
+			out.append("\"");
+			String acval = binding.get(node.getId());
+			if (acval != null && acval.equals(val)) {
+				out.append(" checked=\"checked\"");
+			}
+			out.append("/>");			
+			out.append(ViewUtils.getStringValue(object));
+		}
+	}
+
+	protected void createDropDownField(FieldNode node, List<?> elements, Writer out) throws IOException {
+		out.append("<select");
+		createNameAndId(node, out);
+		out.append('>');
+		PropertyInfo property = node.getProperty();		
+		Converter conv = (Converter)property.getConverter();
+		for (Object object : elements) {
+			String val = conv.toString(object);
+			out.append("<option value=\"");
+			out.append(val);
+			out.append("\"");
+			String acval = binding.get(node.getId());
+			if (acval != null && acval.equals(val)) {
+				out.append(" selected=\"selected\"");
+			}
+			out.append(">");			
+			out.append(ViewUtils.getStringValue(object));
+			out.append("</option>");			
+		}
+		out.append("</select>");		
+	}
+
+	protected void createTextField(FieldNode node, Writer out) throws IOException {
+		PropertyInfo property = node.getProperty();
+		int maxSize = findInputMaxSize(property);
+		if (maxSize < 256) {
+			createSimpleTextField(node, out);
+		} else {
+			createTextAreaField(node, out);			
+		}
+	}
+
+	protected void createTextAreaField(FieldNode node, Writer out) throws IOException {
+		PropertyInfo property = node.getProperty();
+		int maxSize = findInputMaxSize(property);
+		int size = Math.min(MAX_FIELD_SIZE, maxSize);
+		if (size == 0) size = 80;
+		int rows = maxSize / size;
+		if (rows > 15) rows = 15;
+		out.append("<textarea rows=\"");
+		out.append(Integer.toString(rows));
+		out.append("\" cols=\"");
+		out.append(Integer.toString(size));
+		out.append('\"');
+		createNameAndId(node, out);		
+		out.append('>');
+		String val = binding.get(node.getId());
+		out.append(val == null ? "" : val);
+		out.append("</textarea>");		
+	}
+
+	protected void createSimpleTextField(FieldNode node, Writer out) throws IOException {
+		PropertyInfo property = node.getProperty();
+		
+		int maxSize = findInputMaxSize(property);
+		int size = Math.min(MAX_FIELD_SIZE, maxSize);
+		out.append("<input type=\"text\"");
+		createNameAndId(node, out);
+		if (size > 0) {
+			out.append(" size=\"");
+			out.append(Integer.toString(size));
+			out.append('\"');
+		}
+		if (maxSize > 0) {
+			out.append(" maxLength=\"");
+			out.append(Integer.toString(maxSize));			
+			out.append('\"');
+		}
+		out.append(" value=\"");
+		String val = binding.get(node.getId());
+		out.append(val == null ? "" : val);
+		out.append("\"/>");		
+	}
+
+	protected int findInputMaxSize(PropertyInfo property) {
+		CompoundValidator<Object> allvals = property.getValidator();
+		if (allvals == null) return 0;
+		return allvals.maxCharacterLength();
+	}
+
+	public void setLists(Map<String, List<?>> lists) {
+		this.lists = lists;
+	}
+	
+	protected void createNameAndId(Node node, Writer out) throws IOException {
+		out.append(" name=\"");
+		out.append(code);
+		out.append(".");
+		out.append(node.getId());
+		out.append("\" id=\"");
+		out.append(node.getId());
+		out.append('\"');		
+	}
+	
+}

Added: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java (added)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowBean.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.magma.basics.MagmaException;
+import org.apache.magma.beans.MagmaBeanSupport;
+import org.apache.magma.beans.PropertyInfo;
+import org.apache.magma.view.Side;
+import org.apache.magma.view.tree.ContainerProperty;
+import org.apache.magma.view.tree.FieldNode;
+import org.apache.magma.view.tree.LabelNode;
+import org.apache.magma.view.tree.Node;
+import org.apache.magma.view.tree.ViewCustomizer;
+import org.apache.magma.view.tree.ViewUtils;
+import org.apache.magma.view.tree.Zone;
+import org.apache.magma.website.HtmlProducer;
+
+public class ShowBean extends HtmlProducer {
+
+	protected MagmaBeanSupport bean;
+	protected ViewCustomizer filter;
+
+	public ShowBean(Object bean) {
+		this.bean = (MagmaBeanSupport)bean;
+	}
+	public ShowBean(Object bean, ViewCustomizer filter) {
+		this(bean);
+		this.filter = filter;
+	}
+	
+	@Override
+	public void head(OutputStream stream) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void produce(OutputStream stream) {
+		Node root = bean.beanData().getViewTree(this.filter);
+		if (root.getAllNodes().size() == 1) throw new MagmaException("Cannot display {0}, seems like no @View elements are present or they are not correctly connected to each other correctly using @Order, @Zone etc..", bean.getClass());		
+		OutputStreamWriter tables = new OutputStreamWriter(stream);
+		try {
+			createTable(root, tables);
+			tables.flush();
+		} catch (UnsupportedEncodingException e) {
+			// Should never happen
+			throw new MagmaException(e, "Something is extremely wrong if we cannot find UTF-8");
+		} catch (IOException e) {
+			throw new MagmaException(e, "Error writing to output");
+		}
+	}
+
+	protected void createTable(Node node, Writer out) throws IOException {
+		// Skip container only nodes
+		if (node.hasSingleZone()) { 
+			createContainerNodeTable(node, out);
+			return;
+		}
+		if (!node.hasInsideZones() && !node.hasOutsideZones()) {
+			// Avoid creating an entire table structure if we don't have any zone to layout but only a main
+			createMain(node, out);			
+		}
+		if (node.hasOutsideZones()) {
+			createOutsideZonedNodeTable(node, out);
+		} else if (node.hasInsideZones()) {
+			createInsideZonedNodeTable(node, out);
+		}
+	}
+
+	protected void createOutsideZonedNodeTable(Node node, Writer out) throws IOException {
+		// Create a full table
+		out.append("<table>");
+		out.append("<tr>");
+		// Create the table for the outside left
+		Zone zone = node.getZone(Side.OutsideLeft);
+		if (zone != null && zone.getSlices() > 0) {
+			out.append("<td>");
+			createZoneTable(zone, true, out);
+			out.append("</td>");
+		}
+		out.append("<td>");
+		if (!node.hasInsideZones()) {
+			createMain(node, out);
+		} else {
+			createInsideZonedNodeTable(node, out);
+		}
+		out.append("</td>");
+		// Create the outside right table
+		zone = node.getZone(Side.OutsideRight);
+		if (zone != null && zone.getSlices() > 0) {
+			out.append("<td>");
+			createZoneTable(zone, true, out);
+			out.append("</td>");
+		}		
+		out.append("</tr>");
+		out.append("</table>");
+	}
+
+	protected void createInsideZonedNodeTable(Node node, Writer out) throws IOException {
+		// Create a full table
+		out.append("<table>");
+		out.append("<tr>");
+		Zone zone = node.getZone(Side.InsideLeft);
+		if (zone != null && zone.getSlices() > 0) {
+			out.append("<td rowspan=\"3\">");
+			createZoneTable(zone, true, out);
+			out.append("</td>");
+		}
+		boolean maindone = false;
+		Zone bottomzone = node.getZone(Side.Bottom);
+		boolean hasbottom = bottomzone != null && bottomzone.getSlices() > 0;
+		zone = node.getZone(Side.Top);
+		if (zone != null && zone.getSlices() > 0) {
+			out.append("<td>");
+			createZoneTable(zone, false, out);
+			out.append("</td>");
+		} else {
+			if (hasbottom) {
+				out.append("<td rowspan=\"2\">");				
+			} else {
+				out.append("<td rowspan=\"3\">");
+			}
+			createMain(node, out);
+			out.append("</td>");
+			maindone = true;
+		}
+		zone = node.getZone(Side.InsideRight);
+		if (zone != null && zone.getSlices() > 0) {
+			out.append("<td rowspan=\"3\">");
+			createZoneTable(zone, true, out);
+			out.append("</td>");
+		}
+		out.append("</tr>");
+		out.append("<tr>");
+		if (!maindone) {
+			if (hasbottom) {
+				out.append("<td>");				
+			} else {
+				out.append("<td rowspan=\"2\">");
+			}
+			createMain(node, out);
+			out.append("</td>");
+			maindone = true;			
+		}
+		out.append("</tr>");
+		out.append("<tr>");
+		if (hasbottom) {
+			out.append("<td>");
+			createZoneTable(bottomzone, false, out);
+			out.append("</td>");			
+		}
+		out.append("</tr>");
+		out.append("</table>");
+	}
+
+	protected void createContainerNodeTable(Node node, Writer out) throws IOException {
+		Zone zone = node.getUniqueZone();
+		boolean vertical = zone.getSide().equals(Side.OutsideLeft) ||
+				zone.getSide().equals(Side.OutsideRight) ||
+				zone.getSide().equals(Side.InsideLeft) ||
+				zone.getSide().equals(Side.InsideRight);
+		createZoneTable(zone, vertical, out);
+	}
+
+	protected void createZoneTable(Zone zone, boolean vertical, Writer out) throws IOException {
+		String sliceseparator = vertical ? "</td><td>" : "</td></tr><tr><td>";
+		String nodeseparator = vertical ? "</td></tr><tr><td>" : "</td><td>";
+		if (zone.getSlices() > 1) {
+			out.append("<table>");
+			out.append("<tr><td>");
+		}
+		for (int slice = 0; slice < zone.getSlices(); slice++) {
+			List<Node> sliceNodes = zone.getSliceNodes(slice);
+			if (sliceNodes.size() > 1) {
+				out.append("<table>");
+				out.append("<tr><td>");				
+			}
+			for (Iterator iterator = sliceNodes.iterator(); iterator.hasNext();) {
+				Node acnode = (Node) iterator.next();
+				createTable(acnode, out);
+				if (iterator.hasNext()) {
+					out.append(nodeseparator);
+				}
+			}
+			if (sliceNodes.size() > 1) {
+				out.append("</tr></td>");				
+				out.append("</table>");
+			}
+			if (slice + 1 < zone.getSlices()) {
+				out.append(sliceseparator);
+			}
+		}
+		if (zone.getSlices() > 1) {
+			out.append("</tr></td>");
+			out.append("</table>");
+		}
+	}
+
+	protected void createMain(Node node, Writer out) throws IOException {
+		if (node instanceof LabelNode) {
+			createLabelNodeOutput((LabelNode) node, out);
+		} else if (node instanceof FieldNode) {
+			createFieldNodeOutput((FieldNode) node, out);
+		} else if (node instanceof ContainerProperty) {
+			createContainerPropertyNodeOutput((ContainerProperty) node, out);
+		} else {
+			createGenericNodeOutput(node, out);
+		}		
+	}
+
+	private void createContainerPropertyNodeOutput(ContainerProperty node, Writer out) throws IOException {
+		
+	}
+	
+	protected void createFieldNodeOutput(FieldNode node, Writer out) throws IOException {
+		String valueString = ViewUtils.getStringNodeValue(node, this.bean); 
+		out.append(valueString);
+	}
+	
+
+	protected void createLabelNodeOutput(LabelNode node, Writer out) throws IOException {
+		out.append(node.getProperty().getViewSettings().getLabel());
+	}
+
+	protected void createGenericNodeOutput(Node node, Writer out) throws IOException {
+		//out.append("Node " + node.getId());
+	}
+
+}

Added: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java (added)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/ShowList.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview;
+
+import org.apache.magma.basics.MagmaException;
+import org.apache.magma.beans.BeanData;
+import org.apache.magma.beans.MagmaBeanSupport;
+import org.apache.magma.conversion.Converter;
+import org.apache.magma.conversion.Converters;
+import org.apache.magma.view.tree.FieldNode;
+import org.apache.magma.view.tree.Node;
+import org.apache.magma.view.tree.ViewCustomizer;
+import org.apache.magma.view.tree.ViewUtils;
+import org.apache.magma.website.HtmlProducer;
+import org.apache.magma.website.WebHandler;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+public class ShowList extends HtmlProducer {
+
+	protected Collection<?> list;
+	protected ViewCustomizer filter = null;
+	protected String link = null;
+	protected String linkUrl = null;
+	protected Class<?> myclass;
+	protected Converter converter;
+	
+	public <T> ShowList(Class<T> myclass, Collection<? extends T> list, ViewCustomizer filter, String link) {
+		this.list = list;
+		this.filter = filter;
+		this.link = link;
+		this.myclass = myclass;
+	}
+
+	public <T> ShowList(Class<T> myclass,Collection<? extends T> list, String link) {
+		this.list = list;
+		this.link = link;
+		this.myclass = myclass;
+	}
+
+	public <T> ShowList(Class<T> myclass,Collection<? extends T> list) {
+		this.list = list;
+		this.myclass = myclass;
+	}
+
+	public <T> ShowList(Class<T> myclass,Collection<? extends T> list, ViewCustomizer filter) {
+		this.list = list;
+		this.filter = filter;
+		this.myclass = myclass;
+	}
+	
+	@Override
+	public void head(OutputStream stream) {
+		// TODO Auto-generated method stub
+	}
+
+	@Override
+	public void produce(OutputStream stream) {
+		if (this.link != null) {
+			try {
+				Method method = getCreatingHandler().getClass().getMethod(this.link, this.myclass);
+			} catch (NoSuchMethodException e) {
+				throw new MagmaException(e,"Cannot find method {0}.{1}({2}) to make the link", getCreatingHandler(), this.link, this.myclass);
+			}
+			this.converter = Converters.getConverterFor(this.myclass);
+			if (this.converter == null) throw new MagmaException("Cannot find converter for {0}, cannot make link!", this.myclass);
+			this.linkUrl = this.link;
+			if (linkUrl.startsWith("do")) {
+				this.linkUrl = this.linkUrl.substring(2);
+			} else if (linkUrl.startsWith("handle")){
+				this.linkUrl = this.linkUrl.substring(6);				
+			} else {
+				throw new MagmaException("The link {0} is not valid : it should refer a doMethod or handleMethod", this.link);
+			}
+		}
+				
+		Node root = BeanData.getFor(myclass).getViewListTree(this.filter);
+		if (root.getAllNodes().size() == 1) throw new MagmaException("Cannot create list for {0}, seems like no @Listed elements are present or they are not correctly connected to each other to form a proper list", myclass);
+		OutputStreamWriter tables = new OutputStreamWriter(stream);
+		try {
+			openOuterTable(root, tables);
+			createHeader(root, tables);
+			createBody(root, tables);
+			closeOuterTable(root, tables);
+			tables.flush();
+		} catch (UnsupportedEncodingException e) {
+			// Should never happen
+			throw new MagmaException(e, "Something is extremely wrong if we cannot find UTF-8");
+		} catch (IOException e) {
+			throw new MagmaException(e, "Error writing to output");
+		}
+	}
+
+	protected void createBody(Node root, Writer tables) throws IOException {
+		tables.write("<tbody>");
+		for (Object o : this.list) {
+			if (!(o instanceof MagmaBeanSupport)) continue;
+			MagmaBeanSupport mb = (MagmaBeanSupport) o;
+			openRow(mb, tables);
+			List<Node> nodes = root.getUniqueZone().getNodes();
+			for (Node node : nodes) {
+				if (node instanceof FieldNode) {
+					FieldNode fldn = (FieldNode) node;
+					createFieldNodeCell(fldn,mb, tables);
+				}
+			}			
+			closeRow(o, tables);
+		}
+		tables.write("</tbody>");
+	}
+
+	protected void createFieldNodeCell(FieldNode fldn, MagmaBeanSupport bean, Writer tables) throws IOException {
+		tables.write("<td>");
+		if (this.linkUrl != null) {
+			tables.write("<a href=\"");
+			tables.write(createUrlFor(fldn, bean));
+			tables.write("\">");
+		}
+		tables.write(ViewUtils.getStringNodeValue(fldn, bean));
+		if (this.linkUrl != null) {
+			tables.write("</a>");
+		}
+		tables.write("</td>");		
+	}
+
+	protected String createUrlFor(FieldNode fldn, MagmaBeanSupport bean) {
+		return this.linkUrl + "-" + this.converter.toString(bean);
+	}
+
+	protected void openRow(Object o, Writer tables) throws IOException {
+		tables.write("<tr>");
+	}
+	protected void closeRow(Object o, Writer tables) throws IOException {
+		tables.write("</tr>");
+	}
+
+	protected void createHeader(Node root, Writer tables) throws IOException {
+		tables.write("<thead>");
+		tables.write("<tr>");
+		List<Node> nodes = root.getUniqueZone().getNodes();
+		for (Node node : nodes) {
+			if (node instanceof FieldNode) {
+				FieldNode fldn = (FieldNode) node;
+				createFieldNodeHeader(fldn, tables);
+			}
+		}
+		tables.write("</tr>");		
+		tables.write("</thead>");
+	}
+
+	protected void createFieldNodeHeader(FieldNode fldn, Writer tables) throws IOException {
+		tables.write("<th>");
+		tables.write(fldn.getProperty().getViewListSettings().getLabel());
+		tables.write("</th>");		
+	}
+
+	protected void closeOuterTable(Node root, Writer tables) throws IOException {
+		tables.write("</table>");
+	}
+
+	protected void openOuterTable(Node root, Writer tables) throws IOException {
+		tables.write("<table>");
+	}
+
+	
+	
+}

Added: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java (added)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/SmartForm.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview;
+
+import org.apache.magma.basics.LocalizableString;
+import org.apache.magma.basics.LocalizableStringWithSubject;
+import org.apache.magma.basics.MagmaException;
+import org.apache.magma.beans.BeanHandler;
+import org.apache.magma.beans.MagmaBeanSupport;
+import org.apache.magma.conversion.ConversionException;
+import org.apache.magma.validation.ValidationError;
+import org.apache.magma.view.tree.FieldNode;
+import org.apache.magma.view.tree.Node;
+import org.apache.magma.view.tree.ViewCustomizer;
+import org.apache.magma.view.tree.ViewUtils;
+import org.apache.magma.website.HtmlProducer;
+import org.apache.magma.website.WebHandler;
+import org.apache.magma.website.producers.CompoundHtmlProducer;
+import org.apache.magma.website.producers.ParametrizableProducer;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class SmartForm extends WebHandler {
+
+	private MagmaBeanSupport bean = null;
+	private String next = null;
+	
+	private HtmlProducer header = null;
+	private HtmlProducer footer = null;
+	
+	private ViewCustomizer filter = null;
+	
+	Map<String, List<?>> lists = new HashMap<String, List<?>>();
+	Map<String, String> binding = new HashMap<String, String>();
+	List<LocalizableStringWithSubject> errors = new ArrayList<LocalizableStringWithSubject>();
+	
+	public SmartForm(Object bean, String next) {
+		this.bean = (MagmaBeanSupport) bean;
+		this.next = next;
+	}
+
+	public SmartForm(Object bean, String next, HtmlProducer header) {
+		this(bean, next);
+		this.header = header;
+	}
+	
+	public SmartForm(Object bean, String next, HtmlProducer header, HtmlProducer footer) {
+		this(bean, next, header);
+		this.footer = footer;
+	}
+
+	public SmartForm(Object bean, String next, HtmlProducer header, HtmlProducer footer, ViewCustomizer filter) {
+		this(bean, next, header, footer);
+		this.filter = filter;
+	}
+	
+	public void setAllParams(Map<String, String[]> params) {
+		String mycode = getMyCode();
+		int mycodeLen = mycode.length();
+		binding.clear();
+		for (Map.Entry<String, String[]> entry : params.entrySet()) {
+			if (entry.getKey().startsWith(mycode) && entry.getValue()[0].length() > 0) {
+				// TODO here we can bind multiple parameters (lists etc)
+				binding.put(entry.getKey().substring(mycodeLen + 1), entry.getValue()[0]);
+			}
+		}
+	}
+	
+	String getMyCode() {
+		return Integer.toString(getRelativePath().hashCode());
+	}
+
+	public HtmlProducer do_default() {
+		return doShow();
+	}
+	
+	public HtmlProducer doShow() {
+		if (binding.size() == 0) {
+			prepareBinding();
+		}
+		parametrize(header);
+		parametrize(footer);
+		BeanFormProducer producer = new BeanFormProducer(this.bean, binding, errors, this.filter, getMyCode());
+		producer.setLists(this.lists);
+		return new CompoundHtmlProducer(header, producer, footer);
+	}
+	
+	public HtmlProducer doFilled() {
+		executeBinding();
+		if (errors.size() == 0) {
+			return goToNext();
+		}
+		return unrepeatable(doShow());
+	}
+
+	protected void parametrize(HtmlProducer prod) {
+		if (prod instanceof ParametrizableProducer) {
+			((ParametrizableProducer)prod).addParameter("errors", errors);
+		}
+	}
+
+	protected HtmlProducer goToNext() {
+		WebHandler parent = getCreatingHandler();
+		Class<? extends WebHandler> parentClass = parent.getClass();
+		try {
+			Method method = parentClass.getMethod(this.next, this.bean.getClass());
+			return (HtmlProducer) method.invoke(parent, this.bean);
+		} catch (Exception e) {
+			throw new MagmaException(e, "Error invoking {0}.{1}({2}) after proper firm completition.", parentClass.getSimpleName(), this.next, this.bean.getClass().getSimpleName());
+		}
+	}
+
+	void executeBinding() {
+		Map<MagmaBeanSupport,BeanHandler> handlers = new HashMap<MagmaBeanSupport, BeanHandler>();
+		Node root = bean.beanData().getViewTree(this.filter);
+		Set<Node> allNodes = root.getAllNodes();
+		for (Node node : allNodes) {
+			if (node instanceof FieldNode) {
+				MagmaBeanSupport properBean = ViewUtils.findProperBean((FieldNode) node, bean, true);
+				BeanHandler h = handlers.get(properBean);
+				if (h == null) {
+					h = properBean.handler();
+					handlers.put(properBean, h);
+				}
+				h.setStringValue(((FieldNode)node).getProperty().getName(), binding.get(node.getId()));
+			}
+		}
+		
+		errors.clear();
+		for (BeanHandler handler : handlers.values()) {
+			try {
+				handler.commit();
+			} catch (ValidationError ve) {
+				List<LocalizableString> messages = ve.getMessages();
+				fillErrors(messages);
+			} catch (ConversionException ce) {
+				List<LocalizableString> messages = ce.getMessages();
+				fillErrors(messages);				
+			}
+		}
+	}
+
+	private void fillErrors(List<LocalizableString> messages) {
+		for (LocalizableString msg : messages) {
+			if (msg instanceof LocalizableStringWithSubject) {
+				errors.add((LocalizableStringWithSubject) msg);
+			} else {
+				errors.add(new LocalizableStringWithSubject(null, msg));
+			}
+		}
+	}
+
+	void prepareBinding() {
+		Node root = bean.beanData().getViewTree(this.filter);
+		Set<Node> allNodes = root.getAllNodes();
+		for (Node node : allNodes) {
+			if (node instanceof FieldNode) {
+				String value = ViewUtils.getStringNodeValue((FieldNode)node, bean);
+				binding.put(node.getId(), value);
+			}
+		}
+	}
+	
+	public SmartForm setHeader(HtmlProducer header) {
+		this.header = header;
+		return this;
+	}
+	
+	public SmartForm setFooter(HtmlProducer footer) {
+		this.footer = footer;
+		return this;
+	}
+	
+	public SmartForm setFilter(ViewCustomizer filter) {
+		this.filter = filter;
+		return this;
+	}
+	
+	public <T> SmartForm addList(Class<T> clazz, List<T> list) {
+		this.lists.put(clazz.getName(), list);
+		return this;
+	}
+
+	public <T> SmartForm addList(String field, List<T> list) {
+		this.lists.put(field, list);
+		return this;
+	}
+	
+}

Added: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Cell.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Cell.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Cell.java (added)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Cell.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview.html;
+
+public class Cell {
+
+	public Row row = null;
+	
+	public Table contains = null;
+	
+}

Added: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Row.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Row.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Row.java (added)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Row.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview.html;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Row {
+	
+	public Table table = null;
+	public List<Cell> cells = new ArrayList<Cell>();
+	
+	public Row(Table table) {
+		this.table = table;
+		table.rows.add(this);
+	}
+
+}

Added: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Table.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Table.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Table.java (added)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/Table.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview.html;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.magma.view.tree.Node;
+import org.apache.magma.view.tree.Zone;
+
+public class Table {
+
+	public enum For { INSIDE, OUTSIDE, SLICES, STRAIGHT };
+	
+	public Node parentNode = null;
+	public Zone parentZone = null;
+	
+	public List<Row> rows = new ArrayList<Row>();
+	
+}

Added: labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/TableFactory.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/TableFactory.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/TableFactory.java (added)
+++ labs/magma/trunk/website-beansview/src/main/java/org/apache/magma/website/beansview/html/TableFactory.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview.html;
+
+import org.apache.magma.view.tree.Node;
+
+public class TableFactory {
+
+	public Table createFor(Node node) {
+		Table t = new Table();
+		t.parentNode = node;
+		return t;
+	}
+	
+}

Added: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/BeanFormProducerTest.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/BeanFormProducerTest.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/BeanFormProducerTest.java (added)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/BeanFormProducerTest.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.StringContains.containsString;
+import org.apache.magma.basics.LocalizableStringWithSubject;
+import org.apache.magma.view.tree.LabelNode;
+import org.apache.magma.view.tree.Node;
+import org.apache.magma.view.tree.SimpleViewFilter;
+import org.apache.magma.view.tree.ViewCustomizer;
+import org.apache.magma.website.beansview.stuff.Person;
+import org.apache.magma.website.beansview.stuff.Person2;
+import org.apache.magma.website.beansview.stuff.Person4;
+import org.apache.magma.website.beansview.stuff.Person5;
+
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.Test;
+
+
+public class BeanFormProducerTest {
+	@Test
+	public void simpleTreeFields() throws Exception {
+		Person p = new Person();
+		p.setName("Simone");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		
+		HashMap<String, String> binding = new HashMap<String, String>();
+		binding.put("name", "Simone");
+		binding.put("surname", "Gianni");
+		binding.put("email", "simoneg@apache.org");
+		
+		BeanFormProducer sbp = new BeanFormProducer(p, binding, new ArrayList<LocalizableStringWithSubject>(), null, "ABC");
+		sbp.setCompletePath("testing");
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		System.out.println(result);
+		
+		Node node = p.beanData().getViewTree();
+		Set<Node> allNodes = node.getAllNodes();
+		for (Node acnode : allNodes) {
+			if (acnode instanceof LabelNode) {
+				assertThat(result, containsString(((LabelNode)acnode).getProperty().getViewSettings().getLabel()));
+			}
+		}
+		
+		checkValueBinding(binding, result);
+	}
+
+	
+	@Test
+	public void filtered() throws Exception {
+		Person4 p = new Person4();
+		p.setName("Simone");
+		p.setMiddle("P");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		Person4 pp = new Person4();
+		pp.setName("Mara");
+		pp.setMiddle("?");
+		pp.setSurname("Scialanga");
+		pp.setEmail("boh@bih.it");
+		
+		p.setMother(pp);
+
+		ViewCustomizer flt = new SimpleViewFilter("withmother", "+mother");
+		
+		HashMap<String, String> binding = new HashMap<String, String>();
+		binding.put("name", "Simone");
+		binding.put("middle", "Simone");
+		binding.put("surname", "Gianni");
+		binding.put("email", "simoneg@apache.org");
+		binding.put("mother-name", "Mara");
+		binding.put("mother-middle", "?");
+		binding.put("mother-surname", "Scialanga");
+		binding.put("mother-email", "boh@bih.it");
+		
+		BeanFormProducer sbp = new BeanFormProducer(p, binding, new ArrayList<LocalizableStringWithSubject>(), flt, "ABC");
+		sbp.setCompletePath("testing");
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		Node node = p.beanData().getViewTree(flt);
+		Set<Node> allNodes = node.getAllNodes();
+		for (Node acnode : allNodes) {
+			if (acnode instanceof LabelNode) {
+				assertThat(result, containsString(((LabelNode)acnode).getProperty().getViewSettings().getLabel()));
+			}
+		}
+		checkValueBinding(binding, result);
+	}
+
+
+	private void checkValueBinding(HashMap<String, String> binding, String result) {
+		for (Map.Entry<String, String> bindentry : binding.entrySet()) {
+			assertThat(result, containsString("name=\"ABC." + bindentry.getKey() + "\""));
+			assertThat(result, containsString("value=\"" + bindentry.getValue() + "\""));
+		}
+	}
+	
+	@Test
+	public void validationDecorations() throws Exception {
+		Person2 p = new Person2();
+		p.setName("Simone");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		
+		HashMap<String, String> binding = new HashMap<String, String>();
+		binding.put("name", "Simone");
+		binding.put("surname", "Gianni");
+		binding.put("email", "simoneg@apache.org");
+		
+		BeanFormProducer sbp = new BeanFormProducer(p, binding, new ArrayList<LocalizableStringWithSubject>(), null, "ABC");
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		System.out.println(result);
+		
+		Node node = p.beanData().getViewTree();
+		Set<Node> allNodes = node.getAllNodes();
+		for (Node acnode : allNodes) {
+			if (acnode instanceof LabelNode) {
+				assertThat(result, containsString(((LabelNode)acnode).getProperty().getViewSettings().getLabel() + " *"));
+			}
+		}
+		
+		checkValueBinding(binding, result);		
+	}
+	
+	@Test
+	public void textAreaFields() throws Exception {
+		Person5 p = new Person5();
+		p.setName("Simone");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		p.setDescription("bla bla bla");
+		
+		HashMap<String, String> binding = new HashMap<String, String>();
+		binding.put("description", "bla bla bla");
+		
+		BeanFormProducer sbp = new BeanFormProducer(p, binding, new ArrayList<LocalizableStringWithSubject>(), null, "ABC");
+		sbp.setCompletePath("testing");
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		Node node = p.beanData().getViewTree();
+		Set<Node> allNodes = node.getAllNodes();
+		for (Node acnode : allNodes) {
+			if (acnode instanceof LabelNode) {
+				assertThat(result, containsString(((LabelNode)acnode).getProperty().getViewSettings().getLabel()));
+			}
+		}
+		
+		
+		assertThat(result, containsString("<textarea"));
+		assertThat(result, containsString("</textarea>"));
+		assertThat(result, containsString(">bla bla bla<"));
+	}
+	
+}

Added: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowBeanTest.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowBeanTest.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowBeanTest.java (added)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowBeanTest.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview;
+
+import static org.junit.Assert.*;
+import static org.junit.matchers.StringContains.*;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Set;
+
+import org.junit.Test;
+
+import org.apache.magma.beans.BeanData;
+import org.apache.magma.view.tree.LabelNode;
+import org.apache.magma.view.tree.Node;
+import org.apache.magma.view.tree.SimpleViewFilter;
+import org.apache.magma.view.tree.ViewCustomizer;
+import org.apache.magma.website.beansview.stuff.Person;
+import org.apache.magma.website.beansview.stuff.Person2;
+import org.apache.magma.website.beansview.stuff.Person3;
+import org.apache.magma.website.beansview.stuff.Person4;
+import org.apache.magma.website.beansview.stuff.Person5;
+
+public class ShowBeanTest {
+	
+	@Test
+	public void simpleTreeFields() throws Exception {
+		Person p = new Person();
+		p.setName("Simone");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		
+		ShowBean sbp = new ShowBean(p);
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		System.out.println(result);
+		
+		Node node = p.beanData().getViewTree();
+		Set<Node> allNodes = node.getAllNodes();
+		for (Node acnode : allNodes) {
+			if (acnode instanceof LabelNode) {
+				assertThat(result, containsString(((LabelNode)acnode).getProperty().getViewSettings().getLabel()));
+			}
+		}
+		assertThat(result, containsString("Simone"));
+		assertThat(result, containsString("Gianni"));
+		assertThat(result, containsString("simoneg@apache.org"));
+	}
+
+	@Test
+	public void sidedTwoFields() throws Exception {
+		Person2 p = new Person2();
+		p.setName("Simone");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		
+		ShowBean sbp = new ShowBean(p);
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		Node node = p.beanData().getViewTree();
+		Set<Node> allNodes = node.getAllNodes();
+		for (Node acnode : allNodes) {
+			if (acnode instanceof LabelNode) {
+				assertThat(result, containsString(((LabelNode)acnode).getProperty().getViewSettings().getLabel()));
+			}
+		}
+		assertThat(result, containsString("Simone"));
+		assertThat(result, containsString("Gianni"));
+		assertThat(result, containsString("simoneg@apache.org"));
+	}
+	
+	@Test
+	public void sidedTreeFields() throws Exception {
+		Person3 p = new Person3();
+		p.setName("Simone");
+		p.setMiddle("P");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		
+		ShowBean sbp = new ShowBean(p);
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		Node node = p.beanData().getViewTree();
+		Set<Node> allNodes = node.getAllNodes();
+		for (Node acnode : allNodes) {
+			if (acnode instanceof LabelNode) {
+				assertThat(result, containsString(((LabelNode)acnode).getProperty().getViewSettings().getLabel()));
+			}
+		}
+		assertThat(result, containsString("Simone"));
+		assertThat(result, containsString("P"));
+		assertThat(result, containsString("Gianni"));
+		assertThat(result, containsString("simoneg@apache.org"));
+	}
+
+	@Test
+	public void sidedFlatTreeFields() throws Exception {
+		Person5 p = new Person5();
+		p.setName("Simone");
+		p.setMiddle("P");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		
+		ShowBean sbp = new ShowBean(p);
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		Node node = p.beanData().getViewTree();
+		Set<Node> allNodes = node.getAllNodes();
+		for (Node acnode : allNodes) {
+			if (acnode instanceof LabelNode) {
+				assertThat(result, containsString(((LabelNode)acnode).getProperty().getViewSettings().getLabel()));
+			}
+		}
+		assertThat(result, containsString("Simone"));
+		assertThat(result, containsString("P"));
+		assertThat(result, containsString("Gianni"));
+		assertThat(result, containsString("simoneg@apache.org"));
+	}
+	
+	@Test
+	public void filtered() throws Exception {
+		Person4 p = new Person4();
+		p.setName("Simone");
+		p.setMiddle("P");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		Person4 pp = new Person4();
+		pp.setName("Mara");
+		pp.setMiddle("?");
+		pp.setSurname("Scialanga");
+		pp.setEmail("boh@bih.it");
+		
+		p.setMother(pp);
+
+		ViewCustomizer flt = new SimpleViewFilter("withmother", "+mother");
+		
+		ShowBean sbp = new ShowBean(p, flt);
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		Node node = p.beanData().getViewTree(flt);
+		Set<Node> allNodes = node.getAllNodes();
+		for (Node acnode : allNodes) {
+			if (acnode instanceof LabelNode) {
+				assertThat(result, containsString(((LabelNode)acnode).getProperty().getViewSettings().getLabel()));
+			}
+		}
+		assertThat(result, containsString("Simone"));
+		assertThat(result, containsString("P"));
+		assertThat(result, containsString("Gianni"));
+		assertThat(result, containsString("simoneg@apache.org"));
+		assertThat(result, containsString("Mara"));
+		assertThat(result, containsString("?"));
+		assertThat(result, containsString("Scialanga"));
+		assertThat(result, containsString("boh@bih.it"));
+	}
+		
+}

Added: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowListTest.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowListTest.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowListTest.java (added)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/ShowListTest.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview;
+
+import org.apache.magma.website.beansview.stuff.Person;
+
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+
+public class ShowListTest {
+
+	@Test
+	public void simpleTest() throws Exception {
+		Person p = new Person();
+		p.setName("Simone");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		
+		List<Person> lst = new ArrayList<Person>();
+		lst.add(p);
+		lst.add(p);
+		
+		ShowList sbp = new ShowList(Person.class, lst);
+		
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		sbp.produce(baos);
+		
+		String result = new String(baos.toByteArray());
+
+		System.out.println(result);
+		
+	}
+	
+}

Added: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/SmartFormBindingTest.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/SmartFormBindingTest.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/SmartFormBindingTest.java (added)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/SmartFormBindingTest.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.magma.basics.LocalizableStringWithSubject;
+import org.apache.magma.view.tree.SimpleViewFilter;
+import org.apache.magma.view.tree.ViewCustomizer;
+import org.apache.magma.website.beansview.stuff.Person;
+import org.apache.magma.website.beansview.stuff.Person2;
+import org.apache.magma.website.beansview.stuff.Person4;
+
+import org.hamcrest.core.IsNull;
+import org.junit.Test;
+import org.junit.matchers.IsCollectionContaining;
+
+import static org.junit.Assert.*;
+import static org.junit.matchers.JUnitMatchers.*;
+import static org.hamcrest.CoreMatchers.*;
+
+
+public class SmartFormBindingTest {
+
+	@Test
+	public void simpleReadBinding() throws Exception {
+		Person p = new Person();
+		p.setName("Simone");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+
+		SmartForm sf = new SmartForm(p, "next");
+		
+		sf.prepareBinding();
+		
+		Map<String, String> binding = sf.binding;
+		assertThat(binding.keySet(), hasItem(equalTo("name")));
+		assertThat(binding.keySet(), hasItem(equalTo("surname")));
+		assertThat(binding.keySet(), hasItem(equalTo("email")));
+		
+		assertThat(binding.get("name"), equalTo("Simone"));
+		assertThat(binding.get("surname"), equalTo("Gianni"));
+		assertThat(binding.get("email"), equalTo("simoneg@apache.org"));
+	}
+	
+	@Test
+	public void simpleWriteBinding() throws Exception {
+		Person p = new Person();
+		Map<String, String> binding = new HashMap<String, String>();
+		binding.put("name", "Simone");
+		binding.put("surname", "Gianni");
+		binding.put("email", "simoneg@apache.org");
+
+		SmartForm sf = new SmartForm(p, "next");
+		sf.binding = binding;
+		sf.executeBinding();
+		
+		assertThat(p.getName(), equalTo("Simone"));
+		assertThat(p.getSurname(), equalTo("Gianni"));
+		assertThat(p.getEmail(), equalTo("simoneg@apache.org"));
+	}
+	
+	@Test
+	public void expandedReadAndWrite() throws Exception {
+		Person4 p = new Person4();
+		p.setName("Simone");
+		p.setMiddle("P");
+		p.setSurname("Gianni");
+		p.setEmail("simoneg@apache.org");
+		Person4 pp = new Person4();
+		pp.setName("Mara");
+		pp.setMiddle("?");
+		pp.setSurname("Scialanga");
+		pp.setEmail("boh@bih.it");
+		
+		p.setMother(pp);
+
+		ViewCustomizer flt = new SimpleViewFilter("withmotherlimited", "+mother", "-mother-mother");
+
+		SmartForm sf = new SmartForm(p, "next").setFilter(flt);
+		
+		sf.prepareBinding();
+		
+		Map<String, String> binding = sf.binding;
+		assertThat(binding.keySet(), hasItem(equalTo("name")));
+		assertThat(binding.keySet(), hasItem(equalTo("surname")));
+		assertThat(binding.keySet(), hasItem(equalTo("email")));
+		assertThat(binding.keySet(), hasItem(equalTo("middle")));
+		assertThat(binding.keySet(), hasItem(equalTo("mother-name")));
+		assertThat(binding.keySet(), hasItem(equalTo("mother-surname")));
+		assertThat(binding.keySet(), hasItem(equalTo("mother-email")));
+		assertThat(binding.keySet(), hasItem(equalTo("mother-middle")));
+		
+		assertThat(binding.get("name"), equalTo("Simone"));
+		assertThat(binding.get("surname"), equalTo("Gianni"));
+		assertThat(binding.get("middle"), equalTo("P"));
+		assertThat(binding.get("email"), equalTo("simoneg@apache.org"));
+		assertThat(binding.get("mother-name"), equalTo("Mara"));
+		assertThat(binding.get("mother-surname"), equalTo("Scialanga"));
+		assertThat(binding.get("mother-middle"), equalTo("?"));
+		assertThat(binding.get("mother-email"), equalTo("boh@bih.it"));
+		
+		Person4 otherp = new Person4();
+		sf = new SmartForm(otherp, "next").setFilter(flt);
+		
+		sf.binding = binding;
+		sf.executeBinding();
+		
+		assertThat(otherp.getName(), equalTo("Simone"));
+		assertThat(otherp.getSurname(), equalTo("Gianni"));
+		assertThat(otherp.getMiddle(), equalTo("P"));
+		assertThat(otherp.getEmail(), equalTo("simoneg@apache.org"));
+		assertThat(otherp.getMother(), notNullValue());
+		assertThat(otherp.getMother().getName(), equalTo("Mara"));
+		assertThat(otherp.getMother().getSurname(), equalTo("Scialanga"));
+		assertThat(otherp.getMother().getMiddle(), equalTo("?"));
+		assertThat(otherp.getMother().getEmail(), equalTo("boh@bih.it"));
+		
+	}
+	
+	@Test
+	public void bindWithErrors() throws Exception {
+		Person2 p = new Person2();
+		Map<String, String> binding = new HashMap<String, String>();
+		binding.put("name", "SimoneSimoneSimoneSimoneSimoneSimoneSimoneSimoneSimoneSimoneSimoneSimoneSimoneSimoneSimoneSimone");
+		binding.put("surname", "G");
+
+		SmartForm sf = new SmartForm(p, "next");
+		sf.binding = binding;
+		sf.executeBinding();
+		
+		assertThat(p.getName(), equalTo(null));
+		assertThat(p.getSurname(), equalTo(null));
+		assertThat(p.getEmail(), equalTo(null));
+		
+		List<LocalizableStringWithSubject> errors = sf.errors;
+		assertNotNull(errors);
+		assertThat(errors.size(), equalTo(3));
+		
+		for (LocalizableStringWithSubject error : errors) {
+			assertThat(error.getSubject(), notNullValue());
+		}
+	}
+	
+}

Added: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person.java (added)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview.stuff;
+
+import org.apache.magma.beans.MagmaBean;
+import org.apache.magma.view.Listed;
+import org.apache.magma.view.Order;
+import org.apache.magma.view.View;
+
+@MagmaBean
+public class Person {
+
+	private String name;
+	private String surname;
+	private String email;
+	
+	@View
+	@Order(1)
+	@Listed
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	
+	@View
+	@Order(2)
+	@Listed	
+	public String getSurname() {
+		return surname;
+	}
+	public void setSurname(String surname) {
+		this.surname = surname;
+	}
+	
+	
+	@View(label="E-Mail")
+	@Order(3)
+	public String getEmail() {
+		return email;
+	}
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	
+}

Added: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person2.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person2.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person2.java (added)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person2.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview.stuff;
+
+import org.apache.magma.beans.MagmaBean;
+import org.apache.magma.validation.validators.Length;
+import org.apache.magma.validation.validators.Required;
+import org.apache.magma.view.Order;
+import org.apache.magma.view.Side;
+import org.apache.magma.view.View;
+import org.apache.magma.view.Zone;
+
+@MagmaBean
+public class Person2 {
+
+	private String name;
+	private String surname;
+	private String email;
+	
+	
+	@View
+	@Order(1)
+	public String getName() {
+		return name;
+	}
+	@Required
+	@Length(min=3, max=50)
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	
+	@View
+	@Zone(side=Side.OutsideRight, of="name")
+	public String getSurname() {
+		return surname;
+	}
+	
+	@Required
+	@Length(min=3, max=50)	
+	public void setSurname(String surname) {
+		this.surname = surname;
+	}
+	
+	
+	@View(label="E-Mail")
+	@Order(3)	
+	public String getEmail() {
+		return email;
+	}
+	
+	@Required
+	@Length(min=5, max=250)	
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	
+}

Added: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person3.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person3.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person3.java (added)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person3.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview.stuff;
+
+import org.apache.magma.beans.MagmaBean;
+import org.apache.magma.view.After;
+import org.apache.magma.view.Before;
+import org.apache.magma.view.Order;
+import org.apache.magma.view.Side;
+import org.apache.magma.view.View;
+import org.apache.magma.view.Zone;
+
+@MagmaBean
+public class Person3 {
+
+	private String name;
+	private String surname;
+	private String middle;
+	private String email;
+	
+	
+	@View
+	@Order(1)
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	
+	@View
+	@Zone(side=Side.OutsideRight, of="name")
+	public String getSurname() {
+		return surname;
+	}
+	public void setSurname(String surname) {
+		this.surname = surname;
+	}
+	
+	
+	@View(label="E-Mail")
+	@Order(3)
+	public String getEmail() {
+		return email;
+	}
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	@View(label="Middle initial")
+	@Zone(side=Side.OutsideRight, of="name")
+	@Before("surname")
+	public String getMiddle() {
+		return middle;
+	}
+	public void setMiddle(String middle) {
+		this.middle = middle;
+	}
+	
+}

Added: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person4.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person4.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person4.java (added)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person4.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview.stuff;
+
+import org.apache.magma.beans.MagmaBean;
+import org.apache.magma.view.After;
+import org.apache.magma.view.Before;
+import org.apache.magma.view.Order;
+import org.apache.magma.view.Side;
+import org.apache.magma.view.View;
+import org.apache.magma.view.Zone;
+
+@MagmaBean
+public class Person4 {
+
+	private String name;
+	private String surname;
+	private String middle;
+	private String email;
+	
+	private Person4 mother;
+	
+	
+	@View
+	@Order(1)
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	
+	@View
+	@Zone(side=Side.OutsideRight, of="name")
+	public String getSurname() {
+		return surname;
+	}
+	public void setSurname(String surname) {
+		this.surname = surname;
+	}
+	
+	
+	@View(label="E-Mail")
+	@Order(3)
+	public String getEmail() {
+		return email;
+	}
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	@View(label="Middle initial")
+	@Zone(side=Side.OutsideRight, of="name")
+	@Before("surname")
+	public String getMiddle() {
+		return middle;
+	}
+	public void setMiddle(String middle) {
+		this.middle = middle;
+	}
+	
+	@View
+	@Order(5)
+	public Person4 getMother() {
+		return mother;
+	}
+	public void setMother(Person4 mother) {
+		this.mother = mother;
+	}
+}

Added: labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person5.java
URL: http://svn.apache.org/viewvc/labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person5.java?rev=695912&view=auto
==============================================================================
--- labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person5.java (added)
+++ labs/magma/trunk/website-beansview/src/test/java/org/apache/magma/website/beansview/stuff/Person5.java Tue Sep 16 07:36:10 2008
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.magma.website.beansview.stuff;
+
+import org.apache.magma.beans.MagmaBean;
+import org.apache.magma.validation.validators.Length;
+import org.apache.magma.view.After;
+import org.apache.magma.view.Before;
+import org.apache.magma.view.Order;
+import org.apache.magma.view.Side;
+import org.apache.magma.view.View;
+import org.apache.magma.view.Zone;
+
+@MagmaBean
+public class Person5 {
+
+	private String name;
+	private String surname;
+	private String middle;
+	private String email;
+	private String description;
+	
+	
+	@View
+	@Order(1)
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	
+	@View
+	@Zone(side=Side.OutsideRight, of="name")
+	public String getSurname() {
+		return surname;
+	}
+	public void setSurname(String surname) {
+		this.surname = surname;
+	}
+	
+	
+	@View(label="E-Mail")
+	@Zone(side=Side.OutsideRight, of="surname")
+	public String getEmail() {
+		return email;
+	}
+	public void setEmail(String email) {
+		this.email = email;
+	}
+	@View(label="Middle initial")
+	@Zone(side=Side.OutsideRight, of="name")
+	@Before("surname")
+	public String getMiddle() {
+		return middle;
+	}
+	public void setMiddle(String middle) {
+		this.middle = middle;
+	}
+	
+	@View
+	@Order(5)
+	public String getDescription() {
+		return description;
+	}
+	@Length(max=1024)
+	public void setDescription(String description) {
+		this.description = description;
+	}
+	
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org