empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1351456 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: controls/CheckboxInputControl.java controls/InputControlManager.java pages/PageDefinition.java pages/PageDefinitions.java
Date Mon, 18 Jun 2012 18:43:47 GMT
Author: doebele
Date: Mon Jun 18 18:43:47 2012
New Revision: 1351456

URL: http://svn.apache.org/viewvc?rev=1351456&view=rev
Log:
EMPIREDB-140
allow custom page extensions

Added:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/CheckboxInputControl.java
  (with props)
Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControlManager.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinition.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java

Added: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/CheckboxInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/CheckboxInputControl.java?rev=1351456&view=auto
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/CheckboxInputControl.java
(added)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/CheckboxInputControl.java
Mon Jun 18 18:43:47 2012
@@ -0,0 +1,66 @@
+/*
+ * 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.empire.jsf2.controls;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.html.HtmlSelectBooleanCheckbox;
+import javax.faces.context.FacesContext;
+
+import org.apache.empire.exceptions.InternalException;
+import org.apache.empire.jsf2.controls.InputControl;
+
+public class CheckboxInputControl extends InputControl
+{
+    public static final String NAME = "checkbox";
+
+    private Class<? extends javax.faces.component.html.HtmlSelectBooleanCheckbox> inputComponentClass;
+
+    public CheckboxInputControl(Class<? extends HtmlSelectBooleanCheckbox> inputComponentClass)
+    {
+        super(NAME);
+        this.inputComponentClass = inputComponentClass;
+    }
+
+    public CheckboxInputControl()
+    {
+        this(javax.faces.component.html.HtmlSelectBooleanCheckbox.class);
+    }
+
+    @Override
+    protected void createInputComponents(UIComponent parent, InputInfo ii, FacesContext context,
List<UIComponent> compList)
+    {
+        HtmlSelectBooleanCheckbox input;
+        try
+        {   input = inputComponentClass.newInstance();
+		} catch (InstantiationException e1) {
+			throw new InternalException(e1);
+		} catch (IllegalAccessException e2) {
+			throw new InternalException(e2);
+		}
+        copyAttributes(parent, ii, input);
+        
+        setInputValue(input, ii);
+        input.setDisabled(ii.isDisabled());
+        
+        compList.add(input);
+    }
+
+}

Propchange: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/CheckboxInputControl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControlManager.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControlManager.java?rev=1351456&r1=1351455&r2=1351456&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControlManager.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControlManager.java
Mon Jun 18 18:43:47 2012
@@ -43,8 +43,8 @@ public final class InputControlManager
         registerControl(new TextInputControl());
         registerControl(new SelectInputControl());
         registerControl(new TextAreaInputControl());
+        registerControl(new CheckboxInputControl());
         /*
-        registerControl("checkbox", new CheckboxInputControl());
         registerControl("phone",    new PhoneInputControl());
         registerControl("radio",    new RadioInputControl());
         registerControl("email",    new EMailInputControl());

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinition.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinition.java?rev=1351456&r1=1351455&r2=1351456&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinition.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinition.java
Mon Jun 18 18:43:47 2012
@@ -81,9 +81,9 @@ public class PageDefinition
         this.path = path;
         this.pageBeanClass = pageBeanClass;
         // beanName 
-        int lastSlash = path.lastIndexOf("/");
+        int lastSlash = path.lastIndexOf('/');
         String name = path.substring(lastSlash + 1);
-        this.pageBeanName = name.replace(".xhtml", "Page");
+        pageBeanName = name.replace(".xhtml", "Page");
         // add this view
         PageDefinitions.registerPage(this);
     }
@@ -118,7 +118,11 @@ public class PageDefinition
     
     public PageOutcome getOutcome()
     {
-        return new PageOutcome(path.replace(".xhtml", ".iface"));
+    	String uri = path;
+    	String extension = PageDefinitions.getInstance().getPageUriExtension();
+    	if (extension!=null)
+    		uri = path.replace(".xhtml", extension);
+        return new PageOutcome(uri);
     }
     
     public PageOutcome getOutcome(String action)

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java?rev=1351456&r1=1351455&r2=1351456&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
Mon Jun 18 18:43:47 2012
@@ -35,12 +35,14 @@ public abstract class PageDefinitions
     private static LinkedHashMap<String,PageDefinition> pageMap = new LinkedHashMap<String,PageDefinition>();
     
     private static PageDefinitions instance = null;
-    
-    public static PageDefinitions getInstance()
+
+	public static PageDefinitions getInstance()
     {
         return instance;
     }
-
+    
+    protected String pageUriExtension = null; // ".jsf";  
+	
     protected PageDefinitions()
     {
         if (instance!=null) 
@@ -52,6 +54,11 @@ public abstract class PageDefinitions
         log.info("PageDefintions class created");
     }
     
+    public String getPageUriExtension() 
+    {
+		return pageUriExtension;
+	}
+    
     /**
      * Register page beans with the BeanManager
      * @param bm
@@ -113,8 +120,11 @@ public abstract class PageDefinitions
         // Empty-String == default page
         if (StringUtils.isEmpty(viewId))
             return getDefaultPage();
+        // remove extension
+        int ext = viewId.lastIndexOf('.');
+        if (ext>0)
+        	viewId = viewId.substring(0,ext);
         // find in map
-        viewId = viewId.replace(".iface", ".xhtml");
         PageDefinition view = pageMap.get(viewId);
         if (view==null)
             log.error("No page defintion for viewId {}", viewId);
@@ -129,11 +139,16 @@ public abstract class PageDefinitions
     protected static void registerPage(PageDefinition pageDef)
     {
         String name = pageDef.getPath();
+        int ext = name.lastIndexOf('.');
+        if (ext>0)
+        	name = name.substring(0,ext);
+        // Check Name
         if (pageMap.containsKey(name))
         {
             throw new RuntimeException("Page of name "+name+" already defined!");
         }
         log.info("Registering view '{}'.", name);
+        // Register Name
         pageMap.put(name, pageDef);
     }
 }



Mime
View raw message