empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1327989 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: app/FacesApplication.java components/TitleTag.java pages/PageDefinitions.java pages/PagePhaseListener.java utils/TagEncodingHelper.java
Date Thu, 19 Apr 2012 15:18:52 GMT
Author: doebele
Date: Thu Apr 19 15:18:51 2012
New Revision: 1327989

URL: http://svn.apache.org/viewvc?rev=1327989&view=rev
Log:
EMPIREDB-140
bugfixes in PagePhaseListener

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TitleTag.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java?rev=1327989&r1=1327988&r2=1327989&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java
Thu Apr 19 15:18:51 2012
@@ -52,8 +52,8 @@ public abstract class FacesApplication e
 {
     private static final Logger    log    = LoggerFactory.getLogger(FacesApplication.class);
     
-    public final String APPLICATION_ATTRIBUTE   = "facesApp";
-    public final String CONNECTION_ATTRIBUTE    = "dbConnections";
+    private static final String APPLICATION_ATTRIBUTE  = "facesApp";
+    private static final String CONNECTION_ATTRIBUTE   = "dbConnections";
     
     protected TextResolver[] textResolvers = null; 
     
@@ -103,7 +103,7 @@ public abstract class FacesApplication e
     
     /* Context handling */
     
-    public void onChangeView(final FacesContext fc, String previousViewId, String viewId)
+    public void onChangeView(final FacesContext fc, String viewId)
     {
         // allow custom view change logic
     }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TitleTag.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TitleTag.java?rev=1327989&r1=1327988&r2=1327989&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TitleTag.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/TitleTag.java
Thu Apr 19 15:18:51 2012
@@ -69,13 +69,13 @@ public class TitleTag extends UIOutput i
         // render components
         ResponseWriter writer = context.getResponseWriter();
         String tag = writeStartElement(title, writer);
-        renderLabel(column, writer);
+        renderTitle(column, writer);
         if (tag != null)
             writer.endElement(tag);
     }
 
     /* Helpers */
-    protected void renderLabel(Column column, ResponseWriter writer) throws IOException
+    protected void renderTitle(Column column, ResponseWriter writer) throws IOException
     {
         String title=null;
         // Check for short form    

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=1327989&r1=1327988&r2=1327989&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
Thu Apr 19 15:18:51 2012
@@ -81,6 +81,16 @@ public abstract class PageDefinitions
             bm.register(mbi);
         }
     }
+    
+    /**
+     * returns true if the view exists in the page map or false otherwise
+     * @param viewId
+     * @return true if the view exists in the page map or false otherwise
+     */
+    public boolean containsView(String viewId)
+    {
+        return pageMap.containsKey(viewId);        
+    }
 
     /**
      * returns the default (welcome) page definition.

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java?rev=1327989&r1=1327988&r2=1327989&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PagePhaseListener.java
Thu Apr 19 15:18:51 2012
@@ -27,7 +27,6 @@ import javax.faces.event.PhaseId;
 import javax.faces.event.PhaseListener;
 
 import org.apache.commons.beanutils.BeanUtils;
-import org.apache.empire.exceptions.ItemNotFoundException;
 import org.apache.empire.jsf2.app.FacesUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -37,12 +36,14 @@ public class PagePhaseListener implement
     private static final long   serialVersionUID       = 1L;
     private static final Logger log                    = LoggerFactory.getLogger(PagePhaseListener.class);
 
-    public static final String  CURRENT_VIEW_ATTRIBUTE = "currentViewId";
-    public static final String  FORWARD_PAGE_PARAMS    = "forwardPageParams";
+    private static final String LAST_PAGE_VIEW_ID      = "lastPageViewId";
+    
+    // FORWARD_PAGE_PARAMS used by PageNavigationHandler
+    public  static final String FORWARD_PAGE_PARAMS    = "forwardPageParams";
 
     public PagePhaseListener()
     {
-        // foo
+        log.trace("PagePhaseListener created.");
     }
 
     @Override
@@ -78,39 +79,36 @@ public class PagePhaseListener implement
 
         // Get the view Id
         String viewId = vr.getViewId();
-        // boolean checkContextPath = false;
-
-        // Check view Change
+        // boolean viewChanged = false;
+        
+        // Detect view change
         Map<String, Object> sessionMap = fc.getExternalContext().getSessionMap();
-        Object lastViewId = sessionMap.get(CURRENT_VIEW_ATTRIBUTE);
+        Object lastViewId = sessionMap.get(LAST_PAGE_VIEW_ID);
         if (lastViewId == null || !(((String) lastViewId).equalsIgnoreCase(viewId)))
         { // view changes
-            FacesUtils.getFacesApplication().onChangeView(fc, (String) lastViewId, viewId);
+            FacesUtils.getFacesApplication().onChangeView(fc, viewId);
             if (fc.getResponseComplete())
                 return;
             // set view Id
-            sessionMap.put(CURRENT_VIEW_ATTRIBUTE, viewId);
+            sessionMap.put(LAST_PAGE_VIEW_ID, viewId);
+            // viewChanged = true;
         }
 
-        // Find Definition for view-id
+        // Get Page Definition
         PageDefinition pageDef = PageDefinitions.getInstance().getPageFromViewId(viewId);
         if (pageDef == null)
-        {
-            pageDef = PageDefinitions.getInstance().getDefaultPage();
-            if (pageDef == null)
-            {
-                log.error("No Page definition Error for path {}", viewId);
-                throw new ItemNotFoundException(viewId);
-            }
-            log.warn("No Page definition for {}. Redirecting to default page.", viewId);
-            FacesUtils.redirectDirectly(fc, pageDef);
+        {   // No page definition available
+            if (log.isDebugEnabled())
+                log.debug("No page definition available for viewId {}.", viewId);
             return;
-        }
+        }    
 
         // Check Request context path 
         /*
-        if (checkContextPath)
-        {   HttpServletRequest req = FacesUtils.getHttpRequest(fc);
+        if (viewChanged)
+        {
+            log.debug("Checking view context path");
+            HttpServletRequest req = FacesUtils.getHttpRequest(fc);
             String reqURI = req.getRequestURI();
             viewId = pageDef.getPath();
             int vix = viewId.lastIndexOf('.');
@@ -126,7 +124,7 @@ public class PagePhaseListener implement
             // Save current viewId
         }
         */
