myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r819240 - in /myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad: ./ initializer/component/ startup/ storage/ storage/mapper/
Date Sun, 27 Sep 2009 01:50:50 GMT
Author: gpetracek
Date: Sun Sep 27 01:50:49 2009
New Revision: 819240

URL: http://svn.apache.org/viewvc?rev=819240&view=rev
Log:
EXTVAL-61 cleanup based on the storage mechanism

Added:
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorage.java
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorageManager.java
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/TrinidadClientValidatorStorage.java
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/mapper/
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/mapper/DefaultClientValidatorStorageNameMapper.java
Modified:
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/ExtValTrinidadValidationPhaseListener.java
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/TrinidadComponentInitializer.java
    myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java

Modified: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/ExtValTrinidadValidationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/ExtValTrinidadValidationPhaseListener.java?rev=819240&r1=819239&r2=819240&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/ExtValTrinidadValidationPhaseListener.java
(original)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/ExtValTrinidadValidationPhaseListener.java
Sun Sep 27 01:50:49 2009
@@ -19,8 +19,10 @@
 package org.apache.myfaces.extensions.validator.trinidad;
 
 import org.apache.myfaces.extensions.validator.trinidad.renderkit.ExtValTrinidadRenderKit;
+import org.apache.myfaces.extensions.validator.trinidad.storage.TrinidadClientValidatorStorage;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
 
 import javax.faces.FactoryFinder;
 import javax.faces.context.FacesContext;
@@ -39,8 +41,12 @@
 @UsageInformation(UsageCategory.INTERNAL)
 public class ExtValTrinidadValidationPhaseListener implements PhaseListener
 {
+    private static final long serialVersionUID = 9109721831864146165L;
+
     public void afterPhase(PhaseEvent event)
     {
+        ExtValUtils.getStorage(TrinidadClientValidatorStorage.class, TrinidadClientValidatorStorage.class.getName())
+                .rollback();
     }
 
     public void beforePhase(PhaseEvent event)

Modified: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/TrinidadComponentInitializer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/TrinidadComponentInitializer.java?rev=819240&r1=819239&r2=819240&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/TrinidadComponentInitializer.java
(original)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/initializer/component/TrinidadComponentInitializer.java
Sun Sep 27 01:50:49 2009
@@ -23,6 +23,8 @@
 import org.apache.myfaces.extensions.validator.internal.Priority;
 import org.apache.myfaces.extensions.validator.internal.UsageInformation;
 import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.trinidad.storage.TrinidadClientValidatorStorage;
 import org.apache.myfaces.trinidad.context.RequestContext;
 
 import javax.faces.component.UIComponent;
@@ -64,11 +66,18 @@
         {
             if(componentInitializer.configureTrinidadComponent(facesContext, uiComponent,
metaData))
             {
+                addComponentToStorage(uiComponent);
                 updateComponent(facesContext, uiComponent);
             }
         }
     }
 
+    private void addComponentToStorage(UIComponent uiComponent)
+    {
+        ExtValUtils.getStorage(TrinidadClientValidatorStorage.class, TrinidadClientValidatorStorage.class.getName())
+                .addComponent(uiComponent);
+    }
+
     protected boolean configureTrinidadComponent(FacesContext facesContext, UIComponent uiComponent,
                                                  Map<String, Object> metaData)
     {

Modified: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java?rev=819240&r1=819239&r2=819240&view=diff
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java
(original)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/startup/TrinidadModuleStartupListener.java
Sun Sep 27 01:50:49 2009
@@ -20,11 +20,14 @@
 
 import org.apache.myfaces.extensions.validator.core.startup.AbstractStartupListener;
 import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.storage.StorageManagerHolder;
 import org.apache.myfaces.extensions.validator.core.renderkit.AbstractRenderKitWrapperFactory;
 import org.apache.myfaces.extensions.validator.core.renderkit.ExtValRendererProxy;
 import org.apache.myfaces.extensions.validator.core.factory.FactoryNames;
 import org.apache.myfaces.extensions.validator.trinidad.initializer.component.TrinidadComponentInitializer;
 import org.apache.myfaces.extensions.validator.trinidad.WebXmlParameter;
+import org.apache.myfaces.extensions.validator.trinidad.storage.TrinidadClientValidatorStorage;
+import org.apache.myfaces.extensions.validator.trinidad.storage.DefaultClientValidatorStorageManager;
 import org.apache.myfaces.extensions.validator.trinidad.validation.message.TrinidadFacesMessageFactory;
 import org.apache.myfaces.extensions.validator.trinidad.renderkit.ExtValTrinidadRendererProxy;
 import org.apache.myfaces.extensions.validator.trinidad.interceptor.TrinidadValidationExceptionInterceptor;
@@ -94,5 +97,10 @@
          */
 
         ExtValContext.getContext().addMetaDataExtractionInterceptor(new TrinidadMetaDataExtractionInterceptor());
+
+        ExtValContext.getContext().getFactoryFinder()
+                .getFactory(FactoryNames.STORAGE_MANAGER_FACTORY, StorageManagerHolder.class)
+                .setStorageManager(TrinidadClientValidatorStorage.class,
+                        new DefaultClientValidatorStorageManager(), false);
     }
 }

