Seam SVN: r9676 - in trunk: examples/ui/src/org/jboss/seam/example/ui and 5 other directories.
by seam-commits@lists.jboss.org
Author: danielc.roth
Date: 2008-11-29 19:44:50 -0500 (Sat, 29 Nov 2008)
New Revision: 9676
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Controls.xml
trunk/examples/ui/src/org/jboss/seam/example/ui/EqualityValidatorBean.java
trunk/examples/ui/view/equalityValidator.xhtml
trunk/ui/src/main/config/component/equalityValidator.xml
trunk/ui/src/main/java/org/jboss/seam/ui/component/UIEqualityValidator.java
trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/EqualityValidatorRendererBase.java
trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java
Log:
JBSEAM-3720
Modified: trunk/doc/Seam_Reference_Guide/en-US/Controls.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Controls.xml 2008-11-29 17:12:07 UTC (rev 9675)
+++ trunk/doc/Seam_Reference_Guide/en-US/Controls.xml 2008-11-30 00:44:50 UTC (rev 9676)
@@ -481,7 +481,7 @@
<para><emphasis>Description</emphasis></para>
<para>
Tag to nest inside an input control to validate that its parent's
- value is the same as the referenced control's value.
+ value is equal (or not equal!) to the referenced control's value.
</para>
<para><emphasis>Attributes</emphasis></para>
@@ -501,6 +501,44 @@
<literal>messageId</literal> — Message id to show on failure.
</para>
</listitem>
+ <listitem>
+ <para>
+ <literal>operator</literal> — What operator to use when comparing the values
+ Valid operators are:
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>equal</literal> — Validates that value.equals(forValue)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>not_equal</literal> — Validates that !value.equals(forValue)
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>greater</literal> — <![CDATA[Validates that ((Comparable)value).compareTo(forValue) > 0]]>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>greater_or_equal</literal> — <![CDATA[Validates that ((Comparable)value).compareTo(forValue) >= 0]]>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>less</literal> — <![CDATA[Validates that ((Comparable)value).compareTo(forValue) < 0]]>
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>less_or_equal</literal> — <![CDATA[Validates that ((Comparable)value).compareTo(forValue) <= 0]]>
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </listitem>
</itemizedlist>
<para><emphasis>Usage</emphasis></para>
Modified: trunk/examples/ui/src/org/jboss/seam/example/ui/EqualityValidatorBean.java
===================================================================
--- trunk/examples/ui/src/org/jboss/seam/example/ui/EqualityValidatorBean.java 2008-11-29 17:12:07 UTC (rev 9675)
+++ trunk/examples/ui/src/org/jboss/seam/example/ui/EqualityValidatorBean.java 2008-11-30 00:44:50 UTC (rev 9676)
@@ -20,6 +20,8 @@
private String name;
+ private Long age;
+
private Date date;
public void check()
@@ -28,32 +30,34 @@
{
statusMessages.addToControl("name", Severity.WARN, "Enter a name!");
}
- else {
+ else
+ {
statusMessages.addToControl("name", Severity.INFO, "OK!");
}
}
-
+
public void checkDate()
{
- if (date==null)
+ if (date == null)
{
statusMessages.addToControl("date", Severity.WARN, "Enter a date!");
}
- else {
+ else
+ {
statusMessages.addToControl("date", Severity.INFO, "OK!");
}
- }
-
+ }
+
public Date getDate()
{
return date;
}
-
+
public void setDate(Date date)
{
this.date = date;
}
-
+
public String getName()
{
return name;
@@ -64,4 +68,14 @@
this.name = name;
}
+ public Long getAge()
+ {
+ return age;
+ }
+
+ public void setAge(Long age)
+ {
+ this.age = age;
+ }
+
}
Modified: trunk/examples/ui/view/equalityValidator.xhtml
===================================================================
--- trunk/examples/ui/view/equalityValidator.xhtml 2008-11-29 17:12:07 UTC (rev 9675)
+++ trunk/examples/ui/view/equalityValidator.xhtml 2008-11-30 00:44:50 UTC (rev 9676)
@@ -1,26 +1,37 @@
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<ui:composition xmlns="http://www.w3.org/1999/xhtml"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns:f="http://java.sun.com/jsf/core"
- xmlns:h="http://java.sun.com/jsf/html"
- xmlns:s="http://jboss.com/products/seam/taglib"
- template="template.xhtml">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html" xmlns:s="http://jboss.com/products/seam/taglib" template="template.xhtml">
<ui:param name="tagName" value="s:validateEquality" />
<ui:define name="body">
- <p>Validates that two java.lang.String inputs are equal</p>
<h:form>
+ <p>Validates that two java.lang.String inputs are equal</p>
<h:panelGrid columns="3">
<s:label for="name">Name</s:label>
<h:inputText id="name" value="#{equalityValidatorBean.name}" />
<h:message for="name" />
<s:label for="nameVerification">Name Verification</s:label>
<h:inputText id="nameVerification">
- <s:validateEquality for="name" message="Strings do not match!" />
+ <s:validateEquality for="name" message="Must be the same as name!" />
</h:inputText>
<h:message for="nameVerification" />
- <h:commandButton action="#{equalityValidatorBean.check}"
- value="Check name" />
+ <h:commandButton action="#{equalityValidatorBean.check}" value="Check name" />
</h:panelGrid>
+ </h:form>
+
+ <h:form>
+ <p>Validates that one number is greater than another</p>
+ <h:panelGrid columns="3">
+ <s:label for="min">Minimum age (e.g. 18)</s:label>
+ <h:inputText id="min" value="#{equalityValidatorBean.age}" />
+ <h:message for="min" />
+ <s:label for="minVerification">Maximum age (e.g. 25)</s:label>
+ <h:inputText id="minVerification">
+ <f:convertNumber integerOnly="true" />
+ <s:validateEquality for="min" message="Must be larger than minimum!" operator="greater" />
+ </h:inputText>
+ <h:message for="minVerification" />
+ <h:commandButton action="#{equalityValidatorBean.check}" value="Check ages" />
+ </h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
Modified: trunk/ui/src/main/config/component/equalityValidator.xml
===================================================================
--- trunk/ui/src/main/config/component/equalityValidator.xml 2008-11-29 17:12:07 UTC (rev 9675)
+++ trunk/ui/src/main/config/component/equalityValidator.xml 2008-11-30 00:44:50 UTC (rev 9676)
@@ -36,6 +36,11 @@
<classname>java.lang.String</classname>
<description>Message id to use on failure</description>
</property>
+ <property>
+ <name>operator</name>
+ <classname>java.lang.String</classname>
+ <description>Operation to use.</description>
+ </property>
</component>
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/component/UIEqualityValidator.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/component/UIEqualityValidator.java 2008-11-29 17:12:07 UTC (rev 9675)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/component/UIEqualityValidator.java 2008-11-30 00:44:50 UTC (rev 9676)
@@ -21,5 +21,9 @@
public abstract String getMessageId();
public abstract void setMessageId(String messageId);
+
+ public abstract void setOperator(String operator);
+
+ public abstract String getOperator();
}
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/EqualityValidatorRendererBase.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/EqualityValidatorRendererBase.java 2008-11-29 17:12:07 UTC (rev 9675)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/EqualityValidatorRendererBase.java 2008-11-30 00:44:50 UTC (rev 9676)
@@ -42,7 +42,7 @@
if (!hasEqualityValidator(evh))
{
- evh.addValidator(new EqualityValidator(ev.getFor(), ev.getMessage(), ev.getMessageId()));
+ evh.addValidator(new EqualityValidator(ev.getFor(), ev.getMessage(), ev.getMessageId(), ev.getOperator()));
evh.setRequired(true);
}
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java 2008-11-29 17:12:07 UTC (rev 9675)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java 2008-11-30 00:44:50 UTC (rev 9676)
@@ -4,6 +4,7 @@
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
import javax.faces.component.EditableValueHolder;
import javax.faces.component.StateHolder;
import javax.faces.component.UIComponent;
@@ -34,9 +35,15 @@
public static final String VALIDATOR_ID = "org.jboss.seam.ui.validator.Equality";
+ private enum ValidOperation
+ {
+ EQUAL, NOT_EQUAL, GREATER, GREATER_OR_EQUAL, LESS, LESS_OR_EQUAL;
+ }
+
private String forId;
private String message;
private String messageId;
+ private ValidOperation operator = ValidOperation.EQUAL; // Default
public EqualityValidator()
{
@@ -50,7 +57,7 @@
setFor(forId);
}
- public EqualityValidator(String forId, String message, String messageId)
+ public EqualityValidator(String forId, String message, String messageId, String operator)
{
this(forId);
if (message != null)
@@ -61,8 +68,26 @@
{
setMessageId(messageId);
}
+ if (operator != null && !"".equals(operator))
+ {
+ if (ValidOperation.valueOf(operator.toUpperCase()) != null)
+ setOperator(ValidOperation.valueOf(operator.toUpperCase()));
+ else
+ throw new IllegalStateException("Illegal operator. " + "Supported are: " + validOperatorsAsString());
+ }
+
}
+ private String validOperatorsAsString()
+ {
+ StringBuffer buff = new StringBuffer();
+ for (ValidOperation op : ValidOperation.values())
+ {
+ buff.append(op.name()).append(" ");
+ }
+ return buff.toString();
+ }
+
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
{
String forId = getFor();
@@ -78,14 +103,67 @@
}
else if (value != null)
{
- if (!value.equals(other))
+ switch (operator)
{
- String otherComponentId = otherComponent.getId();
- throw new ValidatorException(FacesMessages.createFacesMessage(javax.faces.application.FacesMessage.SEVERITY_ERROR, getMessageId(), getMessage(), otherComponentId, value, other));
+ case EQUAL:
+ if (!value.equals(other))
+ {
+ throwValidationException(value, otherComponent, other);
+ }
+ break;
+ case NOT_EQUAL:
+ if (value.equals(other))
+ {
+ throwValidationException(value, otherComponent, other);
+ }
+ break;
+ case GREATER:
+ if (!(compare(value, other) > 0))
+ {
+ throwValidationException(value, otherComponent, other);
+ }
+ break;
+ case GREATER_OR_EQUAL:
+ if (!(compare(value, other) >= 0))
+ {
+ throwValidationException(value, otherComponent, other);
+ }
+ break;
+ case LESS:
+ if (!(compare(value, other) < 0))
+ {
+ throwValidationException(value, otherComponent, other);
+ }
+ break;
+ case LESS_OR_EQUAL:
+ if (!(compare(value, other) <= 0))
+ {
+ throwValidationException(value, otherComponent, other);
+ }
+ break;
}
}
}
+ private int compare(Object value, Object other) throws IllegalArgumentException
+ {
+ try
+ {
+ Comparable c1 = (Comparable) value;
+ return c1.compareTo(other);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalArgumentException("Values are not comparable", e);
+ }
+
+ }
+
+ private void throwValidationException(Object value, UIComponent otherComponent, Object other)
+ {
+ throw new ValidatorException(FacesMessages.createFacesMessage(FacesMessage.SEVERITY_ERROR, getMessageId(), getMessage(), otherComponent.getId(), value, other));
+ }
+
public String getFor()
{
return forId;
@@ -127,14 +205,16 @@
forId = (String) fields[0];
message = (String) fields[1];
messageId = (String) fields[2];
+ operator = ValidOperation.valueOf((String) fields[3]);
}
public Object saveState(FacesContext context)
{
- Object[] state = new Object[3];
+ Object[] state = new Object[4];
state[0] = forId;
state[1] = message;
state[2] = messageId;
+ state[3] = operator.toString();
return state;
}
@@ -252,7 +332,8 @@
}
else if (newSubmittedValue instanceof String)
{
- // If there's no Renderer, and we've got a String, run it through
+ // If there's no Renderer, and we've got a String, run it
+ // through
// the Converter (if any)
if (converter != null)
{
@@ -305,4 +386,14 @@
}
}
+
+ public ValidOperation getOperator()
+ {
+ return operator;
+ }
+
+ public void setOperator(ValidOperation operator)
+ {
+ this.operator = operator;
+ }
}
15 years, 12 months
Seam SVN: r9675 - trunk/build.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-11-29 12:12:07 -0500 (Sat, 29 Nov 2008)
New Revision: 9675
Modified:
trunk/build/ci.build.xml
Log:
pass ant.version in a couple more places
Modified: trunk/build/ci.build.xml
===================================================================
--- trunk/build/ci.build.xml 2008-11-28 07:44:23 UTC (rev 9674)
+++ trunk/build/ci.build.xml 2008-11-29 17:12:07 UTC (rev 9675)
@@ -48,12 +48,21 @@
<build target="dist" />
<ant target="deploySeamSnapshot" antfile="${ant.file}" inheritall="false" inheritrefs="false" dir=".">
+ <propertyset>
+ <propertyref name="ant.version"/>
+ </propertyset>
<property name="qualifier" value="-SNAPSHOT" />
</ant>
<ant target="deployExamplesSnapshot" antfile="${ant.file}" inheritall="false" inheritrefs="false" dir=".">
+ <propertyset>
+ <propertyref name="ant.version"/>
+ </propertyset>
<property name="qualifier" value="-SNAPSHOT" />
</ant>
<ant target="tests" antfile="${ant.file}" inheritall="false" inheritrefs="false" dir=".">
+ <propertyset>
+ <propertyref name="ant.version"/>
+ </propertyset>
<property name="qualifier" value="-SNAPSHOT" />
</ant>
</target>
@@ -63,10 +72,16 @@
<build target="dist" />
<ant target="deploySeamSnapshot" antfile="${ant.file}" inheritall="false" inheritrefs="false" dir=".">
- <property name="qualifier" value="-SNAPSHOT" />
+ <propertyset>
+ <propertyref name="ant.version"/>
+ </propertyset>
+ <property name="qualifier" value="-SNAPSHOT" />
</ant>
<ant target="deployExamplesSnapshot" antfile="${ant.file}" inheritall="false" inheritrefs="false" dir=".">
- <property name="qualifier" value="-SNAPSHOT" />
+ <propertyset>
+ <propertyref name="ant.version"/>
+ </propertyset>
+ <property name="qualifier" value="-SNAPSHOT" />
</ant>
</target>
@@ -78,7 +93,10 @@
</properties>
</build>
<ant target="deployDocumentation" antfile="${ant.file}" inheritall="false" inheritrefs="false" dir=".">
- <property name="qualifier" value="-SNAPSHOT" />
+ <propertyset>
+ <propertyref name="ant.version"/>
+ </propertyset>
+ <property name="qualifier" value="-SNAPSHOT" />
</ant>
</target>
@@ -110,7 +128,7 @@
<property name="dist.location" value="${dist.location}" />
<property name="qualifier" value="-SNAPSHOT" />
<property name="quietclean" value="true" />
- <property name="testng.jvmargs" value="@{testngjvmargs}" />
+ <property name="testng.jvmargs" value="@{testngjvmargs}" />
<property name="maven.settings.xml" value="${maven.settings.xml}" />
<properties />
</ant>
15 years, 12 months
Seam SVN: r9674 - trunk/src/main/org/jboss/seam/contexts.
by seam-commits@lists.jboss.org
Author: youngm
Date: 2008-11-28 02:44:23 -0500 (Fri, 28 Nov 2008)
New Revision: 9674
Modified:
trunk/src/main/org/jboss/seam/contexts/ServerConversationContext.java
Log:
JBSEAM-3655 not caching @PerNestedConversation components
Modified: trunk/src/main/org/jboss/seam/contexts/ServerConversationContext.java
===================================================================
--- trunk/src/main/org/jboss/seam/contexts/ServerConversationContext.java 2008-11-27 19:50:43 UTC (rev 9673)
+++ trunk/src/main/org/jboss/seam/contexts/ServerConversationContext.java 2008-11-28 07:44:23 UTC (rev 9674)
@@ -87,7 +87,13 @@
{
if (!cache.containsKey(name))
{
- cache.put(name, resolveValue(name));
+ Object value = resolveValue(name);
+ //Don't cache the value of components that have @PerNestedConverstion
+ if(isPerNestedConversation(name))
+ {
+ return value;
+ }
+ cache.put(name, value);
}
return cache.get(name);
}
15 years, 12 months
Seam SVN: r9673 - in trunk/examples: seampay and 1 other directory.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2008-11-27 14:50:43 -0500 (Thu, 27 Nov 2008)
New Revision: 9673
Modified:
trunk/examples/quartz/build.xml
trunk/examples/seampay/build.xml
Log:
JBSEAM-3756
Modified: trunk/examples/quartz/build.xml
===================================================================
--- trunk/examples/quartz/build.xml 2008-11-27 07:02:25 UTC (rev 9672)
+++ trunk/examples/quartz/build.xml 2008-11-27 19:50:43 UTC (rev 9673)
@@ -18,5 +18,23 @@
<exclude name="import.sql" />
<exclude name="seam.quartz.properties" />
</patternset>
+
+ <fileset id="validate.resources" dir="${validate.resources.dir}">
+ <include name="**/META-INF/application.xml" />
+ <include name="**/META-INF/ejb-jar.xml" />
+ <include name="**/META-INF/persistence.xml" />
+ <include name="**/META-INF/jboss-app.xml" />
+ <include name="**/META-INF/orm.xml" />
+ <!--<include name="**/WEB-INF/components.xml" />-->
+ <include name="**/WEB-INF/pages.xml" />
+ <include name="**/WEB-INF/faces-config.xml" />
+ <include name="**/WEB-INF/web.xml" />
+ <include name="**/WEB-INF/jboss-web.xml" />
+ <include name="**/${example.ds}" />
+ <include name="**/hibernate.cfg.xml" />
+ <include name="**/*.jpdl.xml" />
+ <exclude name="**/.gpd.*.jpdl.xml" />
+ </fileset>
+
</project>
Modified: trunk/examples/seampay/build.xml
===================================================================
--- trunk/examples/seampay/build.xml 2008-11-27 07:02:25 UTC (rev 9672)
+++ trunk/examples/seampay/build.xml 2008-11-27 19:50:43 UTC (rev 9673)
@@ -12,5 +12,23 @@
<property name="richfaces.lib" value="yes"/>
<import file="../build.xml"/>
+
+ <fileset id="validate.resources" dir="${validate.resources.dir}">
+ <include name="**/META-INF/application.xml" />
+ <include name="**/META-INF/ejb-jar.xml" />
+ <include name="**/META-INF/persistence.xml" />
+ <include name="**/META-INF/jboss-app.xml" />
+ <include name="**/META-INF/orm.xml" />
+ <!--<include name="**/WEB-INF/components.xml" />-->
+ <include name="**/WEB-INF/pages.xml" />
+ <include name="**/WEB-INF/faces-config.xml" />
+ <include name="**/WEB-INF/web.xml" />
+ <include name="**/WEB-INF/jboss-web.xml" />
+ <include name="**/${example.ds}" />
+ <include name="**/hibernate.cfg.xml" />
+ <include name="**/*.jpdl.xml" />
+ <exclude name="**/.gpd.*.jpdl.xml" />
+ </fileset>
+
</project>
15 years, 12 months
Seam SVN: r9672 - trunk/examples/wiki/src/test/org/jboss/seam/wiki/test.
by seam-commits@lists.jboss.org
Author: christian.bauer(a)jboss.com
Date: 2008-11-27 02:02:25 -0500 (Thu, 27 Nov 2008)
New Revision: 9672
Modified:
trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/WikiBaseData.dbunit.xml
Log:
Default skin for dev deployment
Modified: trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/WikiBaseData.dbunit.xml
===================================================================
--- trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/WikiBaseData.dbunit.xml 2008-11-27 06:46:07 UTC (rev 9671)
+++ trunk/examples/wiki/src/test/org/jboss/seam/wiki/test/WikiBaseData.dbunit.xml 2008-11-27 07:02:25 UTC (rev 9672)
@@ -4,7 +4,7 @@
<PREFERENCE PREF_ID = "1" OBJ_VERSION = "0" USER_ID = "[NULL]" ENTITY_NAME = "Wiki" PROPERTY_NAME = "baseUrl" STRING_VALUE = "http://localhost:8080/wiki" LONG_VALUE = "[NULL]" BOOLEAN_VALUE = "[NULL]"/>
<PREFERENCE PREF_ID = "2" OBJ_VERSION = "0" USER_ID = "[NULL]" ENTITY_NAME = "Wiki" PROPERTY_NAME = "timeZone" STRING_VALUE = "CET" LONG_VALUE = "[NULL]" BOOLEAN_VALUE = "[NULL]"/>
- <PREFERENCE PREF_ID = "3" OBJ_VERSION = "0" USER_ID = "[NULL]" ENTITY_NAME = "Wiki" PROPERTY_NAME = "themeName" STRING_VALUE = "openremote" LONG_VALUE = "[NULL]" BOOLEAN_VALUE = "[NULL]"/>
+ <PREFERENCE PREF_ID = "3" OBJ_VERSION = "0" USER_ID = "[NULL]" ENTITY_NAME = "Wiki" PROPERTY_NAME = "themeName" STRING_VALUE = "default" LONG_VALUE = "[NULL]" BOOLEAN_VALUE = "[NULL]"/>
<PREFERENCE PREF_ID = "4" OBJ_VERSION = "0" USER_ID = "[NULL]" ENTITY_NAME = "Wiki" PROPERTY_NAME = "memberArea" STRING_VALUE = "Members" LONG_VALUE = "[NULL]" BOOLEAN_VALUE = "[NULL]"/>
<PREFERENCE PREF_ID = "5" OBJ_VERSION = "0" USER_ID = "[NULL]" ENTITY_NAME = "Wiki" PROPERTY_NAME = "helpArea" STRING_VALUE = "Help" LONG_VALUE = "[NULL]" BOOLEAN_VALUE = "[NULL]"/>
<PREFERENCE PREF_ID = "6" OBJ_VERSION = "0" USER_ID = "[NULL]" ENTITY_NAME = "Wiki" PROPERTY_NAME = "defaultDocumentId" STRING_VALUE = "[NULL]" LONG_VALUE = "6" BOOLEAN_VALUE = "[NULL]"/>
15 years, 12 months
Seam SVN: r9670 - trunk/src/main/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-11-27 01:39:58 -0500 (Thu, 27 Nov 2008)
New Revision: 9670
Modified:
trunk/src/main/org/jboss/seam/pages-2.1.xsd
Log:
oops, extra backslash
Modified: trunk/src/main/org/jboss/seam/pages-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/pages-2.1.xsd 2008-11-27 06:30:58 UTC (rev 9669)
+++ trunk/src/main/org/jboss/seam/pages-2.1.xsd 2008-11-27 06:39:58 UTC (rev 9670)
@@ -476,7 +476,7 @@
<xs:simpleType name="outcome">
<xs:restriction base="xs:string">
- <xs:pattern value="[^\#\{\}]+"/>
+ <xs:pattern value="[^#\{\}]+"/>
</xs:restriction>
</xs:simpleType>
15 years, 12 months
Seam SVN: r9669 - trunk/seam-gen.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-11-27 01:30:58 -0500 (Thu, 27 Nov 2008)
New Revision: 9669
Modified:
trunk/seam-gen/build.xml
Log:
change references to JBoss to JBoss AS
add reexplode target
add notes about hbm2ddl selections
Modified: trunk/seam-gen/build.xml
===================================================================
--- trunk/seam-gen/build.xml 2008-11-27 06:23:33 UTC (rev 9668)
+++ trunk/seam-gen/build.xml 2008-11-27 06:30:58 UTC (rev 9669)
@@ -69,13 +69,15 @@
<packageDirectory property="test.dir" package="test/${test.package}"/>
<pathFilename property="driver.file" path="${driver.jar}"/>
+ <!-- we don't want create because that will destroy their database on the next deploy -->
<condition property="hibernate.hbm2ddl.auto" value="update">
<and>
<equals arg1="${database.exists}" arg2="n"/>
<equals arg1="${database.drop}" arg2="n"/>
</and>
</condition>
- <condition property="hibernate.hbm2ddl.auto" value="none">
+ <!-- note that update causes duplicate foreign keys to be created because of a Hibernate bug -->
+ <condition property="hibernate.hbm2ddl.auto" value="update">
<and>
<equals arg1="${database.exists}" arg2="y"/>
<equals arg1="${database.drop}" arg2="n"/>
@@ -193,7 +195,7 @@
<property name="old.jboss.home" value="C:/Program Files/jboss-4.2.3.GA"/>
<input addproperty="jboss.home.new"
- message="Enter your JBoss home directory [${old.jboss.home}]"
+ message="Enter your JBoss AS home directory [${old.jboss.home}]"
defaultvalue="${old.jboss.home}"/>
<pathFixer property="jboss.home.new"/>
@@ -462,7 +464,7 @@
<entry key="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/> <!-- yuck! -->
</propertyfile>
- <echo message="Installing JDBC driver jar to JBoss server"/>
+ <echo message="Installing JDBC driver jar to JBoss AS"/>
<copy file="${driver.jar.new}" todir="${jboss.home.new}/server/default/lib"/>
<echo message="Type '${seam.cmd} create-project' to create the new project"/>
@@ -608,7 +610,7 @@
<exclude name="ajax4jsf*.jar" if="icefaces.property"/>
<exclude name="richfaces*.jar" if="icefaces.property"/>
<exclude name="jboss-container.jar"/>
- <exclude name="jboss-seam-wicket.jar"/>
+ <exclude name="jboss-seam-wicket*.jar"/>
<exclude name="jboss-seam-resteasy.jar"/>
<exclude name="test/jboss-deplyers.jar"/>
<exclude name="test/jboss-embedded-api.jar"/>
@@ -937,7 +939,11 @@
<fileset dir="../lib">
<include name="jboss-seam.jar"/>
<include name="jboss-seam-*.jar"/>
+ <exclude name="jboss-seam-resteasy.jar"/>
+ <exclude name="jboss-seam-wicket*.jar"/>
<include name="src/jboss-seam-*.jar"/>
+ <exclude name="src/jboss-seam-resteasy-sources.jar"/>
+ <exclude name="src/jboss-seam-wicket-sources.jar"/>
</fileset>
</copy>
</target>
@@ -1260,7 +1266,7 @@
</target>
<target name="deploy" depends="validate-project" description="Deploy the EAR or WAR">
- <echo message="Deploying project '${project.name}' to JBoss"/>
+ <echo message="Deploying project '${project.name}' to JBoss AS"/>
<ant antfile="${project.home}/build.xml" target="deploy" inheritall="false"/>
</target>
@@ -1272,10 +1278,16 @@
<target name="explode" depends="validate-project"
description="Deploy the project as an exploded directory">
- <echo message="Deploying project '${project.name}' to JBoss as an exploded directory"/>
+ <echo message="Deploying project '${project.name}' to JBoss AS as an exploded directory"/>
<ant antfile="${project.home}/build.xml" target="explode" inheritall="false"/>
</target>
+ <target name="reexplode" depends="validate-project"
+ description="Clean, undeploy and deploy the project as an exploded directory">
+ <echo message="Cleaning, undeploying and deploying project '${project.name}' to JBoss AS as an exploded directory"/>
+ <ant antfile="${project.home}/build.xml" target="reexplode" inheritall="false"/>
+ </target>
+
<target name="restart" depends="validate-project" description="Restart the exploded directory">
<echo message="Restarting project '${project.name}'"/>
<ant antfile="${project.home}/build.xml" target="restart" inheritall="false"/>
@@ -1304,7 +1316,7 @@
<target name="settings" depends="validate-project"
description="Print the settings">
<echo message="Java project workspace: ${workspace.home}"/>
- <echo message="JBoss home: ${jboss.home}"/>
+ <echo message="JBoss AS home: ${jboss.home}"/>
<echo message="IceFaces: ${icefaces}"/>
<echo message="Project name: ${project.name}"/>
<echo message="Project type: ${project.type}"/>
15 years, 12 months
Seam SVN: r9668 - in trunk: src/main/org/jboss/seam and 5 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-11-27 01:23:33 -0500 (Thu, 27 Nov 2008)
New Revision: 9668
Added:
trunk/src/test/unit/org/jboss/seam/test/unit/web/IdentityRequestWrapperTest.java
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Security.xml
trunk/src/main/org/jboss/seam/core-2.1.xsd
trunk/src/main/org/jboss/seam/core/Init.java
trunk/src/main/org/jboss/seam/mock/MockHttpServletRequest.java
trunk/src/main/org/jboss/seam/mock/MockHttpSession.java
trunk/src/main/org/jboss/seam/web/IdentityRequestWrapper.java
trunk/src/test/unit/org/jboss/seam/test/unit/testng.xml
Log:
JBSEAM-3629
Modified: trunk/doc/Seam_Reference_Guide/en-US/Security.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-11-27 05:48:13 UTC (rev 9667)
+++ trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-11-27 06:23:33 UTC (rev 9668)
@@ -57,9 +57,11 @@
<title>Disabling Security</title>
<para>
- In some situations it may be necessary to disable Seam Security, for example during unit tests. This can be done by
- calling the static method <literal>Identity.setSecurityEnabled(false)</literal> to disable security checks. Doing this
- prevents any security checks being performed for the following:
+ In some situations it may be necessary to disable Seam Security, for instances during unit tests or because you
+ are using a different approach to security, such as native JAAS. Simply call the static method
+ <literal>Identity.setSecurityEnabled(false)</literal> to disable the security infrastructure. Of course, it's not
+ very convenient to have to call a static method when you want to configure the application, so as an alternative
+ you can control this setting in components.xml:
</para>
<itemizedlist>
@@ -75,7 +77,18 @@
<listitem>
<para>Page restrictions</para>
</listitem>
+ <listitem>
+ <para>Servlet API security integration</para>
+ </listitem>
</itemizedlist>
+
+ <para>
+ Assuming you are planning to take advantage of what Seam Security has to offer, the rest of this chapter documents
+ the plethora of options you have for giving your user an identity in the eyes of the security model
+ (authentication) and locking down the application by establishing constraints (authorization). Let's begin with
+ the task of authentication since that's the foundation of any security model.
+ </para>
+
</sect1>
<sect1>
Modified: trunk/src/main/org/jboss/seam/core/Init.java
===================================================================
--- trunk/src/main/org/jboss/seam/core/Init.java 2008-11-27 05:48:13 UTC (rev 9667)
+++ trunk/src/main/org/jboss/seam/core/Init.java 2008-11-27 06:23:33 UTC (rev 9668)
@@ -33,6 +33,7 @@
import org.jboss.seam.log.Logging;
import org.jboss.seam.persistence.EntityManagerProxyInterceptor;
import org.jboss.seam.persistence.HibernateSessionProxyInterceptor;
+import org.jboss.seam.security.Identity;
import org.jboss.seam.security.SecurityInterceptor;
import org.jboss.seam.transaction.RollbackInterceptor;
import org.jboss.seam.transaction.TransactionInterceptor;
@@ -572,6 +573,16 @@
this.transactionManagementEnabled = transactionManagementEnabled;
}
+ public boolean isSecurityEnabled()
+ {
+ return Identity.isSecurityEnabled();
+ }
+
+ public void setSecurityEnabled(boolean securityEnabled)
+ {
+ Identity.setSecurityEnabled(securityEnabled);
+ }
+
public Collection<Namespace> getGlobalImports()
{
return globalImports;
Modified: trunk/src/main/org/jboss/seam/core-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/core-2.1.xsd 2008-11-27 05:48:13 UTC (rev 9667)
+++ trunk/src/main/org/jboss/seam/core-2.1.xsd 2008-11-27 06:23:33 UTC (rev 9668)
@@ -46,6 +46,7 @@
<xs:attributeGroup name="attlist.init">
<xs:attribute name="debug" type="components:boolean" />
<xs:attribute name="jndi-pattern" type="components:string" />
+ <xs:attribute name="security-enabled" type="components:boolean" />
<xs:attribute name="transaction-management-enabled" type="components:boolean"/>
<xs:attribute name="user-transaction-name" type="components:string"/>
</xs:attributeGroup>
Modified: trunk/src/main/org/jboss/seam/mock/MockHttpServletRequest.java
===================================================================
--- trunk/src/main/org/jboss/seam/mock/MockHttpServletRequest.java 2008-11-27 05:48:13 UTC (rev 9667)
+++ trunk/src/main/org/jboss/seam/mock/MockHttpServletRequest.java 2008-11-27 06:23:33 UTC (rev 9668)
@@ -143,8 +143,7 @@
public String getRemoteUser()
{
- //TODO
- return null;
+ return principalName;
}
public boolean isUserInRole(String role)
Modified: trunk/src/main/org/jboss/seam/mock/MockHttpSession.java
===================================================================
--- trunk/src/main/org/jboss/seam/mock/MockHttpSession.java 2008-11-27 05:48:13 UTC (rev 9667)
+++ trunk/src/main/org/jboss/seam/mock/MockHttpSession.java 2008-11-27 06:23:33 UTC (rev 9668)
@@ -29,6 +29,8 @@
private boolean isInvalid;
private ServletContext servletContext;
+ public MockHttpSession() {}
+
public MockHttpSession(ServletContext servletContext)
{
this.servletContext = servletContext;
Modified: trunk/src/main/org/jboss/seam/web/IdentityRequestWrapper.java
===================================================================
--- trunk/src/main/org/jboss/seam/web/IdentityRequestWrapper.java 2008-11-27 05:48:13 UTC (rev 9667)
+++ trunk/src/main/org/jboss/seam/web/IdentityRequestWrapper.java 2008-11-27 06:23:33 UTC (rev 9668)
@@ -14,7 +14,7 @@
*
* @author Dan Allen
*/
-class IdentityRequestWrapper extends HttpServletRequestWrapper {
+public class IdentityRequestWrapper extends HttpServletRequestWrapper {
private Identity identity;
@@ -32,11 +32,16 @@
@Override
public Principal getUserPrincipal()
{
- return Identity.isSecurityEnabled() && identity != null ? identity.getPrincipal() : null;
+ return seamSecurityIsActive() ? identity.getPrincipal() : super.getUserPrincipal();
}
@Override
public boolean isUserInRole(String role) {
- return getUserPrincipal() != null && identity != null ? identity.hasRole(role) : false;
+ return seamSecurityIsActive() ? identity.hasRole(role) : super.isUserInRole(role);
}
+
+ private boolean seamSecurityIsActive()
+ {
+ return Identity.isSecurityEnabled() && identity != null;
+ }
}
Modified: trunk/src/test/unit/org/jboss/seam/test/unit/testng.xml
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/testng.xml 2008-11-27 05:48:13 UTC (rev 9667)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/testng.xml 2008-11-27 06:23:33 UTC (rev 9668)
@@ -61,6 +61,7 @@
<test name="Seam Unit Tests: Filters">
<classes>
<class name="org.jboss.seam.test.unit.web.MultipartRequestTest" />
+ <class name="org.jboss.seam.test.unit.web.IdentityRequestWrapperTest" />
</classes>
</test>
Added: trunk/src/test/unit/org/jboss/seam/test/unit/web/IdentityRequestWrapperTest.java
===================================================================
--- trunk/src/test/unit/org/jboss/seam/test/unit/web/IdentityRequestWrapperTest.java (rev 0)
+++ trunk/src/test/unit/org/jboss/seam/test/unit/web/IdentityRequestWrapperTest.java 2008-11-27 06:23:33 UTC (rev 9668)
@@ -0,0 +1,69 @@
+package org.jboss.seam.test.unit.web;
+
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.HashSet;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.jboss.seam.Seam;
+import org.jboss.seam.mock.MockHttpServletRequest;
+import org.jboss.seam.mock.MockHttpSession;
+import org.jboss.seam.security.Identity;
+import org.jboss.seam.security.SimplePrincipal;
+import org.jboss.seam.web.IdentityRequestWrapper;
+import org.testng.annotations.Test;
+
+public class IdentityRequestWrapperTest
+{
+ private static final String JAAS_USER = "jaasUser";
+
+ private static final String JAAS_ROLE = "jaasRole";
+
+ private static final String SEAM_USER = "seamUser";
+
+ private static final String SEAM_ROLE = "seamRole";
+
+ @Test
+ public void testWithSeamSecurityEnabled()
+ {
+ HttpServletRequest request = initializeWrappedRequest();
+ assert request.getUserPrincipal() != null && request.getUserPrincipal().getName().equals(SEAM_USER);
+ assert request.getRemoteUser() != null && request.getRemoteUser().equals(SEAM_USER);
+ assert request.isUserInRole(SEAM_ROLE);
+ }
+
+ @Test
+ public void testWithSeamSecurityDisabled()
+ {
+ HttpServletRequest request = initializeWrappedRequest();
+ Identity.setSecurityEnabled(false);
+ assert request.getUserPrincipal() != null && request.getUserPrincipal().getName().equals(JAAS_USER);
+ assert request.getRemoteUser() != null && request.getRemoteUser().equals(JAAS_USER);
+ assert request.isUserInRole(JAAS_ROLE);
+ }
+
+ public HttpServletRequest initializeWrappedRequest() {
+ HttpSession session = new MockHttpSession();
+ Identity identity = new Identity() {
+
+ @Override
+ public Principal getPrincipal()
+ {
+ return new SimplePrincipal(SEAM_USER);
+ }
+
+ @Override
+ public boolean hasRole(String role)
+ {
+ return SEAM_ROLE.equals(role);
+ }
+
+ };
+ session.setAttribute(Seam.getComponentName(Identity.class), identity);
+ HttpServletRequest request = new MockHttpServletRequest(session, JAAS_USER, new HashSet<String>(Arrays.asList(JAAS_ROLE)), null, "GET");
+ return new IdentityRequestWrapper(request);
+ }
+
+}
15 years, 12 months
Seam SVN: r9667 - trunk/doc/Seam_Reference_Guide/en-US.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-11-27 00:48:13 -0500 (Thu, 27 Nov 2008)
New Revision: 9667
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Security.xml
Log:
fix validation errors in XML document
Modified: trunk/doc/Seam_Reference_Guide/en-US/Security.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-11-26 20:49:02 UTC (rev 9666)
+++ trunk/doc/Seam_Reference_Guide/en-US/Security.xml 2008-11-27 05:48:13 UTC (rev 9667)
@@ -91,8 +91,10 @@
<title>Configuring an Authenticator component</title>
<note>
- If you use Seam's Identity Management features (discussed later in this chapter) then it is not necessary to create
- an authenticator component (and you can skip this section).
+ <para>
+ If you use Seam's Identity Management features (discussed later in this chapter) then it is not necessary to create
+ an authenticator component (and you can skip this section).
+ </para>
</note>
<para>
@@ -3220,7 +3222,6 @@
A <literal>ResolverChain</literal> contains an ordered list of <literal>PermissionResolver</literal>s, for the
purpose of resolving object permissions for a particular object class or permission target.
</para>
- </sect3>
<para>
The following sequence diagram shows the interaction between the components of the permission framework during a
@@ -3274,6 +3275,7 @@
</para>
</listitem>
</itemizedlist>
+ </sect3>
</sect2>
@@ -4994,9 +4996,11 @@
}]]></programlisting>
<warning>
- Note that an <literal>Identity</literal> component must be marked <literal>@Startup</literal>, so
- that it is available immediately after the <literal>SESSION</literal> context begins.
- Failing to do this may render certain Seam functionality inoperable in your application.
+ <para>
+ Note that an <literal>Identity</literal> component must be marked <literal>@Startup</literal>, so that it is
+ available immediately after the <literal>SESSION</literal> context begins. Failing to do this may render
+ certain Seam functionality inoperable in your application.
+ </para>
</warning>
15 years, 12 months