You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2008/07/03 23:58:25 UTC
svn commit: r673833 [12/18] - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/component/
core/src/main/java/org/apache/myfaces/component/html/ext/
core/src/main/java/org/apache/myfaces/component/html/util/
core/src/main/java/org/apach...
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/requestParameterProvider/RequestParameterServletFilter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/requestParameterProvider/RequestParameterServletFilter.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/requestParameterProvider/RequestParameterServletFilter.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/requestParameterProvider/RequestParameterServletFilter.java Thu Jul 3 14:58:05 2008
@@ -39,8 +39,8 @@
*/
public class RequestParameterServletFilter implements Filter
{
- public final static String REQUEST_PARAM_FILTER_CALLED = RequestParameterServletFilter.class.getName() + ".CALLED";
-
+ public final static String REQUEST_PARAM_FILTER_CALLED = RequestParameterServletFilter.class.getName() + ".CALLED";
+
public RequestParameterServletFilter()
{
}
@@ -55,12 +55,12 @@
{
if(servletResponse instanceof HttpServletResponse)
{
- HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
- if (!Boolean.TRUE.equals(httpServletRequest.getAttribute(REQUEST_PARAM_FILTER_CALLED)))
- {
- httpServletRequest.setAttribute(REQUEST_PARAM_FILTER_CALLED, Boolean.TRUE);
- servletResponse = new RequestParameterResponseWrapper((HttpServletResponse) servletResponse);
- }
+ HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
+ if (!Boolean.TRUE.equals(httpServletRequest.getAttribute(REQUEST_PARAM_FILTER_CALLED)))
+ {
+ httpServletRequest.setAttribute(REQUEST_PARAM_FILTER_CALLED, Boolean.TRUE);
+ servletResponse = new RequestParameterResponseWrapper((HttpServletResponse) servletResponse);
+ }
}
filterChain.doFilter(servletRequest, servletResponse);
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/AfterScopePhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/AfterScopePhaseListener.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/AfterScopePhaseListener.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/scope/AfterScopePhaseListener.java Thu Jul 3 14:58:05 2008
@@ -32,31 +32,31 @@
*/
public class AfterScopePhaseListener implements PhaseListener {
- /**
+ /**
*
*/
private static final long serialVersionUID = 9137086632177423625L;
/**
- * we have to tackle the scope cleanup
- * at the latest stage possible
- * thus we intercept it at the last phase
- * at the after phase stage
- */
- public void afterPhase(PhaseEvent arg0) {
- ScopeHolder holder = (ScopeHolder) ScopeUtils.getManagedBean(UIScope.SCOPE_CONTAINER_KEY);
- if(holder != null)
- holder.pageRefresh();
- }
+ * we have to tackle the scope cleanup
+ * at the latest stage possible
+ * thus we intercept it at the last phase
+ * at the after phase stage
+ */
+ public void afterPhase(PhaseEvent arg0) {
+ ScopeHolder holder = (ScopeHolder) ScopeUtils.getManagedBean(UIScope.SCOPE_CONTAINER_KEY);
+ if(holder != null)
+ holder.pageRefresh();
+ }
- public void beforePhase(PhaseEvent arg0) {
- }
+ public void beforePhase(PhaseEvent arg0) {
+ }
- /**
- * last phase possible, the render responce phase
- */
- public PhaseId getPhaseId() {
- return PhaseId.RENDER_RESPONSE;
- }
+ /**
+ * last phase possible, the render responce phase
+ */
+ public PhaseId getPhaseId() {
+ return PhaseId.RENDER_RESPONSE;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/AbstractScript.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/AbstractScript.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/AbstractScript.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/AbstractScript.java Thu Jul 3 14:58:05 2008
@@ -60,6 +60,6 @@
*
* @JSFProperty
*/
- public abstract String getLanguage();
+ public abstract String getLanguage();
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/script/ScriptRenderer.java Thu Jul 3 14:58:05 2008
@@ -39,34 +39,34 @@
*/
public class ScriptRenderer extends HtmlRenderer {
- public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
- if ((context == null) || (component == null)) {
- throw new NullPointerException();
- }
- Script script = (Script) component;
- ResponseWriter writer = context.getResponseWriter();
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
+ if ((context == null) || (component == null)) {
+ throw new NullPointerException();
+ }
+ Script script = (Script) component;
+ ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.SCRIPT_ELEM, component);
- if (script.getSrc() != null)
- {
- writer.writeAttribute(HTML.SRC_ATTR, context.getApplication().getViewHandler().getResourceURL(context, script.getSrc()), null);
- }
- if (script.getType() != null)
- {
- writer.writeAttribute(HTML.TYPE_ATTR, script.getType(), null);
- }
- if (script.getLanguage() != null)
- {
- writer.writeAttribute(HTML.SCRIPT_LANGUAGE_ATTR, script.getLanguage(), null);
- }
- writer.writeText("",null);
- }
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ if (script.getSrc() != null)
+ {
+ writer.writeAttribute(HTML.SRC_ATTR, context.getApplication().getViewHandler().getResourceURL(context, script.getSrc()), null);
+ }
+ if (script.getType() != null)
+ {
+ writer.writeAttribute(HTML.TYPE_ATTR, script.getType(), null);
+ }
+ if (script.getLanguage() != null)
+ {
+ writer.writeAttribute(HTML.SCRIPT_LANGUAGE_ATTR, script.getLanguage(), null);
+ }
+ writer.writeText("",null);
+ }
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
- if ((context == null) || (component == null)) {
- throw new NullPointerException();
- }
+ if ((context == null) || (component == null)) {
+ throw new NullPointerException();
+ }
- ResponseWriter writer = context.getResponseWriter();
+ ResponseWriter writer = context.getResponseWriter();
writer.endElement(HTML.SCRIPT_ELEM);
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContext.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContext.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContext.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContext.java Thu Jul 3 14:58:05 2008
@@ -24,80 +24,80 @@
*/
public abstract class SecurityContext {
- public final static int AUTH_MODE_NONE = -1;
- public final static int AUTH_MODE_SINGLE = 0;
- public final static int AUTH_MODE_ALL = 1;
- public final static int AUTH_MODE_ANY = 2;
- public final static int AUTH_MODE_NOT = 3;
-
- private String[] roles;
- private int authMode = AUTH_MODE_NONE;
-
- public abstract String getAuthType();
-
- public abstract String getRemoteUser();
-
- public abstract boolean ifGranted(String role);
-
- boolean ifSingleGranted() {
- return ifGranted(roles[0]);
- }
-
- boolean ifAllGranted() {
- boolean isAuthorized = false;
- for (int i = 0; i < roles.length; i++) {
- String role = roles[i];
- if(ifGranted(role)) {
- isAuthorized = true;
- } else {
- isAuthorized = false;
- break;
- }
- }
- return isAuthorized;
- }
-
- boolean ifAnyGranted() {
- boolean isAuthorized = false;
- for (int i = 0; i < roles.length; i++) {
- String role = roles[i];
- if(ifGranted(role)) {
- isAuthorized = true;
- break;
- }
- }
- return isAuthorized;
- }
-
- boolean ifNotGranted() {
- boolean isAuthorized = false;
- for (int i = 0; i < roles.length; i++) {
- String role = roles[i];
- if(ifGranted(role)) {
- isAuthorized = false;
- break;
- } else {
- isAuthorized = true;
- }
- }
- return isAuthorized;
- }
-
- boolean inAuthMode() {
- return authMode != AUTH_MODE_NONE;
- }
-
- int getAuthMode() {
- return authMode;
- }
- void setAuthMode(int authMode) {
- this.authMode = authMode;
- }
+ public final static int AUTH_MODE_NONE = -1;
+ public final static int AUTH_MODE_SINGLE = 0;
+ public final static int AUTH_MODE_ALL = 1;
+ public final static int AUTH_MODE_ANY = 2;
+ public final static int AUTH_MODE_NOT = 3;
+
+ private String[] roles;
+ private int authMode = AUTH_MODE_NONE;
+
+ public abstract String getAuthType();
+
+ public abstract String getRemoteUser();
+
+ public abstract boolean ifGranted(String role);
+
+ boolean ifSingleGranted() {
+ return ifGranted(roles[0]);
+ }
+
+ boolean ifAllGranted() {
+ boolean isAuthorized = false;
+ for (int i = 0; i < roles.length; i++) {
+ String role = roles[i];
+ if(ifGranted(role)) {
+ isAuthorized = true;
+ } else {
+ isAuthorized = false;
+ break;
+ }
+ }
+ return isAuthorized;
+ }
+
+ boolean ifAnyGranted() {
+ boolean isAuthorized = false;
+ for (int i = 0; i < roles.length; i++) {
+ String role = roles[i];
+ if(ifGranted(role)) {
+ isAuthorized = true;
+ break;
+ }
+ }
+ return isAuthorized;
+ }
+
+ boolean ifNotGranted() {
+ boolean isAuthorized = false;
+ for (int i = 0; i < roles.length; i++) {
+ String role = roles[i];
+ if(ifGranted(role)) {
+ isAuthorized = false;
+ break;
+ } else {
+ isAuthorized = true;
+ }
+ }
+ return isAuthorized;
+ }
+
+ boolean inAuthMode() {
+ return authMode != AUTH_MODE_NONE;
+ }
+
+ int getAuthMode() {
+ return authMode;
+ }
+ void setAuthMode(int authMode) {
+ this.authMode = authMode;
+ }
- String[] getRoles() {
- return roles;
- }
- void setRoles(String[] roles) {
- this.roles = roles;
- }
+ String[] getRoles() {
+ return roles;
+ }
+ void setRoles(String[] roles) {
+ this.roles = roles;
+ }
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextImpl.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextImpl.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextImpl.java Thu Jul 3 14:58:05 2008
@@ -26,15 +26,15 @@
*/
public class SecurityContextImpl extends SecurityContext{
- public String getAuthType() {
- return FacesContext.getCurrentInstance().getExternalContext().getAuthType();
- }
-
- public String getRemoteUser() {
- return FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();
- }
+ public String getAuthType() {
+ return FacesContext.getCurrentInstance().getExternalContext().getAuthType();
+ }
+
+ public String getRemoteUser() {
+ return FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();
+ }
- public boolean ifGranted(String role) {
- return FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role);
- }
+ public boolean ifGranted(String role) {
+ return FacesContext.getCurrentInstance().getExternalContext().isUserInRole(role);
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolver.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolver.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolver.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextPropertyResolver.java Thu Jul 3 14:58:05 2008
@@ -30,122 +30,122 @@
* @author cagatay
*/
public class SecurityContextPropertyResolver extends PropertyResolver{
-
- private static final Log log = LogFactory.getLog(SecurityContextPropertyResolver.class);
+
+ private static final Log log = LogFactory.getLog(SecurityContextPropertyResolver.class);
- private final static String AUTH_TYPE = "authType";
- private final static String USER = "remoteUser";
- private final static String IF_GRANTED = "ifGranted";
- private final static String IF_ALL_GRANTED = "ifAllGranted";
- private final static String IF_ANY_GRANTED = "ifAnyGranted";
- private final static String IF_NOT_GRANTED = "ifNotGranted";
-
- private PropertyResolver originalResolver;
-
- public SecurityContextPropertyResolver(PropertyResolver propertyresolver) {
- originalResolver = propertyresolver;
- }
-
- public Object getValue(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
- if(base instanceof SecurityContext) {
- SecurityContext securityContext = (SecurityContext) base;
-
- if(property.equals(AUTH_TYPE)) {
- return securityContext.getAuthType();
- }
- else if(property.equals(USER))
- {
- return securityContext.getRemoteUser();
- }
- else if(property.equals(IF_GRANTED))
- {
- securityContext.setAuthMode(SecurityContext.AUTH_MODE_SINGLE);
- return securityContext;
- }
- else if(property.equals(IF_ALL_GRANTED))
- {
- securityContext.setAuthMode(SecurityContext.AUTH_MODE_ALL);
- return securityContext;
- }
- else if(property.equals(IF_ANY_GRANTED))
- {
- securityContext.setAuthMode(SecurityContext.AUTH_MODE_ANY);
- return securityContext;
- }
- else if(property.equals(IF_NOT_GRANTED))
- {
- securityContext.setAuthMode(SecurityContext.AUTH_MODE_NOT);
- return securityContext;
- }
- else if(securityContext.inAuthMode()) {
- securityContext.setRoles(getRolesFromProperty(property));
- int authMode = securityContext.getAuthMode();
-
- if(authMode == SecurityContext.AUTH_MODE_SINGLE)
- return Boolean.valueOf(securityContext.ifSingleGranted());
- else if(authMode == SecurityContext.AUTH_MODE_ALL)
- return Boolean.valueOf(securityContext.ifAllGranted());
- else if(authMode == SecurityContext.AUTH_MODE_ANY)
- return Boolean.valueOf(securityContext.ifAnyGranted());
- else
- return Boolean.valueOf(securityContext.ifNotGranted());
- }
- else {
- if(log.isDebugEnabled())
- log.debug("Exception while retrieving property; base : "+base.getClass().getName()+", property : "+property);
-
- throw new PropertyNotFoundException(getMessage(base, (String)property));
- }
- }
- else
- return originalResolver.getValue(base, property);
-
- }
-
- public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException {
- return originalResolver.getType(base, index);
- }
-
- public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
- if(base instanceof SecurityContext)
- return SecurityContext.class;
- else
- return originalResolver.getType(base, property);
- }
-
- public Object getValue(Object base, int index) throws EvaluationException, PropertyNotFoundException {
- return originalResolver.getValue(base, index);
- }
-
- public boolean isReadOnly(Object base, int index) throws EvaluationException, PropertyNotFoundException {
- return originalResolver.isReadOnly(base, index);
- }
-
- public boolean isReadOnly(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
- if(base instanceof SecurityContext)
- return true;
- else
- return originalResolver.isReadOnly(base, property);
- }
-
- public void setValue(Object base, int index, Object value) throws EvaluationException, PropertyNotFoundException {
- originalResolver.setValue(base, index, value);
- }
-
- public void setValue(Object base, Object property, Object value) throws EvaluationException, PropertyNotFoundException {
- originalResolver.setValue(base, property, value);
- }
-
- private String[] getRolesFromProperty(Object property) {
- String[] roles = ((String)property).split(",");
- for (int i = 0; i < roles.length; i++) {
- roles[i] = roles[i].trim();
- }
- return roles;
- }
-
- private static String getMessage(Object base, String name) {
- return "Bean: " + base.getClass().getName() + ", property: " + name;
- }
+ private final static String AUTH_TYPE = "authType";
+ private final static String USER = "remoteUser";
+ private final static String IF_GRANTED = "ifGranted";
+ private final static String IF_ALL_GRANTED = "ifAllGranted";
+ private final static String IF_ANY_GRANTED = "ifAnyGranted";
+ private final static String IF_NOT_GRANTED = "ifNotGranted";
+
+ private PropertyResolver originalResolver;
+
+ public SecurityContextPropertyResolver(PropertyResolver propertyresolver) {
+ originalResolver = propertyresolver;
+ }
+
+ public Object getValue(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
+ if(base instanceof SecurityContext) {
+ SecurityContext securityContext = (SecurityContext) base;
+
+ if(property.equals(AUTH_TYPE)) {
+ return securityContext.getAuthType();
+ }
+ else if(property.equals(USER))
+ {
+ return securityContext.getRemoteUser();
+ }
+ else if(property.equals(IF_GRANTED))
+ {
+ securityContext.setAuthMode(SecurityContext.AUTH_MODE_SINGLE);
+ return securityContext;
+ }
+ else if(property.equals(IF_ALL_GRANTED))
+ {
+ securityContext.setAuthMode(SecurityContext.AUTH_MODE_ALL);
+ return securityContext;
+ }
+ else if(property.equals(IF_ANY_GRANTED))
+ {
+ securityContext.setAuthMode(SecurityContext.AUTH_MODE_ANY);
+ return securityContext;
+ }
+ else if(property.equals(IF_NOT_GRANTED))
+ {
+ securityContext.setAuthMode(SecurityContext.AUTH_MODE_NOT);
+ return securityContext;
+ }
+ else if(securityContext.inAuthMode()) {
+ securityContext.setRoles(getRolesFromProperty(property));
+ int authMode = securityContext.getAuthMode();
+
+ if(authMode == SecurityContext.AUTH_MODE_SINGLE)
+ return Boolean.valueOf(securityContext.ifSingleGranted());
+ else if(authMode == SecurityContext.AUTH_MODE_ALL)
+ return Boolean.valueOf(securityContext.ifAllGranted());
+ else if(authMode == SecurityContext.AUTH_MODE_ANY)
+ return Boolean.valueOf(securityContext.ifAnyGranted());
+ else
+ return Boolean.valueOf(securityContext.ifNotGranted());
+ }
+ else {
+ if(log.isDebugEnabled())
+ log.debug("Exception while retrieving property; base : "+base.getClass().getName()+", property : "+property);
+
+ throw new PropertyNotFoundException(getMessage(base, (String)property));
+ }
+ }
+ else
+ return originalResolver.getValue(base, property);
+
+ }
+
+ public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException {
+ return originalResolver.getType(base, index);
+ }
+
+ public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
+ if(base instanceof SecurityContext)
+ return SecurityContext.class;
+ else
+ return originalResolver.getType(base, property);
+ }
+
+ public Object getValue(Object base, int index) throws EvaluationException, PropertyNotFoundException {
+ return originalResolver.getValue(base, index);
+ }
+
+ public boolean isReadOnly(Object base, int index) throws EvaluationException, PropertyNotFoundException {
+ return originalResolver.isReadOnly(base, index);
+ }
+
+ public boolean isReadOnly(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
+ if(base instanceof SecurityContext)
+ return true;
+ else
+ return originalResolver.isReadOnly(base, property);
+ }
+
+ public void setValue(Object base, int index, Object value) throws EvaluationException, PropertyNotFoundException {
+ originalResolver.setValue(base, index, value);
+ }
+
+ public void setValue(Object base, Object property, Object value) throws EvaluationException, PropertyNotFoundException {
+ originalResolver.setValue(base, property, value);
+ }
+
+ private String[] getRolesFromProperty(Object property) {
+ String[] roles = ((String)property).split(",");
+ for (int i = 0; i < roles.length; i++) {
+ roles[i] = roles[i].trim();
+ }
+ return roles;
+ }
+
+ private static String getMessage(Object base, String name) {
+ return "Bean: " + base.getClass().getName() + ", property: " + name;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextVariableResolver.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextVariableResolver.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextVariableResolver.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/security/SecurityContextVariableResolver.java Thu Jul 3 14:58:05 2008
@@ -28,36 +28,36 @@
*/
public class SecurityContextVariableResolver extends VariableResolver{
- private static final String SECURITY_CONTEXT = "securityContext";
- private static final String INIT_PARAM_SECURITY_CONTEXT = "org.apache.myfaces.SECURITY_CONTEXT";
+ private static final String SECURITY_CONTEXT = "securityContext";
+ private static final String INIT_PARAM_SECURITY_CONTEXT = "org.apache.myfaces.SECURITY_CONTEXT";
- private VariableResolver originalResolver;
+ private VariableResolver originalResolver;
- public SecurityContextVariableResolver(VariableResolver variableresolver) {
- originalResolver = variableresolver;
- }
-
- public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException {
- if(SECURITY_CONTEXT.equals(name)) {
- return getSecurityContextImpl(facesContext);
- }
- else {
- return originalResolver.resolveVariable(facesContext, name);
- }
- }
-
- private Object getSecurityContextImpl(FacesContext facesContext) {
- String className = (String) facesContext.getExternalContext().getInitParameter(INIT_PARAM_SECURITY_CONTEXT);
-
- if(className == null)
- return new SecurityContextImpl(); //return default implementation
-
- try {
- Class clazz = Class.forName(className);
- return clazz.newInstance();
- }catch(Exception e) {
- throw new EvaluationException(e);
- }
- }
+ public SecurityContextVariableResolver(VariableResolver variableresolver) {
+ originalResolver = variableresolver;
+ }
+
+ public Object resolveVariable(FacesContext facesContext, String name) throws EvaluationException {
+ if(SECURITY_CONTEXT.equals(name)) {
+ return getSecurityContextImpl(facesContext);
+ }
+ else {
+ return originalResolver.resolveVariable(facesContext, name);
+ }
+ }
+
+ private Object getSecurityContextImpl(FacesContext facesContext) {
+ String className = (String) facesContext.getExternalContext().getInitParameter(INIT_PARAM_SECURITY_CONTEXT);
+
+ if(className == null)
+ return new SecurityContextImpl(); //return default implementation
+
+ try {
+ Class clazz = Class.forName(className);
+ return clazz.newInstance();
+ }catch(Exception e) {
+ throw new EvaluationException(e);
+ }
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/AbstractSubForm.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/AbstractSubForm.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/AbstractSubForm.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/AbstractSubForm.java Thu Jul 3 14:58:05 2008
@@ -80,7 +80,7 @@
private static final String PARTIAL_ENABLED = "org.apache.myfaces.IsPartialPhaseExecutionEnabled";
private boolean _submitted;
- public AbstractSubForm()
+ public AbstractSubForm()
{
super.setRendererType(DEFAULT_RENDERER_TYPE);
}
@@ -107,43 +107,43 @@
* @JSFProperty
* @return
*/
- public abstract Boolean getPreserveSubmittedValues();
+ public abstract Boolean getPreserveSubmittedValues();
- public void processDecodes(FacesContext context)
- {
- super.processDecodes(context);
- if (!isRendered()) return;
-
- if (!_submitted && Boolean.FALSE.equals(getPreserveSubmittedValues()))
- {
- // didn't find any better way as we do not know if we are submitted before the
- // decode phase, but then all the other components have the submitted value
- // set already.
- // so lets reset them again ... boring hack.
- resetSubmittedValues(this, context);
- }
- }
-
- public void processValidators(FacesContext context)
- {
- if (context == null) throw new NullPointerException("context");
- if (!isRendered()) return;
-
- boolean partialEnabled = isPartialEnabled(context, PhaseId.PROCESS_VALIDATIONS);
-
- if(partialEnabled || (_submitted && isEmptyList(context)))
- {
- for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
- {
- UIComponent childOrFacet = (UIComponent)it.next();
- childOrFacet.processValidators(context);
- }
- }
- else
- {
- processSubFormValidators(this,context);
- }
+ public void processDecodes(FacesContext context)
+ {
+ super.processDecodes(context);
+ if (!isRendered()) return;
+
+ if (!_submitted && Boolean.FALSE.equals(getPreserveSubmittedValues()))
+ {
+ // didn't find any better way as we do not know if we are submitted before the
+ // decode phase, but then all the other components have the submitted value
+ // set already.
+ // so lets reset them again ... boring hack.
+ resetSubmittedValues(this, context);
+ }
+ }
+
+ public void processValidators(FacesContext context)
+ {
+ if (context == null) throw new NullPointerException("context");
+ if (!isRendered()) return;
+
+ boolean partialEnabled = isPartialEnabled(context, PhaseId.PROCESS_VALIDATIONS);
+
+ if(partialEnabled || (_submitted && isEmptyList(context)))
+ {
+ for (Iterator it = getFacetsAndChildren(); it.hasNext(); )
+ {
+ UIComponent childOrFacet = (UIComponent)it.next();
+ childOrFacet.processValidators(context);
+ }
+ }
+ else
+ {
+ processSubFormValidators(this,context);
+ }
}
public void processUpdates(FacesContext context)
@@ -167,27 +167,27 @@
}
}
- private static void resetSubmittedValues(UIComponent comp, FacesContext context)
- {
- for (Iterator it = comp.getFacetsAndChildren(); it.hasNext(); )
- {
- UIComponent childOrFacet = (UIComponent)it.next();
- if (childOrFacet instanceof AbstractSubForm)
- {
- // we are not responsible for this subForm, are we?
- continue;
- }
-
- if (childOrFacet instanceof EditableValueHolder)
- {
- ((EditableValueHolder) childOrFacet).setSubmittedValue(null);
- }
-
- resetSubmittedValues(childOrFacet, context);
- }
- }
+ private static void resetSubmittedValues(UIComponent comp, FacesContext context)
+ {
+ for (Iterator it = comp.getFacetsAndChildren(); it.hasNext(); )
+ {
+ UIComponent childOrFacet = (UIComponent)it.next();
+ if (childOrFacet instanceof AbstractSubForm)
+ {
+ // we are not responsible for this subForm, are we?
+ continue;
+ }
+
+ if (childOrFacet instanceof EditableValueHolder)
+ {
+ ((EditableValueHolder) childOrFacet).setSubmittedValue(null);
+ }
+
+ resetSubmittedValues(childOrFacet, context);
+ }
+ }
- private static void processSubFormUpdates(UIComponent comp, FacesContext context)
+ private static void processSubFormUpdates(UIComponent comp, FacesContext context)
{
for (Iterator it = comp.getFacetsAndChildren(); it.hasNext(); )
{
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java Thu Jul 3 14:58:05 2008
@@ -47,7 +47,7 @@
private static final String SUBMIT_FUNCTION_SUFFIX = "_submit";
private static final String HIDDEN_PARAM_NAME = "org.apache.myfaces.custom.subform.submittedId";
-
+
public void encodeBegin(FacesContext context, UIComponent component) throws IOException
{
super.encodeBegin(context, component);
@@ -58,7 +58,7 @@
writer.startElement(HTML.SCRIPT_ELEM, null);
writer.writeAttribute(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_TYPE_ATTR, org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
- FormInfo parentFormInfo = RendererUtils.findNestingForm(component,context);
+ FormInfo parentFormInfo = RendererUtils.findNestingForm(component,context);
if(parentFormInfo!=null)
{
writer.writeText(createPartialSubmitJS(component.getId(), parentFormInfo.getFormName()), null);
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/submitOnEvent/SubmitOnEventRenderer.java Thu Jul 3 14:58:05 2008
@@ -54,45 +54,45 @@
*/
public class SubmitOnEventRenderer extends HtmlRenderer
{
- private final static Set ON_CHANGE_FAMILY = new TreeSet(Arrays.asList(new String[]
- {
- UISelectBoolean.COMPONENT_FAMILY,
- UISelectMany.COMPONENT_FAMILY,
- UISelectOne.COMPONENT_FAMILY
- }));
+ private final static Set ON_CHANGE_FAMILY = new TreeSet(Arrays.asList(new String[]
+ {
+ UISelectBoolean.COMPONENT_FAMILY,
+ UISelectMany.COMPONENT_FAMILY,
+ UISelectOne.COMPONENT_FAMILY
+ }));
- public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
+ public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
{
SubmitOnEvent submitOnEvent = (SubmitOnEvent) uiComponent;
UIComponent forComponent = null;
- UIComponent triggerComponent = null;
+ UIComponent triggerComponent = null;
UIComponent parent = uiComponent.getParent();
if (parent != null)
{
if (UIInput.COMPONENT_FAMILY.equals(parent.getFamily())
- || parent instanceof UIInput
- || parent instanceof ModalDialog
- || parent instanceof EditableValueHolder)
+ || parent instanceof UIInput
+ || parent instanceof ModalDialog
+ || parent instanceof EditableValueHolder)
{
triggerComponent = parent;
}
else if (UICommand.COMPONENT_FAMILY.equals(parent.getFamily())
- || parent instanceof UICommand
- || parent instanceof ActionSource)
+ || parent instanceof UICommand
+ || parent instanceof ActionSource)
{
forComponent = parent;
}
- }
+ }
- if (triggerComponent != null && !triggerComponent.isRendered())
- {
- // the component we are attaced to is not being rendered, so we can quit now ...
- return;
- }
+ if (triggerComponent != null && !triggerComponent.isRendered())
+ {
+ // the component we are attaced to is not being rendered, so we can quit now ...
+ return;
+ }
- if (forComponent == null)
+ if (forComponent == null)
{
String forComponentId = submitOnEvent.getFor();
if (forComponentId == null)
@@ -101,51 +101,51 @@
}
forComponent = uiComponent.findComponent(forComponentId);
- if (forComponent == null)
+ if (forComponent == null)
{
throw new IllegalArgumentException("SubmitOnEvent: can't find 'for'-component '" + forComponentId + "'");
}
}
- AddResourceFactory.getInstance(facesContext).addJavaScriptAtPosition(
- facesContext, AddResource.HEADER_BEGIN, SubmitOnEventRenderer.class,
- "submitOnEvent.js");
-
- // If the dojo library will be loaded, use it to attach to the onLoad handler.
- // Do NOT use dojo if no other component requires it, this avoids loading of this
- // heavy-weight javascript-library for just the simple submitOnEvent use-case.
- // We do this for better integration with dojo widget (e.g. our ModalDialog)
- // where using the timeout stuff is not appropriate.
- boolean useDojoForInit = DojoUtils.isDojoInitialized(facesContext);
-
- StringBuffer js = new StringBuffer(80);
-
- if (useDojoForInit)
- {
- js.append("dojo.addOnLoad(function() {");
- }
- else
- {
- js.append("setTimeout(\"");
- }
- js.append("orgApacheMyfacesSubmitOnEventRegister('");
+ AddResourceFactory.getInstance(facesContext).addJavaScriptAtPosition(
+ facesContext, AddResource.HEADER_BEGIN, SubmitOnEventRenderer.class,
+ "submitOnEvent.js");
+
+ // If the dojo library will be loaded, use it to attach to the onLoad handler.
+ // Do NOT use dojo if no other component requires it, this avoids loading of this
+ // heavy-weight javascript-library for just the simple submitOnEvent use-case.
+ // We do this for better integration with dojo widget (e.g. our ModalDialog)
+ // where using the timeout stuff is not appropriate.
+ boolean useDojoForInit = DojoUtils.isDojoInitialized(facesContext);
+
+ StringBuffer js = new StringBuffer(80);
+
+ if (useDojoForInit)
+ {
+ js.append("dojo.addOnLoad(function() {");
+ }
+ else
+ {
+ js.append("setTimeout(\"");
+ }
+ js.append("orgApacheMyfacesSubmitOnEventRegister('");
if (submitOnEvent.getEvent() != null)
{
js.append(submitOnEvent.getEvent().toLowerCase());
}
else
{
- if (triggerComponent != null
- && triggerComponent.getFamily() != null
- && ON_CHANGE_FAMILY.contains(triggerComponent.getFamily()))
- {
- js.append("change");
- }
- else
- {
- js.append("keypress");
- }
- }
+ if (triggerComponent != null
+ && triggerComponent.getFamily() != null
+ && ON_CHANGE_FAMILY.contains(triggerComponent.getFamily()))
+ {
+ js.append("change");
+ }
+ else
+ {
+ js.append("keypress");
+ }
+ }
js.append("','");
if (submitOnEvent.getCallback() != null)
{
@@ -154,27 +154,27 @@
js.append("','");
if (triggerComponent != null)
{
- if (triggerComponent instanceof ModalDialog)
- {
- js.append(((ModalDialog) triggerComponent).getDialogVar());
- }
- else
- {
- js.append(triggerComponent.getClientId(facesContext));
- }
- }
+ if (triggerComponent instanceof ModalDialog)
+ {
+ js.append(((ModalDialog) triggerComponent).getDialogVar());
+ }
+ else
+ {
+ js.append(triggerComponent.getClientId(facesContext));
+ }
+ }
js.append("','");
js.append(forComponent.getClientId(facesContext));
- js.append("');");
+ js.append("');");
// js.append("');");
- if (useDojoForInit)
- {
- js.append("});");
- }
- else
- {
- js.append("\", 100)");
- }
+ if (useDojoForInit)
+ {
+ js.append("});");
+ }
+ else
+ {
+ js.append("\", 100)");
+ }
// AddResourceFactory.getInstance(facesContext).addInlineScriptAtPosition(facesContext, AddResource.BODY_END, js.toString());
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/SuggestAjaxRenderer.java Thu Jul 3 14:58:05 2008
@@ -90,7 +90,7 @@
}
protected String addQueryString(String url, String queryString)
- {
- return url + (url.indexOf("?") > 0 ? "&" : "?") + queryString;
+ {
+ return url + (url.indexOf("?") > 0 ? "&" : "?") + queryString;
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/AbstractInputSuggestAjax.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/AbstractInputSuggestAjax.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/AbstractInputSuggestAjax.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/AbstractInputSuggestAjax.java Thu Jul 3 14:58:05 2008
@@ -58,10 +58,10 @@
setRendererType(DEFAULT_RENDERER_TYPE);
- // it makes absolutely no sense to have two autocompletes active at the same time
- // ensure to disable the browser one - this has nothing to do with the
- // autocomplete attribute this component provides
- setAutocomplete("off"); // NON-NLS
+ // it makes absolutely no sense to have two autocompletes active at the same time
+ // ensure to disable the browser one - this has nothing to do with the
+ // autocomplete attribute this component provides
+ setAutocomplete("off"); // NON-NLS
}
public void encodeChildren(FacesContext context) throws IOException
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/inputsuggestajax/InputSuggestAjaxRenderer.java Thu Jul 3 14:58:05 2008
@@ -95,12 +95,12 @@
String mainComponentRenderedValue = null;
- /* check if the user supplied a label method */
- if (inputSuggestAjax.getItemLabelMethod() == null)
- {
- mainComponentRenderedValue = RendererUtils.getStringValue(context, inputSuggestAjax);
+ /* check if the user supplied a label method */
+ if (inputSuggestAjax.getItemLabelMethod() == null)
+ {
+ mainComponentRenderedValue = RendererUtils.getStringValue(context, inputSuggestAjax);
}
- else
+ else
{
MethodBinding labelMethod = inputSuggestAjax.getItemLabelMethod();
@@ -114,7 +114,7 @@
label = (String) labelMethod.invoke(context, new Object[]{valueObject});
- hiddenInputValue = converter.getAsString(context, inputSuggestAjax, valueObject);
+ hiddenInputValue = converter.getAsString(context, inputSuggestAjax, valueObject);
mainComponentRenderedValue = hiddenInputValue;
}
}
@@ -133,36 +133,36 @@
out.endElement(HTML.DIV_ELEM);
String textInputId = inputSuggestAjax.getClientId(context);
- if (label != null)
- {
- // whe have a label method and thus a hidden input field holding the real value
- // now fake the component id to have the rendered input component use another id
- // than the one we render later for the real value
- String oriId = inputSuggestAjax.getId();
- try
- {
- // fake the label
- inputSuggestAjax.setId(oriId + "_fake");
-
- textInputId = inputSuggestAjax.getClientId(context);
-
- // fake a submitted value so we have it rendered
- inputSuggestAjax.setSubmittedValue(label);
-
- super.encodeEnd(context, inputSuggestAjax);
- }
- finally
- {
- inputSuggestAjax.setSubmittedValue(null);
- inputSuggestAjax.setId(oriId);
- }
- }
- else
- {
- super.encodeEnd(context, inputSuggestAjax);
- }
+ if (label != null)
+ {
+ // whe have a label method and thus a hidden input field holding the real value
+ // now fake the component id to have the rendered input component use another id
+ // than the one we render later for the real value
+ String oriId = inputSuggestAjax.getId();
+ try
+ {
+ // fake the label
+ inputSuggestAjax.setId(oriId + "_fake");
+
+ textInputId = inputSuggestAjax.getClientId(context);
- String inputSuggestComponentVar = DojoUtils.calculateWidgetVarName(placeHolderId);
+ // fake a submitted value so we have it rendered
+ inputSuggestAjax.setSubmittedValue(label);
+
+ super.encodeEnd(context, inputSuggestAjax);
+ }
+ finally
+ {
+ inputSuggestAjax.setSubmittedValue(null);
+ inputSuggestAjax.setId(oriId);
+ }
+ }
+ else
+ {
+ super.encodeEnd(context, inputSuggestAjax);
+ }
+
+ String inputSuggestComponentVar = DojoUtils.calculateWidgetVarName(placeHolderId);
Map attributes = new HashedMap();
@@ -221,29 +221,29 @@
}
}
- protected Converter getRequiredConverter(FacesContext context, InputSuggestAjax inputSuggestAjax)
- {
- Converter converter = inputSuggestAjax.getConverter();
- if (converter != null)
- {
- return converter;
- }
-
- Class type = inputSuggestAjax.getValueBinding("value").getType(context);
- if (type != null)
- {
- converter = context.getApplication().createConverter(type);
- if (converter != null)
- {
- return converter;
- }
- }
-
- throw new IllegalStateException("There must be a converter if " +
- "attribute \"labelMethod\" is used");
- }
+ protected Converter getRequiredConverter(FacesContext context, InputSuggestAjax inputSuggestAjax)
+ {
+ Converter converter = inputSuggestAjax.getConverter();
+ if (converter != null)
+ {
+ return converter;
+ }
+
+ Class type = inputSuggestAjax.getValueBinding("value").getType(context);
+ if (type != null)
+ {
+ converter = context.getApplication().createConverter(type);
+ if (converter != null)
+ {
+ return converter;
+ }
+ }
+
+ throw new IllegalStateException("There must be a converter if " +
+ "attribute \"labelMethod\" is used");
+ }
- public void encodeAjax(FacesContext context, UIComponent uiComponent)
+ public void encodeAjax(FacesContext context, UIComponent uiComponent)
throws IOException
{
InputSuggestAjax inputSuggestAjax = (InputSuggestAjax) uiComponent;
@@ -258,7 +258,7 @@
if (labelMethod != null)
{
- Converter converter = getRequiredConverter(context, inputSuggestAjax);
+ Converter converter = getRequiredConverter(context, inputSuggestAjax);
for (Iterator iterator = suggesteds.iterator(); iterator.hasNext();)
{
@@ -302,7 +302,7 @@
private String escapeQuotes(String input)
{
- return input != null ? input.replaceAll("\"", "\\\\\"") : "";
+ return input != null ? input.replaceAll("\"", "\\\\\"") : "";
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/suggestajax/tablesuggestajax/TableSuggestAjaxRenderer.java Thu Jul 3 14:58:05 2008
@@ -383,7 +383,7 @@
private String escapeQuotes(String input)
{
- return input != null ? input.replaceAll("\"", "\\\\\"") : "";
+ return input != null ? input.replaceAll("\"", "\\\\\"") : "";
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/timednotifier/TimedNotifierRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/timednotifier/TimedNotifierRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/timednotifier/TimedNotifierRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/timednotifier/TimedNotifierRenderer.java Thu Jul 3 14:58:05 2008
@@ -91,14 +91,14 @@
String replacedClientId = notifierClientId.replaceAll(":", "_");
String dialogVar = replacedClientId + "Notifier_Dialog";
- String confirmVar = dialogVar + "_Yes";
+ String confirmVar = dialogVar + "_Yes";
- Integer timeShow = notifier.getShowDelay();
- Integer timeHide = notifier.getHideDelay();
+ Integer timeShow = notifier.getShowDelay();
+ Integer timeHide = notifier.getHideDelay();
UIComponent confirmComp = notifier.getConfirm();
-
+
@@ -107,14 +107,14 @@
StringBuffer sb = new StringBuffer();
sb.append("function "+replacedClientId+"() {\n");
if(confirmComp == null)
- sb.append("var "+ notifierVar + " = new myfaces_TimedNotifier('" +
- dialogVar + "','" + confirmVar + "','" + notifierClientId + "',"+
- timeShow.toString()+","+timeHide.toString()+");\n");
+ sb.append("var "+ notifierVar + " = new myfaces_TimedNotifier('" +
+ dialogVar + "','" + confirmVar + "','" + notifierClientId + "',"+
+ timeShow.toString()+","+timeHide.toString()+");\n");
else
- sb.append("var "+ notifierVar + " = new myfaces_TimedNotifier('" +
- dialogVar + "',null,'" + notifierClientId + "',"+
- timeShow.toString()+","+timeHide.toString()+");\n");
-
+ sb.append("var "+ notifierVar + " = new myfaces_TimedNotifier('" +
+ dialogVar + "',null,'" + notifierClientId + "',"+
+ timeShow.toString()+","+timeHide.toString()+");\n");
+
sb.append( notifierVar + ".showDialog();\n");
sb.append("};\n");
sb.append("dojo.lang.setTimeout("+replacedClientId+","+timeShow.toString()+");");
@@ -172,8 +172,8 @@
* value="yes" /> <input type="button"
* id="form1__idJsp1Notifier_Dialog_No" value="no" /> </div>
*/
- TimedNotifier notifier = (TimedNotifier) uiComponent;
-
+ TimedNotifier notifier = (TimedNotifier) uiComponent;
+
String notifierClientId = uiComponent.getClientId(facesContext);
String replacedClientId = notifierClientId.replaceAll(":", "_");
String dialogVar = replacedClientId + "Notifier_Dialog";
@@ -198,20 +198,20 @@
UIComponent contentComp = notifier.getContent();
if(contentComp == null)
- writer.write(content);
+ writer.write(content);
else
- RendererUtils.renderChild(facesContext, contentComp);
+ RendererUtils.renderChild(facesContext, contentComp);
writer.endElement(HTML.DIV_ELEM);
writer.write(HTML.NBSP_ENTITY);
UIComponent confirmComp = notifier.getConfirm();
if(confirmComp != null)
- RendererUtils.renderChild(facesContext, confirmComp);
+ RendererUtils.renderChild(facesContext, confirmComp);
else {
- writer.startElement(HTML.INPUT_ELEM, uiComponent);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.BUTTON_ELEM, null);
- writer.writeAttribute(HTML.ID_ATTR, dialogVar + "_Yes", null);
- writer.writeAttribute(HTML.VALUE_ATTR, yesText, null);
- writer.endElement(HTML.INPUT_ELEM);
+ writer.startElement(HTML.INPUT_ELEM, uiComponent);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.BUTTON_ELEM, null);
+ writer.writeAttribute(HTML.ID_ATTR, dialogVar + "_Yes", null);
+ writer.writeAttribute(HTML.VALUE_ATTR, yesText, null);
+ writer.endElement(HTML.INPUT_ELEM);
}
writer.write(HTML.NBSP_ENTITY);
writer.endElement(HTML.DIV_ELEM);
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleGroupRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleGroupRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleGroupRenderer.java Thu Jul 3 14:58:05 2008
@@ -40,14 +40,14 @@
public class ToggleGroupRenderer extends HtmlGroupRendererBase {
public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
- ResponseWriter writer = context.getResponseWriter();
+ ResponseWriter writer = context.getResponseWriter();
- writer.startElement( org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SPAN_ELEM, component );
- writer.writeAttribute(HTML.ID_ATTR, component.getClientId(context), null);
- HtmlRendererUtils.renderHTMLAttributes( writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES );
+ writer.startElement( org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SPAN_ELEM, component );
+ writer.writeAttribute(HTML.ID_ATTR, component.getClientId(context), null);
+ HtmlRendererUtils.renderHTMLAttributes( writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES );
- RendererUtils.renderChildren( context, component );
+ RendererUtils.renderChildren( context, component );
- writer.endElement( HTML.SPAN_ELEM );
- }
+ writer.endElement( HTML.SPAN_ELEM );
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleLinkRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleLinkRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleLinkRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleLinkRenderer.java Thu Jul 3 14:58:05 2008
@@ -222,7 +222,7 @@
RendererUtils.checkParamValidity(context, component, ToggleLink.class);
if(((ToggleLink) component).isDisabled())
- return;
+ return;
super.encodeEnd(context, component);
}
@@ -232,19 +232,19 @@
ToggleLink toggleLink = (ToggleLink) component;
if(toggleLink.isDisabled())
- return;
+ return;
super.encodeBegin(context, component);
}
private String getToggleJavascriptFunctionName(FacesContext context,ToggleLink toggleLink){
- for(UIComponent component = toggleLink.getParent(); component != null; component = component.getParent())
- if( component instanceof TogglePanel )
- return TogglePanelRenderer.getToggleJavascriptFunctionName( context, (TogglePanel)component );
+ for(UIComponent component = toggleLink.getParent(); component != null; component = component.getParent())
+ if( component instanceof TogglePanel )
+ return TogglePanelRenderer.getToggleJavascriptFunctionName( context, (TogglePanel)component );
- Log log = LogFactory.getLog(ToggleLinkRenderer.class);
+ Log log = LogFactory.getLog(ToggleLinkRenderer.class);
log.error("The ToggleLink component with id " + toggleLink.getClientId( context )+" isn't enclosed in a togglePanel.");
- return null;
+ return null;
}
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/TogglePanelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/TogglePanelRenderer.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/TogglePanelRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/TogglePanelRenderer.java Thu Jul 3 14:58:05 2008
@@ -64,7 +64,7 @@
writer.endElement(HTML.INPUT_ELEM);
if( ! toggleMode )
- writeJavascriptToToggleVisibility(context, togglePanel);
+ writeJavascriptToToggleVisibility(context, togglePanel);
super.encodeEnd(context, togglePanel);
}
@@ -107,7 +107,7 @@
boolean display = toggleMode != isHiddenWhenToggled(component);
if( display ){
- if (style == null || style.length() == 0) {
+ if (style == null || style.length() == 0) {
return;
} else {
int index = style.indexOf(";display:none;");
@@ -121,11 +121,11 @@
}
}
}else{ // hide
- if (style == null) {
- style = ";display:none;";
- } else if (style.indexOf("display:none;") == -1) {
- style = style.concat(";display:none;");
- }
+ if (style == null) {
+ style = ";display:none;";
+ } else if (style.indexOf("display:none;") == -1) {
+ style = style.concat(";display:none;");
+ }
}
setStyle.invoke(component, new Object[] { style });
@@ -139,11 +139,11 @@
}
private boolean isHiddenWhenToggled(UIComponent component){
- return component instanceof ToggleLink || component instanceof ToggleGroup;
+ return component instanceof ToggleLink || component instanceof ToggleGroup;
}
private String getHiddenFieldId(FacesContext context, TogglePanel togglePanel){
- return togglePanel.getClientId(context) + "_hidden";
+ return togglePanel.getClientId(context) + "_hidden";
}
// Generate the javascript function to hide the Link component
// and display the components specified in the 'for' attribute
@@ -163,20 +163,20 @@
for(Iterator it = togglePanel.getChildren().iterator(); it.hasNext(); ) {
UIComponent component = (UIComponent) it.next();
if ( isHiddenWhenToggled( component ) ) {
- if( idsToHideCount > 0 )
- idsToHide.append( ',' );
- idsToHide.append( component.getClientId( context ) );
- idsToHideCount++;
+ if( idsToHideCount > 0 )
+ idsToHide.append( ',' );
+ idsToHide.append( component.getClientId( context ) );
+ idsToHideCount++;
}
}
if( idsToHideCount == 1 ){
- out.write( "document.getElementById('"+ idsToHide.toString() +"').style.display = 'none';\n" );
+ out.write( "document.getElementById('"+ idsToHide.toString() +"').style.display = 'none';\n" );
}else if( idsToHideCount > 1 ){
- out.write( "var idsToHide = '" + idsToHide.toString() + "'.split(',');\n" );
- out.write( "for(var i=0;i<idsToHide.length;i++) document.getElementById(idsToHide[i]).style.display = 'none';\n" );
+ out.write( "var idsToHide = '" + idsToHide.toString() + "'.split(',');\n" );
+ out.write( "for(var i=0;i<idsToHide.length;i++) document.getElementById(idsToHide[i]).style.display = 'none';\n" );
}else{ // no idsToHide set
- getLog().warn( "TogglePanel "+ togglePanel.getClientId(context) +" has no visible components when toggled." );
+ getLog().warn( "TogglePanel "+ togglePanel.getClientId(context) +" has no visible components when toggled." );
}
out.write( "var idsToShow = idsToShowS.split(',');\n" );
out.write( "for(var j=0;j<idsToShow.length;j++) document.getElementById(idsToShow[j]).style.display = 'inline';\n");
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/urlvalidator/AbstractUrlValidator.java Thu Jul 3 14:58:05 2008
@@ -41,50 +41,50 @@
*/
public abstract class AbstractUrlValidator extends ValidatorBase {
- /**
- * <p>The standard converter id for this converter.</p>
- */
- public static final String VALIDATOR_ID = "org.apache.myfaces.validator.Url";
- /**
- * <p>The message identifier of the {@link FacesMessage} to be created if
- * the maximum length check fails.</p>
- */
- public static final String URL_MESSAGE_ID = "org.apache.myfaces.Url.INVALID";
-
- public AbstractUrlValidator(){
-
- }
-
- /**
- * method that validates an url address.
- * it uses the commons-validator
- */
- public void validate(
- FacesContext facesContext,
- UIComponent uiComponent,
- Object value)
- throws ValidatorException {
-
-
- if (facesContext == null) throw new NullPointerException("facesContext");
- if (uiComponent == null) throw new NullPointerException("uiComponent");
-
- if (value == null)
- {
- return;
- }
-
- org.apache.commons.validator.UrlValidator urlValidator = initValidator();
-
- if (!urlValidator.isValid(value.toString())) {
- Object[] args = {value.toString()};
- throw new ValidatorException(getFacesMessage(URL_MESSAGE_ID, args));
+ /**
+ * <p>The standard converter id for this converter.</p>
+ */
+ public static final String VALIDATOR_ID = "org.apache.myfaces.validator.Url";
+ /**
+ * <p>The message identifier of the {@link FacesMessage} to be created if
+ * the maximum length check fails.</p>
+ */
+ public static final String URL_MESSAGE_ID = "org.apache.myfaces.Url.INVALID";
+
+ public AbstractUrlValidator(){
+
+ }
+
+ /**
+ * method that validates an url address.
+ * it uses the commons-validator
+ */
+ public void validate(
+ FacesContext facesContext,
+ UIComponent uiComponent,
+ Object value)
+ throws ValidatorException {
+
+
+ if (facesContext == null) throw new NullPointerException("facesContext");
+ if (uiComponent == null) throw new NullPointerException("uiComponent");
+
+ if (value == null)
+ {
+ return;
+ }
+
+ org.apache.commons.validator.UrlValidator urlValidator = initValidator();
+
+ if (!urlValidator.isValid(value.toString())) {
+ Object[] args = {value.toString()};
+ throw new ValidatorException(getFacesMessage(URL_MESSAGE_ID, args));
}
- }
-
- private org.apache.commons.validator.UrlValidator initValidator()
- {
+ }
+
+ private org.apache.commons.validator.UrlValidator initValidator()
+ {
int options = 0;
if (isAllow2Slashes())
@@ -109,34 +109,34 @@
org.apache.commons.validator.UrlValidator(schemesList,options);
}
return urlValidator;
- }
-
- private String[] getSchemesList(){
- if (getSchemes() == null)
- {
- return null;
- }
- String [] list = getSchemes().split(",");
- String [] resp = new String [list.length];
-
- for (int i = 0; i < list.length; i++)
- {
- resp[i] = list[i].trim();
- }
- return resp;
- }
-
- public abstract void setSchemes(String _schemes);
-
- /**
- * CSV values that indicates the set of schemes to check this url.
- *
- * If allowAllSchemas = true, the values of this field are ignored.
- *
- * If no schemes are provided, default to this set ("http", "https", "ftp").
- *
- * @JSFProperty
- */
+ }
+
+ private String[] getSchemesList(){
+ if (getSchemes() == null)
+ {
+ return null;
+ }
+ String [] list = getSchemes().split(",");
+ String [] resp = new String [list.length];
+
+ for (int i = 0; i < list.length; i++)
+ {
+ resp[i] = list[i].trim();
+ }
+ return resp;
+ }
+
+ public abstract void setSchemes(String _schemes);
+
+ /**
+ * CSV values that indicates the set of schemes to check this url.
+ *
+ * If allowAllSchemas = true, the values of this field are ignored.
+ *
+ * If no schemes are provided, default to this set ("http", "https", "ftp").
+ *
+ * @JSFProperty
+ */
public abstract String getSchemes();
public abstract void setAllow2Slashes(boolean _allow2Slashes);
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/util/ComponentUtils.java Thu Jul 3 14:58:05 2008
@@ -43,9 +43,9 @@
public final class ComponentUtils
{
- private ComponentUtils() {
+ private ComponentUtils() {
- }
+ }
/**
* TR- This was moved from AjaxPhaseListenere on checkin 344383
@@ -56,157 +56,157 @@
* @return component referenced by clientId or null if not found
*/
public static UIComponent findComponentByClientId(FacesContext context,
- UIComponent root, String clientId) {
- UIComponent component = null;
- for (int i = 0; i < root.getChildCount() && component == null; i++) {
- UIComponent child = (UIComponent) root.getChildren().get(i);
- component = findComponentByClientId(context, child, clientId);
- }
- if (root.getId() != null) {
- if (component == null && root.getClientId(context).equals(clientId)) {
- component = root;
- }
- }
- return component;
- }
-
- /**
- * Useful if you don't know the clientId <p/> TR- This was moved from
- * AjaxPhaseListenere on checkin 344383 Seems like this could be made more
- * efficient
- *
- * @param context
- * @param root
- * @param id
- * @return component referenced by id or null if not found
- */
+ UIComponent root, String clientId) {
+ UIComponent component = null;
+ for (int i = 0; i < root.getChildCount() && component == null; i++) {
+ UIComponent child = (UIComponent) root.getChildren().get(i);
+ component = findComponentByClientId(context, child, clientId);
+ }
+ if (root.getId() != null) {
+ if (component == null && root.getClientId(context).equals(clientId)) {
+ component = root;
+ }
+ }
+ return component;
+ }
+
+ /**
+ * Useful if you don't know the clientId <p/> TR- This was moved from
+ * AjaxPhaseListenere on checkin 344383 Seems like this could be made more
+ * efficient
+ *
+ * @param context
+ * @param root
+ * @param id
+ * @return component referenced by id or null if not found
+ */
public static UIComponent findComponentById(FacesContext context,
- UIComponent root, String id) {
- UIComponent component = null;
- for (int i = 0; i < root.getChildCount() && component == null; i++) {
- UIComponent child = (UIComponent) root.getChildren().get(i);
- component = findComponentById(context, child, id);
- }
- // System.out.println("component looking for: " + id + " - rootid: " +
- // root.getId() + " " + root);
- if (root.getId() != null) {
- if (component == null && root.getId().equals(id)) {
- component = root;
- }
- }
- return component;
- }
-
- public static UIComponent findFirstMessagesComponent(FacesContext context,
- UIComponent base) {
- if (base == null) {
- return null;
- }
-
- if (base instanceof HtmlMessages) {
- return base;
- }
-
- Iterator iterChildren = base.getFacetsAndChildren();
- while (iterChildren.hasNext()) {
- UIComponent child = (UIComponent) iterChildren.next();
-
- UIComponent found = findFirstMessagesComponent(context, child);
- if (found != null) {
- return found;
- }
- }
-
- return null;
- }
-
- private static boolean isDecorated(UIComponent component, String attribute,
- String value) {
- String attributeValue = (String) component.getAttributes().get(
- attribute);
-
- if (attributeValue == null || attributeValue.indexOf(value) == -1)
- return false;
- else
- return true;
- }
-
- /**
- * Changes the event attributes like onclick by appending the given value
- *
- * @param component
- * UIComponent instance that the attribute belongs to
- * @param attribute
- * Attribute to be changed
- * @param value
- * Value to be appended
- */
- public static void decorateEventAttribute(UIComponent component,
- String attribute, String value) {
- if (isDecorated(component, attribute, value))
- return;
-
- String attributeValue = (String) component.getAttributes().get(
- attribute);
-
- if (attributeValue == null)
- component.getAttributes().put(attribute, value);
- else if (attributeValue.endsWith(";"))
- component.getAttributes().put(attribute, attributeValue + value);
- else
- component.getAttributes().put(attribute,
- attributeValue + ";" + value);
- }
-
- /**
- * The getParameterMap() is used for getting the parameters
- * of a specific component.
- * @param component
- * @return the Map of the component.
- */
- public static Map getParameterMap(UIComponent component) {
- Map result = new HashMap();
- for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
- UIComponent child = (UIComponent) iter.next();
- if (child instanceof UIParameter) {
- UIParameter uiparam = (UIParameter) child;
- Object value = uiparam.getValue();
- if (value != null) {
- result.put(uiparam.getName(), value);
- }
- }
- }
- return result;
- }
-
- /**
- * The getLifecycleId() is used for getting the id of
- * the Lifecycle from the ServletContext.
- * @param context
- * @return the id of the life cycle.
- */
- public static String getLifecycleId(ServletContext context) {
- String lifecycleId = context
- .getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR);
- return lifecycleId != null ? lifecycleId
- : LifecycleFactory.DEFAULT_LIFECYCLE;
- }
-
- /**
- * This method is used for getting the columns of
- * a specific HTMLDataTable.
- * @param table
- * @return the List of UIColumns
- */
- public static List getHTMLDataTableColumns(HtmlDataTable table) {
- List columns = new ArrayList();
-
- for (int i = 0; i < table.getChildCount(); i++) {
- UIComponent child = (UIComponent) table.getChildren().get( i );
- if (child instanceof UIColumn) {
- columns.add( child );
- }
- }
- return columns;
- }
+ UIComponent root, String id) {
+ UIComponent component = null;
+ for (int i = 0; i < root.getChildCount() && component == null; i++) {
+ UIComponent child = (UIComponent) root.getChildren().get(i);
+ component = findComponentById(context, child, id);
+ }
+ // System.out.println("component looking for: " + id + " - rootid: " +
+ // root.getId() + " " + root);
+ if (root.getId() != null) {
+ if (component == null && root.getId().equals(id)) {
+ component = root;
+ }
+ }
+ return component;
+ }
+
+ public static UIComponent findFirstMessagesComponent(FacesContext context,
+ UIComponent base) {
+ if (base == null) {
+ return null;
+ }
+
+ if (base instanceof HtmlMessages) {
+ return base;
+ }
+
+ Iterator iterChildren = base.getFacetsAndChildren();
+ while (iterChildren.hasNext()) {
+ UIComponent child = (UIComponent) iterChildren.next();
+
+ UIComponent found = findFirstMessagesComponent(context, child);
+ if (found != null) {
+ return found;
+ }
+ }
+
+ return null;
+ }
+
+ private static boolean isDecorated(UIComponent component, String attribute,
+ String value) {
+ String attributeValue = (String) component.getAttributes().get(
+ attribute);
+
+ if (attributeValue == null || attributeValue.indexOf(value) == -1)
+ return false;
+ else
+ return true;
+ }
+
+ /**
+ * Changes the event attributes like onclick by appending the given value
+ *
+ * @param component
+ * UIComponent instance that the attribute belongs to
+ * @param attribute
+ * Attribute to be changed
+ * @param value
+ * Value to be appended
+ */
+ public static void decorateEventAttribute(UIComponent component,
+ String attribute, String value) {
+ if (isDecorated(component, attribute, value))
+ return;
+
+ String attributeValue = (String) component.getAttributes().get(
+ attribute);
+
+ if (attributeValue == null)
+ component.getAttributes().put(attribute, value);
+ else if (attributeValue.endsWith(";"))
+ component.getAttributes().put(attribute, attributeValue + value);
+ else
+ component.getAttributes().put(attribute,
+ attributeValue + ";" + value);
+ }
+
+ /**
+ * The getParameterMap() is used for getting the parameters
+ * of a specific component.
+ * @param component
+ * @return the Map of the component.
+ */
+ public static Map getParameterMap(UIComponent component) {
+ Map result = new HashMap();
+ for (Iterator iter = component.getChildren().iterator(); iter.hasNext();) {
+ UIComponent child = (UIComponent) iter.next();
+ if (child instanceof UIParameter) {
+ UIParameter uiparam = (UIParameter) child;
+ Object value = uiparam.getValue();
+ if (value != null) {
+ result.put(uiparam.getName(), value);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The getLifecycleId() is used for getting the id of
+ * the Lifecycle from the ServletContext.
+ * @param context
+ * @return the id of the life cycle.
+ */
+ public static String getLifecycleId(ServletContext context) {
+ String lifecycleId = context
+ .getInitParameter(FacesServlet.LIFECYCLE_ID_ATTR);
+ return lifecycleId != null ? lifecycleId
+ : LifecycleFactory.DEFAULT_LIFECYCLE;
+ }
+
+ /**
+ * This method is used for getting the columns of
+ * a specific HTMLDataTable.
+ * @param table
+ * @return the List of UIColumns
+ */
+ public static List getHTMLDataTableColumns(HtmlDataTable table) {
+ List columns = new ArrayList();
+
+ for (int i = 0; i < table.getChildCount(); i++) {
+ UIComponent child = (UIComponent) table.getChildren().get( i );
+ if (child instanceof UIColumn) {
+ columns.add( child );
+ }
+ }
+ return columns;
+ }
}
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/RestoreStateCommand.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/RestoreStateCommand.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/RestoreStateCommand.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/RestoreStateCommand.java Thu Jul 3 14:58:05 2008
@@ -20,8 +20,8 @@
public interface RestoreStateCommand
{
- public void saveCurrentState();
- public void restoreCurrentState();
-
- public void restoreEventState();
+ public void saveCurrentState();
+ public void restoreCurrentState();
+
+ public void restoreEventState();
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeCollector.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeCollector.java?rev=673833&r1=673832&r2=673833&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeCollector.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/valueChangeNotifier/ValueChangeCollector.java Thu Jul 3 14:58:05 2008
@@ -36,95 +36,95 @@
* @version $Revision$ $Date$
*/
public class ValueChangeCollector implements ValueChangeListener,
- StateHolder
+ StateHolder
{
- private String method = null;
- private boolean isTransient = false;
+ private String method = null;
+ private boolean isTransient = false;
- public ValueChangeCollector()
- {
- }
-
- protected ValueChangeCollector(String method)
- {
- this.method = method;
- }
-
- /**
- * This it the valueChange sink<br />
- * The received event will be cloned and collected by the manager.
- */
- public void processValueChange(ValueChangeEvent event)
- throws AbortProcessingException
- {
- UIComponent valueChangeComponent = event.getComponent();
- List restoreStateCommands = new ArrayList();
- collectStates(restoreStateCommands, valueChangeComponent);
-
- ValueChangeEvent clonedEvent = new ValueChangeEvent(
- event.getComponent(),
- event.getOldValue(),
- event.getNewValue());
-
- ValueChangeManager manager = ValueChangeManager.getManager(FacesContext
- .getCurrentInstance());
- manager.addEvent(method, clonedEvent, restoreStateCommands);
- }
-
- protected void collectStates(List restoreStateCommands, UIComponent component)
- {
- while (component != null)
- {
- if (component instanceof UIData)
- {
- final UIData data = (UIData) component;
- final int rowIndex = data.getRowIndex();
-
- restoreStateCommands.add(new RestoreStateCommand()
- {
- int currentRowIndex;
-
- public void saveCurrentState()
- {
- currentRowIndex = data.getRowIndex();
- }
-
- public void restoreCurrentState()
- {
- data.setRowIndex(currentRowIndex);
- }
-
- public void restoreEventState()
- {
- data.setRowIndex(rowIndex);
- }
- });
- }
-
- component = component.getParent();
- }
- }
-
- public Object saveState(FacesContext context)
- {
- return new Object[]
- { this.method};
- }
-
- public void restoreState(FacesContext context, Object state)
- {
- Object[] o = (Object[]) state;
-
- this.method = (String) o[0];
- }
-
- public boolean isTransient()
- {
- return isTransient;
- }
-
- public void setTransient(boolean isTransient)
- {
- this.isTransient = isTransient;
- }
+ public ValueChangeCollector()
+ {
+ }
+
+ protected ValueChangeCollector(String method)
+ {
+ this.method = method;
+ }
+
+ /**
+ * This it the valueChange sink<br />
+ * The received event will be cloned and collected by the manager.
+ */
+ public void processValueChange(ValueChangeEvent event)
+ throws AbortProcessingException
+ {
+ UIComponent valueChangeComponent = event.getComponent();
+ List restoreStateCommands = new ArrayList();
+ collectStates(restoreStateCommands, valueChangeComponent);
+
+ ValueChangeEvent clonedEvent = new ValueChangeEvent(
+ event.getComponent(),
+ event.getOldValue(),
+ event.getNewValue());
+
+ ValueChangeManager manager = ValueChangeManager.getManager(FacesContext
+ .getCurrentInstance());
+ manager.addEvent(method, clonedEvent, restoreStateCommands);
+ }
+
+ protected void collectStates(List restoreStateCommands, UIComponent component)
+ {
+ while (component != null)
+ {
+ if (component instanceof UIData)
+ {
+ final UIData data = (UIData) component;
+ final int rowIndex = data.getRowIndex();
+
+ restoreStateCommands.add(new RestoreStateCommand()
+ {
+ int currentRowIndex;
+
+ public void saveCurrentState()
+ {
+ currentRowIndex = data.getRowIndex();
+ }
+
+ public void restoreCurrentState()
+ {
+ data.setRowIndex(currentRowIndex);
+ }
+
+ public void restoreEventState()
+ {
+ data.setRowIndex(rowIndex);
+ }
+ });
+ }
+
+ component = component.getParent();
+ }
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ return new Object[]
+ { this.method};
+ }
+
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object[] o = (Object[]) state;
+
+ this.method = (String) o[0];
+ }
+
+ public boolean isTransient()
+ {
+ return isTransient;
+ }
+
+ public void setTransient(boolean isTransient)
+ {
+ this.isTransient = isTransient;
+ }
}
\ No newline at end of file