-
+        
         // Init Page
         String name = pageDef.getPageBeanName();
         Map<String, Object> viewMap = vr.getViewMap();
@@ -141,18 +139,17 @@ public class PagePhaseListener implement
                 pageBean = pageDef.getPageBeanClass().newInstance();
                 // List request parameters
                 /*
-                 * FacesContext fc = pe.getFacesContext();
-                 * Map<String, String> map = fc.getExternalContext().getRequestParameterMap();
-                 * for (String key : map.keySet())
-                 * {
-                 * StringBuilder param = new StringBuilder();
-                 * param.append("Parameter: ");
-                 * param.append(key);
-                 * param.append(" = ");
-                 * param.append(map.get(key));
-                 * log.debug(param.toString());
-                 * }
-                 */
+                Map<String, String> map = fc.getExternalContext().getRequestParameterMap();
+                for (String key : map.keySet())
+                {
+                    StringBuilder param = new StringBuilder();
+                    param.append("Parameter: ");
+                    param.append(key);
+                    param.append(" = ");
+                    param.append(map.get(key));
+                    log.debug(param.toString());
+                }
+                */
             }
             catch (Exception e)
             {
@@ -167,12 +164,12 @@ public class PagePhaseListener implement
             initPageBean(pageBean, fc, viewMap);
 
         /*
-         * Collection<UIViewParameter> params = ViewMetadata.getViewParameters(vr);
-         * for (UIViewParameter p : params)
-         * {
-         * log.info("p {} = {}", p.getName(), p.getValue());
-         * }
-         */
+        Collection<UIViewParameter> params = ViewMetadata.getViewParameters(vr);
+        for (UIViewParameter p : params)
+        {
+            log.info("p {} = {}", p.getName(), p.getValue());
+        }
+        */
     }
 
     private void initPageBean(Page pageBean, FacesContext fc, Map<String, Object> viewMap)

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java?rev=1327989&r1=1327988&r2=1327989&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
Thu Apr 19 15:18:51 2012
@@ -809,10 +809,10 @@ public class TagEncodingHelper implement
     {
         Object title = tag.getAttributes().get("title");
         if (title != null)
-            return StringUtils.toString(title);
+            return getDisplayText(StringUtils.toString(title));
         // Check for short form
         if (hasFormat("short") && !ObjectUtils.isEmpty(column.getAttribute(COLATTR_ABBR_TITLE)))
-            return column.getTitle();
+            return getDisplayText(column.getTitle());
         // No Title
         return null;
     }



Mime
View raw message