Author: hlship
Date: Fri Dec 21 15:47:04 2007
New Revision: 606347
URL: http://svn.apache.org/viewvc?rev=606347&view=rev
Log:
TAPESTRY-1360: Add a @Width annotation to set the width of input fields
generated by BeanEditForm
Added:
tapestry/tapestry5/trunk/tapestry-annotations/src/main/java/org/apache/tapestry/beaneditor/Width.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/PropertyEditBlocks.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyModelImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestFilter.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestHandler.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/PropertyEditContext.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Request.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestFilter.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestHandler.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SimpleBean.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java
Added:
tapestry/tapestry5/trunk/tapestry-annotations/src/main/java/org/apache/tapestry/beaneditor/Width.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-annotations/src/main/java/org/apache/tapestry/beaneditor/Width.java?rev=606347&view=auto
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-annotations/src/main/java/org/apache/tapestry/beaneditor/Width.java
(added)
+++
tapestry/tapestry5/trunk/tapestry-annotations/src/main/java/org/apache/tapestry/beaneditor/Width.java
Fri Dec 21 15:47:04 2007
@@ -0,0 +1,37 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed 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.tapestry.beaneditor;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Defines the desired width of the field used to edit the property. Note
that width (generally equivalent to the
+ * size attribute of an HTML <input> element) is only used for
presentation; validation must be used to
+ * actually enforce a maximum input length.
+ */
[EMAIL PROTECTED](METHOD)
[EMAIL PROTECTED](RetentionPolicy.RUNTIME)
[EMAIL PROTECTED]
+public @interface Width
+{
+ /**
+ * The width used to display the field for the property (values less than
one indicate unspecified).
+ */
+ int value();
+}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/beaneditor/PropertyModel.java
Fri Dec 21 15:47:04 2007
@@ -52,7 +52,7 @@
* Changes the data type for the property.
*
* @param dataType
- * @return the property edit model, for further changes
+ * @return the property model, for further changes
*/
PropertyModel dataType(String dataType);
@@ -63,10 +63,25 @@
PropertyConduit getConduit();
/**
+ * Returns the desired field width for the field used to edit the
property. A value of 0 or less means unspecified.
+ *
+ * @return the width of the field used to edit the property
+ */
+ int getWidth();
+
+ /**
+ * Sets the width of the field used to edit the property.
+ *
+ * @param width the desired width (0 or less indicates an unspecified
width)
+ * @return the property model, for further changes
+ */
+ PropertyModel width(int width);
+
+ /**
* Changes the label for the property to the provided value.
*
* @param label new label for property
- * @return the property edit model, for further changes
+ * @return the property model, for further changes
*/
PropertyModel label(String label);
@@ -83,6 +98,8 @@
/**
* Updates sortable and returns the model for further changes.
+ *
+ * @return the property model, for further changes
*/
PropertyModel sortable(boolean sortable);
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/components/PropertyEditor.java
Fri Dec 21 15:47:04 2007
@@ -170,6 +170,11 @@
{
_propertyModel.getConduit().set(_object, value);
}
+
+ public int getWidth()
+ {
+ return _propertyModel.getWidth();
+ }
};
_environment.push(PropertyEditContext.class, context);
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/PropertyEditBlocks.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/PropertyEditBlocks.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/PropertyEditBlocks.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/corelib/pages/PropertyEditBlocks.java
Fri Dec 21 15:47:04 2007
@@ -38,27 +38,22 @@
@Environmental
private PropertyEditContext _context;
- @Component(parameters =
- {"value=context.propertyValue", "label=prop:context.label",
- "translate=prop:context.translator",
"validate=prop:textFieldValidator",
- "clientId=prop:context.propertyId"})
+ @Component(
+ parameters = {"value=context.propertyValue",
"label=prop:context.label", "translate=prop:context.translator",
"validate=prop:textFieldValidator", "clientId=prop:context.propertyId",
"size=prop:widthOrNull"})
private TextField _textField;
- @Component(parameters =
- {"value=context.propertyValue", "label=prop:context.label",
"encoder=valueEncoderForProperty",
- "model=selectModelForProperty",
"validate=prop:selectValidator",
- "clientId=prop:context.propertyId"})
+ @Component(
+ parameters = {"value=context.propertyValue",
"label=prop:context.label", "encoder=valueEncoderForProperty",
"model=selectModelForProperty", "validate=prop:selectValidator",
"clientId=prop:context.propertyId"})
private Select _select;
@SuppressWarnings("unused")
- @Component(parameters =
- {"value=context.propertyValue", "label=prop:context.label",
"clientId=prop:context.propertyId"})
+ @Component(
+ parameters = {"value=context.propertyValue",
"label=prop:context.label", "clientId=prop:context.propertyId"})
private Checkbox _checkboxField;
@SuppressWarnings("unused")
- @Component(parameters =
- {"value=context.propertyValue", "label=prop:context.label",
- "clientId=prop:context.propertyid",
"validate=prop:dateFieldValidator"})
+ @Component(
+ parameters = {"value=context.propertyValue",
"label=prop:context.label", "clientId=prop:context.propertyid",
"validate=prop:dateFieldValidator"})
private DateField _dateField;
public PropertyEditContext getContext()
@@ -97,5 +92,12 @@
public SelectModel getSelectModelForProperty()
{
return new EnumSelectModel(_context.getPropertyType(),
_context.getContainerMessages());
+ }
+
+ public Integer getWidthOrNull()
+ {
+ int width = _context.getWidth();
+
+ return width < 1 ? null : width;
}
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyModelImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyModelImpl.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyModelImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/beaneditor/PropertyModelImpl.java
Fri Dec 21 15:47:04 2007
@@ -17,6 +17,7 @@
import org.apache.tapestry.PropertyConduit;
import org.apache.tapestry.beaneditor.BeanModel;
import org.apache.tapestry.beaneditor.PropertyModel;
+import org.apache.tapestry.beaneditor.Width;
import org.apache.tapestry.internal.TapestryInternalUtils;
import org.apache.tapestry.ioc.Messages;
import static org.apache.tapestry.ioc.internal.util.Defense.notBlank;
@@ -38,8 +39,9 @@
private boolean _sortable;
- public PropertyModelImpl(BeanModel model, final String name, final
PropertyConduit conduit,
- Messages messages)
+ private int _width;
+
+ public PropertyModelImpl(BeanModel model, String name, PropertyConduit
conduit, Messages messages)
{
_model = model;
_name = name;
@@ -55,6 +57,14 @@
Class wrapperType = ClassFabUtils.getWrapperType(getPropertyType());
_sortable = Comparable.class.isAssignableFrom(wrapperType);
+
+ // Extract a default width from the @Width annotation, if present
+ if (conduit != null)
+ {
+ Width width = conduit.getAnnotation(Width.class);
+
+ if (width != null) _width = width.value();
+ }
}
public String getId()
@@ -116,6 +126,18 @@
public PropertyModel sortable(boolean sortable)
{
_sortable = sortable;
+
+ return this;
+ }
+
+ public int getWidth()
+ {
+ return _width;
+ }
+
+ public PropertyModel width(int width)
+ {
+ _width = width;
return this;
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestImpl.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/RequestImpl.java
Fri Dec 21 15:47:04 2007
@@ -110,4 +110,8 @@
return
XML_HTTP_REQUEST.equals(_request.getHeader(REQUESTED_WITH_HEADER));
}
+ public boolean isRequestedSessionIdValid()
+ {
+ return _request.isRequestedSessionIdValid();
+ }
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/test/TestableRequestImpl.java
Fri Dec 21 15:47:04 2007
@@ -42,9 +42,8 @@
private void nyi(String methodName)
{
- throw new RuntimeException(String.format(
- "Request: method %s() not yet implemented by
TestableRequestImpl.",
- methodName));
+ throw new RuntimeException(
+ String.format("Request: method %s() not yet implemented by
TestableRequestImpl.", methodName));
}
public void clear()
@@ -140,4 +139,11 @@
return false;
}
+ /**
+ * Always returns true.
+ */
+ public boolean isRequestedSessionIdValid()
+ {
+ return true;
+ }
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestFilter.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestFilter.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestFilter.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestFilter.java
Fri Dec 21 15:47:04 2007
@@ -19,12 +19,12 @@
import java.io.IOException;
/**
- * @see org.apache.tapestry.services.HttpServletRequestHandler
+ * Filter interface for [EMAIL PROTECTED]
org.apache.tapestry.services.HttpServletRequestHandler}.
*/
public interface HttpServletRequestFilter
{
/**
- * Filter interface for the tapestry.request.HttpServletRequestHandler
pipeline. A filter should
+ * Filter interface for the HttpServletRequestHandler pipeline. A filter
should
* delegate to the handler. It may perform operations before or after
invoking the handler, and
* may modify the request and response passed in to the handler.
*
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestHandler.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestHandler.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestHandler.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/HttpServletRequestHandler.java
Fri Dec 21 15:47:04 2007
@@ -19,7 +19,7 @@
import java.io.IOException;
/**
- * Service interface for the tapestry.request.HttpServletRequestHandler
pipeline service.
+ * Service interface for the HttpServletRequestHandler pipeline service.
*
* @see org.apache.tapestry.services.HttpServletRequestFilter
*/
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/PropertyEditContext.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/PropertyEditContext.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/PropertyEditContext.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/PropertyEditContext.java
Fri Dec 21 15:47:04 2007
@@ -82,4 +82,9 @@
* correct place to look for strings used for labels, etc.
*/
Messages getContainerMessages();
+
+ /**
+ * Returns the desired width of the input field used to edit the property.
A value less than 1 is an unspecified width.
+ */
+ int getWidth();
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Request.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Request.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Request.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/Request.java
Fri Dec 21 15:47:04 2007
@@ -113,4 +113,11 @@
* @return true if the request has an XmlHttpRequest origin
*/
boolean isXHR();
+
+ /**
+ * Checks whether the requested session ID is still valid.
+ *
+ * @return true if the request included a session id that is still active,
false if the included session id has expired
+ */
+ public boolean isRequestedSessionIdValid();
}
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestFilter.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestFilter.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestFilter.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestFilter.java
Fri Dec 21 15:47:04 2007
@@ -18,7 +18,7 @@
/**
* Filter interface for [EMAIL PROTECTED]
org.apache.tapestry.services.RequestHandler}. Implementations of
- * this interface may be contributed into the tapestry.RequestHandler service
configuration.
+ * this interface may be contributed into the RequestHandler service
configuration.
*/
public interface RequestFilter
{
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestHandler.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestHandler.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestHandler.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/RequestHandler.java
Fri Dec 21 15:47:04 2007
@@ -17,9 +17,10 @@
import java.io.IOException;
/**
- * Service interface for the RequestHandler pipeline service.
+ * Service interface for the RequestHandler pipeline service. An ordered
configuration of filters may be
+ * contributed to the service.
*
- * @see RequestFilter
+ * @see org.apache.tapestry.services.RequestFilter
*/
public interface RequestHandler
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
Fri Dec 21 15:47:04 2007
@@ -533,9 +533,14 @@
assertText("//[EMAIL PROTECTED]'firstName']/@size", "40");
+ // Check that the @Width annotation works
+
+ assertText("//[EMAIL PROTECTED]'birthYear']/@size", "4");
+
// Check override of the submit label
assertText("//[EMAIL PROTECTED]'submit']/@value", "Register");
+
type("firstName", "a");
type("lastName", "b");
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/data/RegistrationData.java
Fri Dec 21 15:47:04 2007
@@ -17,6 +17,7 @@
import org.apache.tapestry.beaneditor.OrderAfter;
import org.apache.tapestry.beaneditor.OrderBefore;
import org.apache.tapestry.beaneditor.Validate;
+import org.apache.tapestry.beaneditor.Width;
public class RegistrationData
{
@@ -32,6 +33,7 @@
@OrderAfter("lastName")
@Validate("min=1900,max=2007")
+ @Width(4)
public int getBirthYear()
{
return _birthYear;
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/BeanModelSourceImplTest.java
Fri Dec 21 15:47:04 2007
@@ -22,6 +22,7 @@
import org.apache.tapestry.internal.test.InternalBaseTestCase;
import org.apache.tapestry.ioc.Messages;
import org.apache.tapestry.services.BeanModelSource;
+import org.easymock.EasyMock;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -70,21 +71,22 @@
assertEquals(model.getPropertyNames(), Arrays.asList("firstName",
"lastName", "age"));
- assertEquals(
- model.toString(),
- "BeanModel[org.apache.tapestry.internal.services.SimpleBean
properties:firstName, lastName, age]");
+ assertEquals(model.toString(),
+
"BeanModel[org.apache.tapestry.internal.services.SimpleBean
properties:firstName, lastName, age]");
PropertyModel age = model.get("age");
assertEquals(age.getLabel(), "Age");
assertSame(age.getPropertyType(), int.class);
assertEquals(age.getDataType(), "text");
+ assertEquals(age.getWidth(), 2);
PropertyModel firstName = model.get("firstName");
assertEquals(firstName.getLabel(), "First Name");
assertEquals(firstName.getPropertyType(), String.class);
assertEquals(firstName.getDataType(), "text");
+ assertEquals(firstName.getWidth(), 0);
assertEquals(model.get("lastName").getLabel(), "Last Name");
@@ -122,6 +124,7 @@
stub_contains(messages, false);
expect(conduit.getPropertyType()).andReturn(propertyType).atLeastOnce();
+
expect(conduit.getAnnotation(EasyMock.isA(Class.class))).andStubReturn(null);
replay();
@@ -131,17 +134,9 @@
// Note the use of case insensitivity here.
- PropertyModel property = model.add(
- RelativePosition.BEFORE,
- "lastname",
- "middleInitial",
- conduit);
-
- assertEquals(model.getPropertyNames(), Arrays.asList(
- "firstName",
- "middleInitial",
- "lastName",
- "age"));
+ PropertyModel property = model.add(RelativePosition.BEFORE,
"lastname", "middleInitial", conduit);
+
+ assertEquals(model.getPropertyNames(), Arrays.asList("firstName",
"middleInitial", "lastName", "age"));
assertEquals(property.getPropertyName(), "middleInitial");
assertSame(property.getConduit(), conduit);
@@ -193,23 +188,17 @@
expect(conduit.getPropertyType()).andReturn(propertyType).atLeastOnce();
+
expect(conduit.getAnnotation(EasyMock.isA(Class.class))).andStubReturn(null);
+
replay();
BeanModel model = _source.create(SimpleBean.class, true, resources);
assertEquals(model.getPropertyNames(), Arrays.asList("firstName",
"lastName", "age"));
- PropertyModel property = model.add(
- RelativePosition.AFTER,
- "firstname",
- "middleInitial",
- conduit);
-
- assertEquals(model.getPropertyNames(), Arrays.asList(
- "firstName",
- "middleInitial",
- "lastName",
- "age"));
+ PropertyModel property = model.add(RelativePosition.AFTER,
"firstname", "middleInitial", conduit);
+
+ assertEquals(model.getPropertyNames(), Arrays.asList("firstName",
"middleInitial", "lastName", "age"));
assertEquals(property.getPropertyName(), "middleInitial");
assertSame(property.getConduit(), conduit);
@@ -280,9 +269,8 @@
}
catch (RuntimeException ex)
{
- assertEquals(
- ex.getMessage(),
- "Bean editor model for
org.apache.tapestry.internal.services.SimpleBean already contains a property
model for property \'age\'.");
+ assertEquals(ex.getMessage(),
+ "Bean editor model for
org.apache.tapestry.internal.services.SimpleBean already contains a property
model for property \'age\'.");
}
verify();
@@ -308,10 +296,8 @@
}
catch (RuntimeException ex)
{
- assertEquals(
- ex.getMessage(),
- "Bean editor model for
org.apache.tapestry.internal.services.SimpleBean does not contain a property
named \'frobozz\'. "
- + "Available properties: age, firstName,
lastName.");
+ assertEquals(ex.getMessage(),
+ "Bean editor model for
org.apache.tapestry.internal.services.SimpleBean does not contain a property
named \'frobozz\'. " + "Available properties: age, firstName, lastName.");
}
verify();
@@ -346,8 +332,7 @@
replay();
- BeanModel model = _source.create(SimpleBean.class, true,
resources).get("age").label(
- "Decrepitude").model();
+ BeanModel model = _source.create(SimpleBean.class, true,
resources).get("age").label("Decrepitude").model();
assertEquals(model.get("age").getLabel(), "Decrepitude");
@@ -394,8 +379,7 @@
assertSame(propertyModel.getPropertyType(), String[].class);
- String[] value =
- {"foo", "bar"};
+ String[] value = {"foo", "bar"};
StringArrayBean bean = new StringArrayBean();
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SimpleBean.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SimpleBean.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SimpleBean.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/SimpleBean.java
Fri Dec 21 15:47:04 2007
@@ -14,6 +14,8 @@
package org.apache.tapestry.internal.services;
+import org.apache.tapestry.beaneditor.Width;
+
public class SimpleBean
{
private String _firstName;
@@ -32,6 +34,7 @@
return _lastName;
}
+ @Width(2)
public int getAge()
{
return _age;
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java
Fri Dec 21 15:47:04 2007
@@ -61,7 +61,7 @@
*/
static final String CLASS_FACTORY_SERVICE_ID = "ClassFactory";
- static final String LOG_SOURCE_SERVICE_ID = "LogSource";
+ static final String LOGGER_SOURCE_SERVICE_ID = "LoggerSource";
private final OneShotLock _lock = new OneShotLock();
@@ -130,7 +130,7 @@
addBuiltin(SERVICE_ACTIVITY_SCOREBOARD_SERVICE_ID,
ServiceActivityScoreboard.class, scoreboardAndTracker);
- addBuiltin(LOG_SOURCE_SERVICE_ID, LoggerSource.class, _loggerSource);
+ addBuiltin(LOGGER_SOURCE_SERVICE_ID, LoggerSource.class,
_loggerSource);
_classFactory = classFactory;
Modified:
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java
URL:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java?rev=606347&r1=606346&r2=606347&view=diff
==============================================================================
---
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java
(original)
+++
tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/services/PipelineBuilder.java
Fri Dec 21 15:47:04 2007
@@ -1,17 +1,17 @@
-// Copyright 2006, 2007 The Apache Software Foundation
-//
-// Licensed 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.
-
+// Copyright 2006, 2007 The Apache Software Foundation
+//
+// Licensed 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.tapestry.ioc.services;
import org.slf4j.Logger;