Seam SVN: r7855 - branches/Seam_2_0/doc/Seam_Reference_Guide.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2008-04-08 04:27:13 -0400 (Tue, 08 Apr 2008)
New Revision: 7855
Added:
branches/Seam_2_0/doc/Seam_Reference_Guide/en-US/
Removed:
branches/Seam_2_0/doc/Seam_Reference_Guide/en/
Log:
move en to en-US
Copied: branches/Seam_2_0/doc/Seam_Reference_Guide/en-US (from rev 7853, branches/Seam_2_0/doc/Seam_Reference_Guide/en)
16 years, 7 months
Seam SVN: r7852 - in branches/Seam_2_0/examples/seamspace: view and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-04-07 21:21:49 -0400 (Mon, 07 Apr 2008)
New Revision: 7852
Modified:
branches/Seam_2_0/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java
branches/Seam_2_0/examples/seamspace/view/register.xhtml
Log:
JBSEAM-2846
Modified: branches/Seam_2_0/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java
===================================================================
--- branches/Seam_2_0/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java 2008-04-08 01:10:55 UTC (rev 7851)
+++ branches/Seam_2_0/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java 2008-04-08 01:21:49 UTC (rev 7852)
@@ -32,7 +32,7 @@
@In
private Identity identity;
-
+
/**
* Password confirmation
*/
Modified: branches/Seam_2_0/examples/seamspace/view/register.xhtml
===================================================================
--- branches/Seam_2_0/examples/seamspace/view/register.xhtml 2008-04-08 01:10:55 UTC (rev 7851)
+++ branches/Seam_2_0/examples/seamspace/view/register.xhtml 2008-04-08 01:21:49 UTC (rev 7852)
@@ -48,7 +48,7 @@
<div class="formRow">
<h:outputLabel for="username">Username<em>*</em></h:outputLabel>
- <h:inputText id="username" value="#{register.username}" required="true"/>
+ <h:inputText id="username" value="#{newMember.username}" required="true"/>
<div class="validationError"><h:message for="username"/></div>
</div>
@@ -77,7 +77,7 @@
<h:outputLabel for="dob">Date of birth<em>*</em></h:outputLabel>
<!-- TODO Add in start and end of range -->
<!-- TODO Change image -->
- <rich:calendar id="dob" value="#{newMember.dob}" required="true" datePattern="MM/dd/yyyy" buttonIcon="images/ellipses.png" />
+ <rich:calendar id="dob" value="#{newMember.dob}" required="true" datePattern="MM/dd/yyyy" buttonIcon="images/ellipsis.png" />
<div class="validationError"><h:message for="dob"/></div>
</div>
16 years, 7 months
Seam SVN: r7851 - in trunk/examples/contactlist: view and 1 other directory.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-04-07 21:10:55 -0400 (Mon, 07 Apr 2008)
New Revision: 7851
Modified:
trunk/examples/contactlist/resources/WEB-INF/pages.xml
trunk/examples/contactlist/view/search.xhtml
Log:
JBSEAM-2845
Modified: trunk/examples/contactlist/resources/WEB-INF/pages.xml
===================================================================
--- trunk/examples/contactlist/resources/WEB-INF/pages.xml 2008-04-08 01:10:32 UTC (rev 7850)
+++ trunk/examples/contactlist/resources/WEB-INF/pages.xml 2008-04-08 01:10:55 UTC (rev 7851)
@@ -49,6 +49,14 @@
<param name="firstResult"
value="#{contacts.firstResult}"/>
+
+ <navigation>
+ <rule if-outcome="newsearch">
+ <redirect view-id="/search.xhtml">
+ <param name="firstResult" value="0"/>
+ </redirect>
+ </rule>
+ </navigation>
</page>
<exception class="javax.persistence.PersistenceException">
Modified: trunk/examples/contactlist/view/search.xhtml
===================================================================
--- trunk/examples/contactlist/view/search.xhtml 2008-04-08 01:10:32 UTC (rev 7850)
+++ trunk/examples/contactlist/view/search.xhtml 2008-04-08 01:10:55 UTC (rev 7851)
@@ -12,7 +12,12 @@
<body>
<div class="menuButtons">
- <s:link view="/search.xhtml" value="Search Contacts"/>
+ <s:link view="/search.xhtml" value="Search Contacts">
+ <f:param name="firstName" />
+ <f:param name="lastName" />
+ <f:param name="firstResult" />
+ </s:link>
+
<s:link view="/editContact.xhtml" value="Create New Contact">
<f:param name="contactId"/> <!-- suppress propagation of contact id page parameter -->
</s:link>
@@ -35,7 +40,9 @@
<span class="name">Last Name :</span>
<span class="value"><h:inputText value="#{exampleContact.lastName}"/></span>
</span>
- <h:commandButton value="Search" action="/search.xhtml"/>
+
+
+ <h:commandButton value="Search" action="newsearch"/>
</h:form>
</div>
16 years, 7 months
Seam SVN: r7850 - in trunk/examples/seamspace/resources: WEB-INF and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-04-07 21:10:32 -0400 (Mon, 07 Apr 2008)
New Revision: 7850
Modified:
trunk/examples/seamspace/resources/META-INF/security-rules.drl
trunk/examples/seamspace/resources/WEB-INF/pages.xml
Log:
fix user registration, broken security rule
Modified: trunk/examples/seamspace/resources/META-INF/security-rules.drl
===================================================================
--- trunk/examples/seamspace/resources/META-INF/security-rules.drl 2008-04-08 01:09:57 UTC (rev 7849)
+++ trunk/examples/seamspace/resources/META-INF/security-rules.drl 2008-04-08 01:10:32 UTC (rev 7850)
@@ -71,8 +71,8 @@
activation-group "permissions"
when
mbr: Member()
- acct: MemberAccount(member == mbr)
- check: PermissionCheck(target == mbr, action == "createBlog", granted == false)
+ acct: MemberAccount(member.memberId == mbr.memberId)
+ check: PermissionCheck(target.memberId == mbr.memberId, action == "createBlog", granted == false)
then
check.grant();
end
Modified: trunk/examples/seamspace/resources/WEB-INF/pages.xml
===================================================================
--- trunk/examples/seamspace/resources/WEB-INF/pages.xml 2008-04-08 01:09:57 UTC (rev 7849)
+++ trunk/examples/seamspace/resources/WEB-INF/pages.xml 2008-04-08 01:10:32 UTC (rev 7850)
@@ -40,7 +40,9 @@
<page view-id="/register2.xhtml">
<navigation from-action="#{register.uploadPicture}">
- <redirect view-id="/profile.xhtml"/>
+ <redirect view-id="/profile.xhtml">
+ <param name="name" value="#{newMember.memberName}"/>
+ </redirect>
</navigation>
</page>
16 years, 7 months
Seam SVN: r7849 - trunk/src/main/org/jboss/seam/security/management.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-04-07 21:09:57 -0400 (Mon, 07 Apr 2008)
New Revision: 7849
Modified:
trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
Log:
fix password hashing
Modified: trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-04-07 23:55:47 UTC (rev 7848)
+++ trunk/src/main/org/jboss/seam/security/management/JpaIdentityStore.java 2008-04-08 01:09:57 UTC (rev 7849)
@@ -69,13 +69,13 @@
private Field propertyField;
private Method propertyGetter;
private Method propertySetter;
- private Class<? extends Annotation> annotation;
+ private Annotation annotation;
private String name;
private Class propertyClass;
private boolean isFieldProperty;
- public BeanProperty(Field propertyField, Class<? extends Annotation> annotation)
+ public BeanProperty(Field propertyField, Annotation annotation)
{
this.propertyField = propertyField;
isFieldProperty = true;
@@ -84,7 +84,7 @@
this.propertyClass = propertyField.getDeclaringClass();
}
- public BeanProperty(Method propertyMethod, Class<? extends Annotation> annotation)
+ public BeanProperty(Method propertyMethod, Annotation annotation)
{
if (!(propertyMethod.getName().startsWith("get") || (propertyMethod.getName().startsWith("is"))))
{
@@ -188,7 +188,7 @@
}
}
- public Class<? extends Annotation> getAnnotation()
+ public Annotation getAnnotation()
{
return annotation;
}
@@ -213,8 +213,6 @@
private BeanProperty roleNameProperty;
private BeanProperty roleGroupsProperty;
- private String passwordHash;
-
public Set<Feature> getFeatures()
{
return featureSet.getFeatures();
@@ -300,12 +298,18 @@
{
for (Field f : cls.getFields())
{
- if (f.isAnnotationPresent(annotation)) return new BeanProperty(f, annotation);
+ if (f.isAnnotationPresent(annotation))
+ {
+ return new BeanProperty(f, f.getAnnotation(annotation));
+ }
}
for (Method m : cls.getMethods())
{
- if (m.isAnnotationPresent(annotation)) return new BeanProperty(m, annotation);
+ if (m.isAnnotationPresent(annotation))
+ {
+ return new BeanProperty(m, m.getAnnotation(annotation));
+ }
}
return null;
@@ -337,11 +341,8 @@
if (userEnabledProperty != null) userEnabledProperty.setValue(user, false);
}
else
- {
- String passwordValue = passwordHash == null ? password :
- PasswordHash.instance().generateSaltedHash(password, getUserAccountSalt(user));
-
- userPasswordProperty.setValue(user, passwordValue);
+ {
+ userPasswordProperty.setValue(user, generatePasswordHash(password, getUserAccountSalt(user)));
if (userEnabledProperty != null) userEnabledProperty.setValue(user, true);
}
@@ -451,6 +452,8 @@
public boolean addRoleToGroup(String role, String group)
{
+ if (roleGroupsProperty == null) return false;
+
Object targetRole = lookupRole(role);
if (targetRole == null)
{
@@ -463,43 +466,53 @@
throw new NoSuchRoleException("Could not grant role, group '" + group + "' does not exist");
}
- if (roleGroupsProperty != null)
+
+ Collection roleGroups = (Collection) roleGroupsProperty.getValue(targetRole);
+ if (roleGroups == null)
{
- Collection roleGroups = (Collection) roleGroupsProperty.getValue(targetRole);
- if (roleGroups == null)
+ // This should either be a Set, or a List...
+ if (Set.class.isAssignableFrom(roleGroupsProperty.getPropertyClass()))
{
- // This should either be a Set, or a List...
- if (Set.class.isAssignableFrom(roleGroupsProperty.getPropertyClass()))
- {
- roleGroups = new HashSet();
- }
- else if (List.class.isAssignableFrom(roleGroupsProperty.getPropertyClass()))
- {
- roleGroups = new ArrayList();
- }
-
- roleGroupsProperty.setValue(targetRole, roleGroups);
+ roleGroups = new HashSet();
}
- else if (((Collection) roleGroupsProperty.getValue(targetRole)).contains(targetGroup))
+ else if (List.class.isAssignableFrom(roleGroupsProperty.getPropertyClass()))
{
- return false;
+ roleGroups = new ArrayList();
}
-
- ((Collection) roleGroupsProperty.getValue(targetRole)).add(targetGroup);
- mergeEntity(targetRole);
- return true;
+ roleGroupsProperty.setValue(targetRole, roleGroups);
}
- else
+ else if (((Collection) roleGroupsProperty.getValue(targetRole)).contains(targetGroup))
{
return false;
}
+
+ ((Collection) roleGroupsProperty.getValue(targetRole)).add(targetGroup);
+ mergeEntity(targetRole);
+
+ return true;
}
public boolean removeRoleFromGroup(String role, String group)
{
- // TODO Auto-generated method stub
- return false;
+ if (roleGroupsProperty == null) return false;
+
+ Object roleToRemove = lookupRole(role);
+ if (role == null)
+ {
+ throw new NoSuchUserException("Could not remove role from group, no such role '" + role + "'");
+ }
+
+ Object targetGroup = lookupRole(group);
+ if (targetGroup == null)
+ {
+ throw new NoSuchRoleException("Could not remove role from group, no such group '" + group + "'");
+ }
+
+ boolean success = ((Collection) roleGroupsProperty.getValue(roleToRemove)).remove(targetGroup);
+
+ if (success) mergeEntity(roleToRemove);
+ return success;
}
public boolean createRole(String role)
@@ -606,7 +619,7 @@
throw new NoSuchUserException("Could not change password, user '" + username + "' does not exist");
}
- userPasswordProperty.setValue(user, PasswordHash.instance().generateSaltedHash(password, getUserAccountSalt(user)));
+ userPasswordProperty.setValue(user, generatePasswordHash(password, getUserAccountSalt(user)));
mergeEntity(user);
return true;
}
@@ -715,6 +728,38 @@
}
}
+ private String generatePasswordHash(String password, String salt)
+ {
+ String algorithm = ((UserPassword) userPasswordProperty.getAnnotation()).hash();
+
+ if (algorithm == null || "".equals(algorithm))
+ {
+ if (salt == null || "".equals(salt))
+ {
+ return PasswordHash.instance().generateHash(password);
+ }
+ else
+ {
+ return PasswordHash.instance().generateSaltedHash(password, salt);
+ }
+ }
+ else if ("none".equals(algorithm))
+ {
+ return password;
+ }
+ else
+ {
+ if (salt == null || "".equals(salt))
+ {
+ return PasswordHash.instance().generateHash(password, algorithm);
+ }
+ else
+ {
+ return PasswordHash.instance().generateSaltedHash(password, salt, algorithm);
+ }
+ }
+ }
+
public boolean authenticate(String username, String password)
{
Object user = lookupUser(username);
@@ -723,7 +768,7 @@
return false;
}
- String passwordHash = PasswordHash.instance().generateSaltedHash(password, getUserAccountSalt(user));
+ String passwordHash = generatePasswordHash(password, getUserAccountSalt(user));
boolean success = passwordHash.equals(userPasswordProperty.getValue(user));
if (success && Events.exists())
16 years, 7 months
Seam SVN: r7848 - in branches/Seam_2_0/examples/contactlist: view and 1 other directory.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-04-07 19:55:47 -0400 (Mon, 07 Apr 2008)
New Revision: 7848
Modified:
branches/Seam_2_0/examples/contactlist/resources/WEB-INF/pages.xml
branches/Seam_2_0/examples/contactlist/view/search.xhtml
Log:
JBSEAM-2845
Modified: branches/Seam_2_0/examples/contactlist/resources/WEB-INF/pages.xml
===================================================================
--- branches/Seam_2_0/examples/contactlist/resources/WEB-INF/pages.xml 2008-04-07 23:19:20 UTC (rev 7847)
+++ branches/Seam_2_0/examples/contactlist/resources/WEB-INF/pages.xml 2008-04-07 23:55:47 UTC (rev 7848)
@@ -49,6 +49,14 @@
<param name="firstResult"
value="#{contacts.firstResult}"/>
+
+ <navigation>
+ <rule if-outcome="newsearch">
+ <redirect view-id="/search.xhtml">
+ <param name="firstResult" value="0"/>
+ </redirect>
+ </rule>
+ </navigation>
</page>
<exception class="javax.persistence.PersistenceException">
Modified: branches/Seam_2_0/examples/contactlist/view/search.xhtml
===================================================================
--- branches/Seam_2_0/examples/contactlist/view/search.xhtml 2008-04-07 23:19:20 UTC (rev 7847)
+++ branches/Seam_2_0/examples/contactlist/view/search.xhtml 2008-04-07 23:55:47 UTC (rev 7848)
@@ -12,7 +12,12 @@
<body>
<div class="menuButtons">
- <s:link view="/search.xhtml" value="Search Contacts"/>
+ <s:link view="/search.xhtml" value="Search Contacts">
+ <f:param name="firstName" />
+ <f:param name="lastName" />
+ <f:param name="firstResult" />
+ </s:link>
+
<s:link view="/editContact.xhtml" value="Create New Contact">
<f:param name="contactId"/> <!-- suppress propagation of contact id page parameter -->
</s:link>
@@ -35,7 +40,9 @@
<span class="name">Last Name :</span>
<span class="value"><h:inputText value="#{exampleContact.lastName}"/></span>
</span>
- <h:commandButton value="Search" action="/search.xhtml"/>
+
+
+ <h:commandButton value="Search" action="newsearch"/>
</h:form>
</div>
16 years, 7 months
Seam SVN: r7847 - trunk/src/remoting/org/jboss/seam/remoting/wrapper.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-04-07 19:19:20 -0400 (Mon, 07 Apr 2008)
New Revision: 7847
Modified:
trunk/src/remoting/org/jboss/seam/remoting/wrapper/NumberWrapper.java
Log:
JBSEAM-2858
Modified: trunk/src/remoting/org/jboss/seam/remoting/wrapper/NumberWrapper.java
===================================================================
--- trunk/src/remoting/org/jboss/seam/remoting/wrapper/NumberWrapper.java 2008-04-07 23:19:07 UTC (rev 7846)
+++ trunk/src/remoting/org/jboss/seam/remoting/wrapper/NumberWrapper.java 2008-04-07 23:19:20 UTC (rev 7847)
@@ -11,76 +11,109 @@
*/
public class NumberWrapper extends BaseWrapper implements Wrapper
{
- private static final byte[] NUMBER_TAG_OPEN = "<number>".getBytes();
- private static final byte[] NUMBER_TAG_CLOSE = "</number>".getBytes();
+ private static final byte[] NUMBER_TAG_OPEN = "<number>".getBytes();
+ private static final byte[] NUMBER_TAG_CLOSE = "</number>".getBytes();
- public Object convert(Type type)
- throws ConversionException
- {
- String val = element.getStringValue().trim();
+ public Object convert(Type type) throws ConversionException
+ {
+ String val = element.getStringValue().trim();
- if (type.equals(Short.class))
- value = !"".equals(val) ? Short.valueOf(val) : null;
- else if (type.equals(Short.TYPE))
- value = Short.parseShort(val);
- else if (type.equals(Integer.class))
- value = !"".equals(val) ? Integer.valueOf(val) : null;
- else if (type.equals(Integer.TYPE))
- value = Integer.parseInt(val);
- else if (type.equals(Long.class) || type.equals(Object.class))
- value = !"".equals(val) ? Long.valueOf(val) : null;
- else if (type.equals(Long.TYPE))
- value = Long.parseLong(val);
- else if (type.equals(Float.class))
- value = !"".equals(val) ? Float.valueOf(val) : null;
- else if (type.equals(Float.TYPE))
- value = Float.parseFloat(val);
- else if (type.equals(Double.class))
- value = !"".equals(val) ? Double.valueOf(val) : null;
- else if (type.equals(Double.TYPE))
- value = Double.parseDouble(val);
- else if (type.equals(Byte.class))
- value = !"".equals(val) ? Byte.valueOf(val) : null;
- else if (type.equals(Byte.TYPE))
- value = Byte.parseByte(val);
+ if (type.equals(Short.class))
+ {
+ value = !"".equals(val) ? Short.valueOf(val) : null;
+ }
+ else if (type.equals(Short.TYPE))
+ {
+ value = Short.parseShort(val);
+ }
+ else if (type.equals(Integer.class))
+ {
+ value = !"".equals(val) ? Integer.valueOf(val) : null;
+ }
+ else if (type.equals(Integer.TYPE))
+ {
+ value = Integer.parseInt(val);
+ }
+ else if (type.equals(Long.class) || type.equals(Object.class))
+ {
+ value = !"".equals(val) ? Long.valueOf(val) : null;
+ }
+ else if (type.equals(Long.TYPE))
+ {
+ value = Long.parseLong(val);
+ }
+ else if (type.equals(Float.class))
+ {
+ value = !"".equals(val) ? Float.valueOf(val) : null;
+ }
+ else if (type.equals(Float.TYPE))
+ {
+ value = Float.parseFloat(val);
+ }
+ else if (type.equals(Double.class))
+ {
+ value = !"".equals(val) ? Double.valueOf(val) : null;
+ }
+ else if (type.equals(Double.TYPE))
+ {
+ value = Double.parseDouble(val);
+ }
+ else if (type.equals(Byte.class))
+ {
+ value = !"".equals(val) ? Byte.valueOf(val) : null;
+ }
+ else if (type.equals(Byte.TYPE))
+ {
+ value = Byte.parseByte(val);
+ }
+ else if (type.equals(String.class))
+ {
+ value = val;
+ }
+ else
+ {
+ throw new ConversionException(String.format("Value [%s] cannot be converted to type [%s].",
+ element.getStringValue(), type));
+ }
- else if (type.equals(String.class))
- value = val;
- else
- throw new ConversionException(String.format(
- "Value [%s] cannot be converted to type [%s].", element.getStringValue(),
- type));
+ return value;
+ }
- return value;
- }
+ /**
+ *
+ * @param out OutputStream
+ * @throws IOException
+ */
+ public void marshal(OutputStream out) throws IOException
+ {
+ out.write(NUMBER_TAG_OPEN);
+ out.write(value.toString().getBytes());
+ out.write(NUMBER_TAG_CLOSE);
+ }
- /**
- *
- * @param out OutputStream
- * @throws IOException
- */
- public void marshal(OutputStream out)
- throws IOException
- {
- out.write(NUMBER_TAG_OPEN);
- out.write(value.toString().getBytes());
- out.write(NUMBER_TAG_CLOSE);
- }
+ /**
+ * Allow conversions to either Integer or String.
+ *
+ * @param cls Class
+ * @return ConversionScore
+ */
+ public ConversionScore conversionScore(Class cls)
+ {
+ if (cls.equals(Integer.class) || cls.equals(Integer.TYPE) ||
+ cls.equals(Long.class) || cls.equals(Long.TYPE) ||
+ cls.equals(Short.class) || cls.equals(Short.TYPE) ||
+ cls.equals(Double.class) || cls.equals(Double.TYPE) ||
+ cls.equals(Float.class) || cls.equals(Float.TYPE) ||
+ cls.equals(Byte.class) || cls.equals(Byte.TYPE))
+ {
+ return ConversionScore.exact;
+ }
- /**
- * Allow conversions to either Integer or String.
- *
- * @param cls Class
- * @return ConversionScore
- */
- public ConversionScore conversionScore(Class cls)
- {
- if (cls.equals(Integer.class) || cls.equals(Integer.TYPE))
- return ConversionScore.exact;
+ if (cls.equals(String.class) || cls.equals(Object.class))
+ {
+ return ConversionScore.compatible;
+ }
- if (cls.equals(String.class) || cls.equals(Object.class))
- return ConversionScore.compatible;
-
- return ConversionScore.nomatch;
- }
+ return ConversionScore.nomatch;
+ }
}
16 years, 7 months
Seam SVN: r7846 - branches/Seam_2_0/src/remoting/org/jboss/seam/remoting/wrapper.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-04-07 19:19:07 -0400 (Mon, 07 Apr 2008)
New Revision: 7846
Modified:
branches/Seam_2_0/src/remoting/org/jboss/seam/remoting/wrapper/NumberWrapper.java
Log:
JBSEAM-2858
Modified: branches/Seam_2_0/src/remoting/org/jboss/seam/remoting/wrapper/NumberWrapper.java
===================================================================
--- branches/Seam_2_0/src/remoting/org/jboss/seam/remoting/wrapper/NumberWrapper.java 2008-04-07 23:13:41 UTC (rev 7845)
+++ branches/Seam_2_0/src/remoting/org/jboss/seam/remoting/wrapper/NumberWrapper.java 2008-04-07 23:19:07 UTC (rev 7846)
@@ -11,76 +11,109 @@
*/
public class NumberWrapper extends BaseWrapper implements Wrapper
{
- private static final byte[] NUMBER_TAG_OPEN = "<number>".getBytes();
- private static final byte[] NUMBER_TAG_CLOSE = "</number>".getBytes();
+ private static final byte[] NUMBER_TAG_OPEN = "<number>".getBytes();
+ private static final byte[] NUMBER_TAG_CLOSE = "</number>".getBytes();
- public Object convert(Type type)
- throws ConversionException
- {
- String val = element.getStringValue().trim();
+ public Object convert(Type type) throws ConversionException
+ {
+ String val = element.getStringValue().trim();
- if (type.equals(Short.class))
- value = !"".equals(val) ? Short.valueOf(val) : null;
- else if (type.equals(Short.TYPE))
- value = Short.parseShort(val);
- else if (type.equals(Integer.class))
- value = !"".equals(val) ? Integer.valueOf(val) : null;
- else if (type.equals(Integer.TYPE))
- value = Integer.parseInt(val);
- else if (type.equals(Long.class) || type.equals(Object.class))
- value = !"".equals(val) ? Long.valueOf(val) : null;
- else if (type.equals(Long.TYPE))
- value = Long.parseLong(val);
- else if (type.equals(Float.class))
- value = !"".equals(val) ? Float.valueOf(val) : null;
- else if (type.equals(Float.TYPE))
- value = Float.parseFloat(val);
- else if (type.equals(Double.class))
- value = !"".equals(val) ? Double.valueOf(val) : null;
- else if (type.equals(Double.TYPE))
- value = Double.parseDouble(val);
- else if (type.equals(Byte.class))
- value = !"".equals(val) ? Byte.valueOf(val) : null;
- else if (type.equals(Byte.TYPE))
- value = Byte.parseByte(val);
+ if (type.equals(Short.class))
+ {
+ value = !"".equals(val) ? Short.valueOf(val) : null;
+ }
+ else if (type.equals(Short.TYPE))
+ {
+ value = Short.parseShort(val);
+ }
+ else if (type.equals(Integer.class))
+ {
+ value = !"".equals(val) ? Integer.valueOf(val) : null;
+ }
+ else if (type.equals(Integer.TYPE))
+ {
+ value = Integer.parseInt(val);
+ }
+ else if (type.equals(Long.class) || type.equals(Object.class))
+ {
+ value = !"".equals(val) ? Long.valueOf(val) : null;
+ }
+ else if (type.equals(Long.TYPE))
+ {
+ value = Long.parseLong(val);
+ }
+ else if (type.equals(Float.class))
+ {
+ value = !"".equals(val) ? Float.valueOf(val) : null;
+ }
+ else if (type.equals(Float.TYPE))
+ {
+ value = Float.parseFloat(val);
+ }
+ else if (type.equals(Double.class))
+ {
+ value = !"".equals(val) ? Double.valueOf(val) : null;
+ }
+ else if (type.equals(Double.TYPE))
+ {
+ value = Double.parseDouble(val);
+ }
+ else if (type.equals(Byte.class))
+ {
+ value = !"".equals(val) ? Byte.valueOf(val) : null;
+ }
+ else if (type.equals(Byte.TYPE))
+ {
+ value = Byte.parseByte(val);
+ }
+ else if (type.equals(String.class))
+ {
+ value = val;
+ }
+ else
+ {
+ throw new ConversionException(String.format("Value [%s] cannot be converted to type [%s].",
+ element.getStringValue(), type));
+ }
- else if (type.equals(String.class))
- value = val;
- else
- throw new ConversionException(String.format(
- "Value [%s] cannot be converted to type [%s].", element.getStringValue(),
- type));
+ return value;
+ }
- return value;
- }
+ /**
+ *
+ * @param out OutputStream
+ * @throws IOException
+ */
+ public void marshal(OutputStream out) throws IOException
+ {
+ out.write(NUMBER_TAG_OPEN);
+ out.write(value.toString().getBytes());
+ out.write(NUMBER_TAG_CLOSE);
+ }
- /**
- *
- * @param out OutputStream
- * @throws IOException
- */
- public void marshal(OutputStream out)
- throws IOException
- {
- out.write(NUMBER_TAG_OPEN);
- out.write(value.toString().getBytes());
- out.write(NUMBER_TAG_CLOSE);
- }
+ /**
+ * Allow conversions to either Integer or String.
+ *
+ * @param cls Class
+ * @return ConversionScore
+ */
+ public ConversionScore conversionScore(Class cls)
+ {
+ if (cls.equals(Integer.class) || cls.equals(Integer.TYPE) ||
+ cls.equals(Long.class) || cls.equals(Long.TYPE) ||
+ cls.equals(Short.class) || cls.equals(Short.TYPE) ||
+ cls.equals(Double.class) || cls.equals(Double.TYPE) ||
+ cls.equals(Float.class) || cls.equals(Float.TYPE) ||
+ cls.equals(Byte.class) || cls.equals(Byte.TYPE))
+ {
+ return ConversionScore.exact;
+ }
- /**
- * Allow conversions to either Integer or String.
- *
- * @param cls Class
- * @return ConversionScore
- */
- public ConversionScore conversionScore(Class cls)
- {
- if (cls.equals(Integer.class) || cls.equals(Integer.TYPE))
- return ConversionScore.exact;
+ if (cls.equals(String.class) || cls.equals(Object.class))
+ {
+ return ConversionScore.compatible;
+ }
- if (cls.equals(String.class) || cls.equals(Object.class))
- return ConversionScore.compatible;
-
- return ConversionScore.nomatch;
- }
+ return ConversionScore.nomatch;
+ }
}
16 years, 7 months
Seam SVN: r7845 - branches/Seam_2_0/examples/dvdstore/resources/WEB-INF.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2008-04-07 19:13:41 -0400 (Mon, 07 Apr 2008)
New Revision: 7845
Modified:
branches/Seam_2_0/examples/dvdstore/resources/WEB-INF/pages.xml
Log:
JBSEAM-2850
Modified: branches/Seam_2_0/examples/dvdstore/resources/WEB-INF/pages.xml
===================================================================
--- branches/Seam_2_0/examples/dvdstore/resources/WEB-INF/pages.xml 2008-04-07 23:12:21 UTC (rev 7844)
+++ branches/Seam_2_0/examples/dvdstore/resources/WEB-INF/pages.xml 2008-04-07 23:13:41 UTC (rev 7845)
@@ -2,7 +2,7 @@
<pages xmlns="http://jboss.com/products/seam/pages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/pages http://jboss.com/products/seam/pages-2.0.xsd">
-
+
<page view-id="/dvd.xhtml"
action="#{search.selectFromRequest}">
@@ -82,4 +82,9 @@
</redirect>
</exception>
+ <exception class="javax.faces.application.ViewExpiredException">
+ <redirect view-id="/home.xhtml">
+ <message>The page you tried to access is no longer available.</message>
+ </redirect>
+ </exception>
</pages>
16 years, 7 months