Added: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorage.java?rev=819240&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorage.java
(added)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorage.java
Sun Sep 27 01:50:49 2009
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.trinidad.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.trinidad.ExtValTrinidadClientValidatorWrapper;
+
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.validator.Validator;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultClientValidatorStorage implements TrinidadClientValidatorStorage
+{
+    private List<UIComponent> componentList = new ArrayList<UIComponent>();
+
+    public void addComponent(UIComponent trinidadComponent)
+    {
+        if(!this.componentList.contains(trinidadComponent))
+        {
+            this.componentList.add(trinidadComponent);
+        }
+    }
+
+    public void rollback()
+    {
+        for (UIComponent component : this.componentList)
+        {
+            removeTrinidadValidatorWrapper(component);
+        }
+        this.componentList.clear();
+    }
+
+    private void removeTrinidadValidatorWrapper(UIComponent uiComponent)
+    {
+        if (uiComponent instanceof EditableValueHolder)
+        {
+            for (Validator validator : ((EditableValueHolder) uiComponent).getValidators())
+            {
+                if (validator instanceof ExtValTrinidadClientValidatorWrapper)
+                {
+                    ((EditableValueHolder) uiComponent).removeValidator(validator);
+                }
+            }
+        }
+        else
+        {
+            //to keep the source in sync with older versions
+            for (Object child : uiComponent.getChildren())
+            {
+                removeTrinidadValidatorWrapper((UIComponent)child);
+            }
+        }
+    }
+}
\ No newline at end of file

Added: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorageManager.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorageManager.java?rev=819240&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorageManager.java
(added)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/DefaultClientValidatorStorageManager.java
Sun Sep 27 01:50:49 2009
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.trinidad.storage;
+
+import org.apache.myfaces.extensions.validator.core.storage.AbstractRequestScopeAwareStorageManager;
+import org.apache.myfaces.extensions.validator.core.storage.StorageManager;
+import org.apache.myfaces.extensions.validator.trinidad.storage.mapper.DefaultClientValidatorStorageNameMapper;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * default storage-manager for component entries
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultClientValidatorStorageManager
+        extends AbstractRequestScopeAwareStorageManager<TrinidadClientValidatorStorage>
+{
+    public DefaultClientValidatorStorageManager()
+    {
+        register(new DefaultClientValidatorStorageNameMapper());
+    }
+
+    public String getStorageManagerKey()
+    {
+        return StorageManager.class.getName() + "_FOR_TRINIDAD_CLIENT_VALIDATOR:KEY";
+    }
+}

Added: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/TrinidadClientValidatorStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/TrinidadClientValidatorStorage.java?rev=819240&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/TrinidadClientValidatorStorage.java
(added)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/TrinidadClientValidatorStorage.java
Sun Sep 27 01:50:49 2009
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.trinidad.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * extval injects client-validators into trinidad components based on meta-data.
+ * so client-side validation is supported. some app-servers show a different behaviour.
+ * that's the reason for storing these components and remove the injected validators after
the rendering phase.
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public interface TrinidadClientValidatorStorage
+{
+    void addComponent(UIComponent trinidadComponent);
+    void rollback();
+}

Added: myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/mapper/DefaultClientValidatorStorageNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/mapper/DefaultClientValidatorStorageNameMapper.java?rev=819240&view=auto
==============================================================================
--- myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/mapper/DefaultClientValidatorStorageNameMapper.java
(added)
+++ myfaces/extensions/validator/trunk/component-support/trinidad-support/src/main/java/org/apache/myfaces/extensions/validator/trinidad/storage/mapper/DefaultClientValidatorStorageNameMapper.java
Sun Sep 27 01:50:49 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.trinidad.storage.mapper;
+
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.trinidad.storage.TrinidadClientValidatorStorage;
+import org.apache.myfaces.extensions.validator.trinidad.storage.DefaultClientValidatorStorage;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * use a public class to allow optional deregistration
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultClientValidatorStorageNameMapper implements NameMapper<String>
+{
+    public String createName(String source)
+    {
+        return (TrinidadClientValidatorStorage.class.getName().equals(source)) ?
+                DefaultClientValidatorStorage.class.getName() : null;
+    }
+}



Mime
View raw message