[jboss-cvs] jboss-seam/src/main/org/jboss/seam/faces ...
Gavin King
gavin.king at jboss.com
Tue Jun 19 16:08:13 EDT 2007
User: gavin
Date: 07/06/19 16:08:13
Modified: src/main/org/jboss/seam/faces
FacesContext.java FacesMessages.java FacesPage.java
HttpError.java IsUserInRole.java Navigator.java
Redirect.java Switcher.java UiComponent.java
UserPrincipal.java
Added: src/main/org/jboss/seam/faces
BusinessProcess.java DataModels.java
FacesExpressions.java FacesManager.java
Parameters.java
Removed: src/main/org/jboss/seam/faces
JsfBusinessProcess.java JsfExpressions.java
JsfManager.java JsfParameters.java JsfProvider.java
Log:
more repackaging
Revision Changes Path
1.2 +2 -2 jboss-seam/src/main/org/jboss/seam/faces/FacesContext.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FacesContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/FacesContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- FacesContext.java 19 Jun 2007 19:12:44 -0000 1.1
+++ FacesContext.java 19 Jun 2007 20:08:12 -0000 1.2
@@ -1,4 +1,4 @@
-//$Id: FacesContext.java,v 1.1 2007/06/19 19:12:44 gavin Exp $
+//$Id: FacesContext.java,v 1.2 2007/06/19 20:08:12 gavin Exp $
package org.jboss.seam.faces;
import static org.jboss.seam.InterceptionType.NEVER;
@@ -18,7 +18,7 @@
*/
@Scope(ScopeType.APPLICATION)
@Intercept(NEVER)
- at Name("org.jboss.seam.core.facesContext")
+ at Name("org.jboss.seam.faces.facesContext")
@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
public class FacesContext
{
1.3 +1 -1 jboss-seam/src/main/org/jboss/seam/faces/FacesMessages.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FacesMessages.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/FacesMessages.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- FacesMessages.java 19 Jun 2007 19:41:44 -0000 1.2
+++ FacesMessages.java 19 Jun 2007 20:08:12 -0000 1.3
@@ -34,7 +34,7 @@
* @author Gavin King
*/
@Scope(ScopeType.CONVERSATION)
- at Name("org.jboss.seam.core.facesMessages")
+ at Name("org.jboss.seam.faces.facesMessages")
@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
@Intercept(NEVER)
public class FacesMessages implements Serializable
1.2 +1 -1 jboss-seam/src/main/org/jboss/seam/faces/FacesPage.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: FacesPage.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/FacesPage.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- FacesPage.java 19 Jun 2007 19:12:44 -0000 1.1
+++ FacesPage.java 19 Jun 2007 20:08:12 -0000 1.2
@@ -25,7 +25,7 @@
* @author Gavin King
*
*/
- at Name("org.jboss.seam.core.facesPage")
+ at Name("org.jboss.seam.faces.facesPage")
@Intercept(InterceptionType.NEVER)
@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
@Scope(ScopeType.PAGE)
1.2 +2 -2 jboss-seam/src/main/org/jboss/seam/faces/HttpError.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: HttpError.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/HttpError.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- HttpError.java 19 Jun 2007 19:12:44 -0000 1.1
+++ HttpError.java 19 Jun 2007 20:08:12 -0000 1.2
@@ -1,4 +1,4 @@
-//$Id: HttpError.java,v 1.1 2007/06/19 19:12:44 gavin Exp $
+//$Id: HttpError.java,v 1.2 2007/06/19 20:08:12 gavin Exp $
package org.jboss.seam.faces;
import static org.jboss.seam.InterceptionType.NEVER;
@@ -24,7 +24,7 @@
*/
@Scope(ScopeType.APPLICATION)
@Intercept(NEVER)
- at Name("org.jboss.seam.core.httpError")
+ at Name("org.jboss.seam.faces.httpError")
@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
public class HttpError
{
1.2 +12 -43 jboss-seam/src/main/org/jboss/seam/faces/IsUserInRole.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: IsUserInRole.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/IsUserInRole.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- IsUserInRole.java 19 Jun 2007 19:12:44 -0000 1.1
+++ IsUserInRole.java 19 Jun 2007 20:08:12 -0000 1.2
@@ -1,23 +1,15 @@
package org.jboss.seam.faces;
import static org.jboss.seam.InterceptionType.NEVER;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
-
-import java.util.AbstractMap;
-import java.util.Map;
-import java.util.Set;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
import javax.faces.context.FacesContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Unwrap;
-import org.jboss.seam.web.ServletContexts;
/**
* Manager component for a map of roles assigned
@@ -28,42 +20,19 @@
*/
@Scope(ScopeType.APPLICATION)
@Intercept(NEVER)
- at Name("org.jboss.seam.core.isUserInRole")
- at Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
-public class IsUserInRole
+ at Name("org.jboss.seam.web.isUserInRole")
+ at Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
+public class IsUserInRole extends org.jboss.seam.web.IsUserInRole
{
- @Unwrap
- public Map<String, Boolean> getMap()
- {
- return new AbstractMap<String, Boolean>()
- {
@Override
- public Set<Map.Entry<String, Boolean>> entrySet() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Boolean get(Object key)
+ protected Boolean isUserInRole(String role)
{
- if ( !(key instanceof String ) ) return false;
-
- String role = (String) key;
-
FacesContext facesContext = FacesContext.getCurrentInstance();
if ( facesContext != null )
{
return facesContext.getExternalContext().isUserInRole(role);
}
- ServletRequest servletRequest = ServletContexts.instance().getRequest();
- if ( servletRequest != null )
- {
- return ( (HttpServletRequest) servletRequest ).isUserInRole(role);
- }
-
- return null;
- }
-
- };
+ return super.isUserInRole(role);
}
}
1.2 +1 -1 jboss-seam/src/main/org/jboss/seam/faces/Navigator.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Navigator.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/Navigator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Navigator.java 19 Jun 2007 19:12:44 -0000 1.1
+++ Navigator.java 19 Jun 2007 20:08:12 -0000 1.2
@@ -43,7 +43,7 @@
viewId = Pages.getCurrentViewId();
}
if ( log.isDebugEnabled() ) log.debug("redirecting to: " + viewId);
- JsfManager.instance().redirect(viewId, parameters, true);
+ FacesManager.instance().redirect(viewId, parameters, true);
}
/**
1.2 +2 -2 jboss-seam/src/main/org/jboss/seam/faces/Redirect.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Redirect.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/Redirect.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Redirect.java 19 Jun 2007 19:12:44 -0000 1.1
+++ Redirect.java 19 Jun 2007 20:08:12 -0000 1.2
@@ -27,7 +27,7 @@
*
* @author Gavin King
*/
- at Name("org.jboss.seam.core.redirect")
+ at Name("org.jboss.seam.faces.redirect")
@Intercept(InterceptionType.NEVER)
@Scope(ScopeType.CONVERSATION)
@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
@@ -137,7 +137,7 @@
*/
public void execute()
{
- JsfManager.instance().redirect(viewId, parameters, conversationPropagationEnabled);
+ FacesManager.instance().redirect(viewId, parameters, conversationPropagationEnabled);
}
/**
1.2 +1 -1 jboss-seam/src/main/org/jboss/seam/faces/Switcher.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Switcher.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/Switcher.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Switcher.java 19 Jun 2007 19:12:44 -0000 1.1
+++ Switcher.java 19 Jun 2007 20:08:12 -0000 1.2
@@ -29,7 +29,7 @@
* @author Gavin King
*/
@Scope(ScopeType.PAGE)
- at Name("org.jboss.seam.core.switcher")
+ at Name("org.jboss.seam.faces.switcher")
@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
@Intercept(NEVER)
public class Switcher implements Serializable
1.2 +1 -1 jboss-seam/src/main/org/jboss/seam/faces/UiComponent.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UiComponent.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/UiComponent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- UiComponent.java 19 Jun 2007 19:12:44 -0000 1.1
+++ UiComponent.java 19 Jun 2007 20:08:12 -0000 1.2
@@ -17,7 +17,7 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Unwrap;
- at Name("org.jboss.seam.core.uiComponent")
+ at Name("org.jboss.seam.faces.uiComponent")
@Intercept(NEVER)
@Scope(STATELESS)
@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
1.2 +6 -15 jboss-seam/src/main/org/jboss/seam/faces/UserPrincipal.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UserPrincipal.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/faces/UserPrincipal.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- UserPrincipal.java 19 Jun 2007 19:12:44 -0000 1.1
+++ UserPrincipal.java 19 Jun 2007 20:08:12 -0000 1.2
@@ -1,13 +1,11 @@
package org.jboss.seam.faces;
import static org.jboss.seam.InterceptionType.NEVER;
-import static org.jboss.seam.annotations.Install.BUILT_IN;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
import java.security.Principal;
import javax.faces.context.FacesContext;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
@@ -17,7 +15,6 @@
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Unwrap;
import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.web.ServletContexts;
/**
* Manager component for the current user Principal
@@ -27,11 +24,11 @@
*/
@Scope(ScopeType.APPLICATION)
@Intercept(NEVER)
- at Name("org.jboss.seam.core.userPrincipal")
- at Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
-public class UserPrincipal
+ at Name("org.jboss.seam.web.userPrincipal")
+ at Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
+public class UserPrincipal extends org.jboss.seam.web.UserPrincipal
{
- @Unwrap
+ @Unwrap @Override
public Principal getUserPrincipal()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
@@ -40,13 +37,7 @@
return facesContext.getExternalContext().getUserPrincipal();
}
- ServletRequest servletRequest = ServletContexts.instance().getRequest();
- if ( servletRequest != null )
- {
- return ( (HttpServletRequest) servletRequest ).getUserPrincipal();
- }
-
- return null;
+ return super.getUserPrincipal();
}
public static Principal instance()
1.1 date: 2007/06/19 20:08:12; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/faces/BusinessProcess.java
Index: BusinessProcess.java
===================================================================
package org.jboss.seam.faces;
import static org.jboss.seam.InterceptionType.NEVER;
import static org.jboss.seam.annotations.Install.FRAMEWORK;
import javax.faces.application.FacesMessage;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
/**
* Holds the task and process ids for the current conversation,
* and provides programmatic control over the business process.
*
* @author Gavin King
*
*/
@Scope(ScopeType.CONVERSATION)
@Name("org.jboss.seam.core.businessProcess")
@Intercept(NEVER)
@Install(dependencies="org.jboss.seam.core.jbpm", precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
public class BusinessProcess extends org.jboss.seam.bpm.BusinessProcess
{
@Override
protected void taskNotFound(Long taskId)
{
FacesMessages.instance().addFromResourceBundleOrDefault(
FacesMessage.SEVERITY_WARN,
"org.jboss.seam.TaskNotFound",
"Task #0 not found",
taskId
);
}
@Override
protected void taskEnded(Long taskId)
{
FacesMessages.instance().addFromResourceBundleOrDefault(
FacesMessage.SEVERITY_WARN,
"org.jboss.seam.TaskEnded",
"Task #0 already ended",
taskId
);
}
@Override
protected void processEnded(Long processId)
{
FacesMessages.instance().addFromResourceBundleOrDefault(
FacesMessage.SEVERITY_WARN,
"org.jboss.seam.ProcessEnded",
"Process #0 already ended",
processId
);
}
@Override
protected void processNotFound(Long processId)
{
FacesMessages.instance().addFromResourceBundleOrDefault(
FacesMessage.SEVERITY_WARN,
"org.jboss.seam.ProcessNotFound",
"Process #0 not found",
processId
);
}
@Override
protected void processEnded(String key)
{
FacesMessages.instance().addFromResourceBundleOrDefault(
FacesMessage.SEVERITY_WARN,
"org.jboss.seam.ProcessEnded",
"Process #0 already ended",
key
);
}
@Override
protected void processNotFound(String key)
{
FacesMessages.instance().addFromResourceBundleOrDefault(
FacesMessage.SEVERITY_WARN,
"org.jboss.seam.ProcessNotFound",
"Process #0 not found",
key
);
}
}
1.1 date: 2007/06/19 20:08:12; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/faces/DataModels.java
Index: DataModels.java
===================================================================
package org.jboss.seam.faces;
import static org.jboss.seam.InterceptionType.NEVER;
import static org.jboss.seam.ScopeType.STATELESS;
import static org.jboss.seam.annotations.Install.BUILT_IN;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.faces.model.DataModel;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.framework.Query;
import org.jboss.seam.jsf.ArrayDataModel;
import org.jboss.seam.jsf.ListDataModel;
import org.jboss.seam.jsf.MapDataModel;
import org.jboss.seam.jsf.SetDataModel;
@Name("org.jboss.seam.faces.dataModels")
@Install(precedence=BUILT_IN, classDependencies="javax.faces.context.FacesContext")
@Scope(STATELESS)
@Intercept(NEVER)
public class DataModels
{
public DataModel getDataModel(Object value)
{
if (value instanceof List)
{
return new ListDataModel( (List) value );
}
else if (value instanceof Object[])
{
return new ArrayDataModel( (Object[]) value );
}
else if (value instanceof Map)
{
return new MapDataModel( (Map) value );
}
else if (value instanceof Set)
{
return new SetDataModel( (Set) value );
}
else
{
throw new IllegalArgumentException("unknown collection type: " + value.getClass());
}
}
public DataModel getDataModel(Query query)
{
return getDataModel( query.getResultList() );
}
public static DataModels instance()
{
return (DataModels) Component.getInstance(DataModels.class, ScopeType.STATELESS);
}
}
1.1 date: 2007/06/19 20:08:12; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/faces/FacesExpressions.java
Index: FacesExpressions.java
===================================================================
//$Id: FacesExpressions.java,v 1.1 2007/06/19 20:08:12 gavin Exp $
package org.jboss.seam.faces;
import static org.jboss.seam.InterceptionType.NEVER;
import static org.jboss.seam.annotations.Install.FRAMEWORK;
import static org.jboss.seam.el.EL.EL_CONTEXT;
import javax.el.ELContext;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.validator.ValidatorException;
import org.hibernate.validator.InvalidValue;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.core.Expressions;
/**
* Factory for method and value bindings
*
* @author Gavin King
*/
@Scope(ScopeType.APPLICATION)
@Intercept(NEVER)
@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
@Name("org.jboss.seam.core.expressions")
public class FacesExpressions extends Expressions
{
/**
* Get an appropriate ELContext. If there is an active JSF request,
* use JSF's ELContext. Otherwise, use one that we created.
*/
@Override
public ELContext getELContext()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
return facesContext==null ? EL_CONTEXT : facesContext.getELContext();
}
/**
* Validate that a value can be assigned to the property
* identified by a value expression.
*
* @param propertyExpression a value expression
* @param value the value that is to be assigned
*
* @throws ValidatorException is validation fails
*/
public void validate(String propertyExpression, Object value)
{
InvalidValue[] ivs;
try
{
ivs = getInvalidValues(propertyExpression, value );
}
catch (Exception e)
{
throw new ValidatorException( new FacesMessage(FacesMessage.SEVERITY_ERROR, "model validation failed:" + e.getMessage(), null), e );
}
if ( ivs.length>0 )
{
throw new ValidatorException( FacesMessages.createFacesMessage( FacesMessage.SEVERITY_ERROR, ivs[0].getMessage() ) );
}
}
@Override
protected boolean isFacesContextActive()
{
return FacesContext.getCurrentInstance()==null;
}
public static FacesExpressions instance()
{
return (FacesExpressions) Expressions.instance();
}
}
1.1 date: 2007/06/19 20:08:12; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/faces/FacesManager.java
Index: FacesManager.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.seam.faces;
import static org.jboss.seam.InterceptionType.NEVER;
import static org.jboss.seam.annotations.Install.FRAMEWORK;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.contexts.Lifecycle;
import org.jboss.seam.core.Conversation;
import org.jboss.seam.core.Init;
import org.jboss.seam.core.Interpolator;
import org.jboss.seam.core.Manager;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.navigation.ConversationIdParameter;
import org.jboss.seam.navigation.Pageflow;
import org.jboss.seam.navigation.Pages;
import org.jboss.seam.util.JSF;
/**
* The Seam conversation manager.
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
*/
@Scope(ScopeType.EVENT)
@Name("org.jboss.seam.core.manager")
@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
@Intercept(NEVER)
public class FacesManager extends Manager
{
private static final LogProvider log = Logging.getLogProvider(FacesManager.class);
private boolean controllingRedirect;
/**
* Temporarily promote a temporary conversation to
* a long running conversation for the duration of
* a browser redirect. After the redirect, the
* conversation will be demoted back to a temporary
* conversation. Handle any changes to the conversation
* id, due to propagation via natural id.
*/
public void beforeRedirect(String viewId)
{
beforeRedirect();
FacesContext facesContext = FacesContext.getCurrentInstance();
String currentViewId = Pages.getViewId(facesContext);
if ( viewId!=null && currentViewId!=null )
{
ConversationIdParameter currentPage = Pages.instance().getPage(currentViewId).getConversationIdParameter();
ConversationIdParameter targetPage = Pages.instance().getPage(viewId).getConversationIdParameter();
if ( isDifferentConversationId(currentPage, targetPage) )
{
updateCurrentConversationId( targetPage.getConversationId() );
}
}
}
public void interpolateAndRedirect(String url)
{
Map<String, Object> parameters = new HashMap<String, Object>();
int loc = url.indexOf('?');
if (loc>0)
{
StringTokenizer tokens = new StringTokenizer( url.substring(loc), "?=&" );
while ( tokens.hasMoreTokens() )
{
String name = tokens.nextToken();
String value = Interpolator.instance().interpolate( tokens.nextToken() );
parameters.put(name, value);
}
url = url.substring(0, loc);
}
redirect(url, parameters, true);
}
/**
* Redirect to the given view id, encoding the conversation id
* into the request URL.
*
* @param viewId the JSF view id
*/
@Override
public void redirect(String viewId)
{
redirect(viewId, null, true);
}
@Override
protected void storeConversationToViewRootIfNecessary()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
if ( facesContext!=null && Lifecycle.getPhaseId()==JSF.RENDER_RESPONSE )
{
FacesPage.instance().storeConversation();
}
}
@Override
protected String generateInitialConversationId()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
String viewId = Pages.getViewId(facesContext);
if ( viewId!=null )
{
return Pages.instance().getPage(viewId)
.getConversationIdParameter()
.getInitialConversationId( facesContext.getExternalContext().getRequestParameterMap() );
}
else
{
return super.generateInitialConversationId();
}
}
/**
* Redirect to the given view id, after encoding parameters and conversation
* id into the request URL.
*
* @param viewId the JSF view id
* @param parameters request parameters to be encoded (possibly null)
* @param includeConversationId determines if the conversation id is to be encoded
*/
public void redirect(String viewId, Map<String, Object> parameters,
boolean includeConversationId)
{
/*if ( Lifecycle.getPhaseId()==PhaseId.RENDER_RESPONSE )
{
throw new IllegalStateException("attempted to redirect during RENDER_RESPONSE phase");
}*/
FacesContext context = FacesContext.getCurrentInstance();
String url = context.getApplication().getViewHandler().getActionURL(context, viewId);
if (parameters!=null)
{
url = encodeParameters(url, parameters);
}
url = Pages.instance().encodePageParameters(
FacesContext.getCurrentInstance(),
url,
viewId,
parameters==null ? Collections.EMPTY_SET : parameters.keySet()
);
if (includeConversationId)
{
beforeRedirect(viewId);
url = encodeConversationId(url, viewId);
}
redirect(viewId, context, url);
}
/**
* Redirect to the given view id, after encoding the given conversation
* id into the request URL.
*
* @param viewId the JSF view id
* @param conversationId an id of a long-running conversation
*/
@Override
public void redirect(String viewId, String conversationId)
{
FacesContext context = FacesContext.getCurrentInstance();
String url = context.getApplication().getViewHandler().getActionURL(context, viewId);
url = encodeConversationId(url, viewId, conversationId);
redirect(viewId, context, url);
}
private void redirect(String viewId, FacesContext context, String url)
{
url = Pages.instance().encodeScheme(viewId, context, url);
if ( log.isDebugEnabled() )
{
log.debug("redirecting to: " + url);
}
ExternalContext externalContext = context.getExternalContext();
controllingRedirect = true;
try
{
externalContext.redirect( externalContext.encodeActionURL(url) );
}
catch (IOException ioe)
{
throw new RedirectException(ioe);
}
finally
{
controllingRedirect = false;
}
context.responseComplete();
}
/**
* Called by the Seam Redirect Filter when a redirect is called.
* Appends the conversationId parameter if necessary.
*
* @param url the requested URL
* @return the resulting URL with the conversationId appended
*/
public String appendConversationIdFromRedirectFilter(String url, String viewId)
{
boolean appendConversationId = !controllingRedirect;
if (appendConversationId)
{
beforeRedirect(viewId);
url = encodeConversationId(url, viewId);
}
return url;
}
/**
* If a page description is defined, remember the description and
* view id for the current page, to support conversation switching.
* Called just before the render phase.
*/
public void prepareBackswitch(FacesContext facesContext)
{
Conversation conversation = Conversation.instance();
//stuff from jPDL takes precedence
org.jboss.seam.pageflow.Page pageflowPage =
Manager.instance().isLongRunningConversation() &&
Init.instance().isJbpmInstalled() &&
Pageflow.instance().isInProcess() ?
Pageflow.instance().getPage() : null;
if (pageflowPage==null)
{
//handle stuff defined in pages.xml
Pages pages = Pages.instance();
if (pages!=null) //for tests
{
String viewId = Pages.getViewId(facesContext);
org.jboss.seam.navigation.Page pageEntry = pages.getPage(viewId);
if ( pageEntry.isSwitchEnabled() )
{
conversation.setViewId(viewId);
}
if ( pageEntry.hasDescription() )
{
conversation.setDescription( pageEntry.renderDescription() );
}
conversation.setTimeout( pages.getTimeout(viewId) );
}
}
else
{
//use stuff from the pageflow definition
if ( pageflowPage.isSwitchEnabled() )
{
conversation.setViewId( Pageflow.instance().getPageViewId() );
}
if ( pageflowPage.hasDescription() )
{
conversation.setDescription( pageflowPage.getDescription() );
}
conversation.setTimeout( pageflowPage.getTimeout() );
}
flushConversationMetadata();
}
public static FacesManager instance()
{
return (FacesManager) Manager.instance();
}
}
1.1 date: 2007/06/19 20:08:12; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/faces/Parameters.java
Index: Parameters.java
===================================================================
package org.jboss.seam.faces;
import static org.jboss.seam.annotations.Install.FRAMEWORK;
import java.util.Map;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import org.jboss.seam.InterceptionType;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
@Name("org.jboss.seam.web.parameters")
@Intercept(InterceptionType.NEVER)
@Scope(ScopeType.STATELESS)
@Install(precedence=FRAMEWORK, classDependencies="javax.faces.context.FacesContext")
public class Parameters extends org.jboss.seam.web.Parameters
{
@Override
protected Object convertRequestParameter(String requestParameter, Class type)
{
if ( String.class.equals(type) ) return requestParameter;
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext==null)
{
throw new IllegalStateException("No FacesContext associated with current thread, cannot convert request parameter type");
}
else
{
Converter converter = facesContext.getApplication().createConverter(type);
if (converter==null)
{
throw new IllegalArgumentException("no converter for type: " + type);
}
UIViewRoot viewRoot = facesContext.getViewRoot();
return converter.getAsObject(
facesContext,
viewRoot==null ? new UIViewRoot() : viewRoot, //have to pass something here, or get a totally useless NPE from JSF
requestParameter );
}
}
@Override
public Map<String, String[]> getRequestParameters()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
if ( facesContext != null )
{
return facesContext.getExternalContext().getRequestParameterValuesMap();
}
return super.getRequestParameters();
}
}
More information about the jboss-cvs-commits
mailing list