[weld-commits] Weld SVN: r6461 - in examples/trunk/jsf/pastecode/src/main: webapp and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Jun 16 15:33:43 EDT 2010


Author: pete.muir at jboss.org
Date: 2010-06-16 15:33:43 -0400 (Wed, 16 Jun 2010)
New Revision: 6461

Added:
   examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/Paginator.java
Removed:
   examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/QueryInfo.java
Modified:
   examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManager.java
   examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java
   examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/History.java
   examples/trunk/jsf/pastecode/src/main/webapp/pagination.xhtml
Log:
Rename QueryInfo

Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManager.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManager.java	2010-06-16 19:26:39 UTC (rev 6460)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManager.java	2010-06-16 19:33:43 UTC (rev 6461)
@@ -36,5 +36,5 @@
 
    public List<CodeFragment> getRecentCodeFragments();
 
-   public List<CodeFragment> searchCodeFragments(CodeFragment code, int page, QueryInfo info);
+   public List<CodeFragment> searchCodeFragments(CodeFragment code, int page, Paginator info);
 }

Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java	2010-06-16 19:26:39 UTC (rev 6460)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java	2010-06-16 19:33:43 UTC (rev 6461)
@@ -28,8 +28,6 @@
 import java.util.List;
 
 import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
 import javax.enterprise.inject.Produces;
 import javax.inject.Inject;
 import javax.inject.Named;
@@ -156,14 +154,7 @@
       return codes;
    }
 
-   /**
-    * getting codes from database needs new transaction so that we can further
-    * modify returned Codes without affecting database (when we call this
-    * function from another session bean
-    */
-   
-   @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
-   public List<CodeFragment> searchCodeFragments(CodeFragment code, int page, QueryInfo info)
+   public List<CodeFragment> searchCodeFragments(CodeFragment code, int page, Paginator paginator)
    {
       StringBuilder sb = new StringBuilder();
 
@@ -213,9 +204,9 @@
       @SuppressWarnings("unchecked")
       List<CodeFragment> codes = q.getResultList();
 
-      info.setPage(page);
-      info.setRecordsCount(allRecords);
-      info.setPagesCount(allRecords / PAGE_SIZE);
+      paginator.setPage(page);
+      paginator.setRecordsCount(allRecords);
+      paginator.setPagesCount(allRecords / PAGE_SIZE);
 
       return codes;
    }

Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/History.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/History.java	2010-06-16 19:26:39 UTC (rev 6460)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/History.java	2010-06-16 19:33:43 UTC (rev 6461)
@@ -50,7 +50,7 @@
    @Inject
    private CodeFragmentManager codeFragmentManager;
 
-   private QueryInfo info;
+   private Paginator paginator;
 
    private List<CodeFragment> codes;
 
@@ -85,12 +85,12 @@
    // Do the search, called as a "page action"
    public String search()
    {
-      this.info = new QueryInfo();
+      this.paginator = new Paginator();
       this.codes = null;
       
       // Perform a seach
       
-      this.codes = codeFragmentManager.searchCodeFragments(this.codeFragmentPrototype, this.page, this.info);
+      this.codes = codeFragmentManager.searchCodeFragments(this.codeFragmentPrototype, this.page, this.paginator);
 
       for (int i = 0; i != this.codes.size(); i++)
       {
@@ -110,13 +110,13 @@
       this.page = page;
    }
 
-   public QueryInfo getInfo()
+   public Paginator getPaginator()
    {
-      return info;
+      return paginator;
    }
 
-   public void setInfo(QueryInfo info)
+   public void setPaginator(Paginator paginator)
    {
-      this.info = info;
+      this.paginator = paginator;
    }
 }

Copied: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/Paginator.java (from rev 6452, examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/QueryInfo.java)
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/Paginator.java	                        (rev 0)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/Paginator.java	2010-06-16 19:33:43 UTC (rev 6461)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.weld.examples.pastecode.session;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Paginator
+{
+
+   private int recordsCount = 0;
+   private int pagesCount = 0;
+   private int numLinks = 8;
+   private int startIndex;
+   private int endIndex;
+   private int page = 0;
+   private List<Integer> indexes;
+
+   public int getNumLinks()
+   {
+      return numLinks;
+   }
+
+   public int getPage()
+   {
+      return page;
+   }
+
+   public void setPage(int page)
+   {
+      this.page = page;
+   }
+
+   public int getPagesCount()
+   {
+      return pagesCount;
+   }
+
+   public void setPagesCount(int pagesCount)
+   {
+      this.pagesCount = pagesCount;
+
+      if (pagesCount == 1)
+      {
+         this.setBoundedIndexes(0, 0);
+      }
+
+      if (this.page > (numLinks / 2))
+      {
+         this.setStartIndex(this.page - (numLinks / 2));
+      }
+      else
+      {
+         this.setStartIndex(0);
+         this.setEndIndex((numLinks > this.pagesCount) ? this.pagesCount : numLinks);
+      }
+
+      if (this.page + (numLinks / 2) >= this.pagesCount)
+      {
+         this.setEndIndex(this.pagesCount);
+         this.setStartIndex((this.pagesCount - numLinks) < 0 ? 0 : this.pagesCount - numLinks);
+      }
+      else
+      {
+         if (this.page < (numLinks / 2))
+         {
+            this.setEndIndex((numLinks > this.pagesCount) ? this.pagesCount : numLinks);
+         }
+         else
+         {
+            this.setEndIndex(this.page + (numLinks / 2));
+         }
+
+      }
+      this.setBoundedIndexes(this.startIndex, this.endIndex);
+   }
+
+   public void setBoundedIndexes(int startIndex, int endIndex)
+   {
+      this.indexes = new ArrayList<Integer>(endIndex - startIndex);
+      for (int i = startIndex; i <= endIndex; i++)
+      {
+         this.indexes.add(new Integer(i));
+      }
+   }
+
+   public List<Integer> getIndexes()
+   {
+      return indexes;
+   }
+
+   public void setIndexes(List<Integer> indexes)
+   {
+      this.indexes = indexes;
+   }
+
+   public int getRecordsCount()
+   {
+      return recordsCount;
+   }
+
+   public void setRecordsCount(int recordsCount)
+   {
+      this.recordsCount = recordsCount;
+   }
+
+   public int getStartIndex()
+   {
+      return startIndex;
+   }
+
+   public void setStartIndex(int startIndex)
+   {
+      this.startIndex = startIndex;
+   }
+
+   public int getEndIndex()
+   {
+      return endIndex;
+   }
+
+   public void setEndIndex(int endIndex)
+   {
+      this.endIndex = endIndex;
+   }
+}

Deleted: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/QueryInfo.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/QueryInfo.java	2010-06-16 19:26:39 UTC (rev 6460)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/QueryInfo.java	2010-06-16 19:33:43 UTC (rev 6461)
@@ -1,145 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.weld.examples.pastecode.session;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class QueryInfo
-{
-   
-   private int recordsCount = 0;
-   private int pagesCount = 0;
-   private int numLinks = 8;
-   private int startIndex;
-   private int endIndex;
-   private int page = 0;
-   private List<Integer> indexes;
-
-   public int getNumLinks()
-   {
-      return numLinks;
-   }
-
-   public int getPage()
-   {
-      return page;
-   }
-
-   public void setPage(int page)
-   {
-      this.page = page;
-   }
-
-   public int getPagesCount()
-   {
-      return pagesCount;
-   }
-
-   public void setPagesCount(int pagesCount)
-   {
-      this.pagesCount = pagesCount;
-
-      if (pagesCount == 1)
-      {
-         this.setBoundedIndexes(0, 0);
-      }
-
-      if (this.page > (numLinks / 2))
-      {
-         this.setStartIndex(this.page - (numLinks / 2));
-      }
-      else
-      {
-         this.setStartIndex(0);
-         this.setEndIndex((numLinks > this.pagesCount) ? this.pagesCount : numLinks);
-      }
-
-      if (this.page + (numLinks / 2) >= this.pagesCount)
-      {
-         this.setEndIndex(this.pagesCount);
-         this.setStartIndex((this.pagesCount - numLinks) < 0 ? 0 : this.pagesCount - numLinks);
-      }
-      else
-      {
-         if (this.page < (numLinks / 2))
-         {
-            this.setEndIndex((numLinks > this.pagesCount) ? this.pagesCount : numLinks);
-         }
-         else
-         {
-            this.setEndIndex(this.page + (numLinks / 2));
-         }
-
-      }
-      this.setBoundedIndexes(this.startIndex, this.endIndex);
-   }
-
-   public void setBoundedIndexes(int startIndex, int endIndex)
-   {
-      this.indexes = new ArrayList(endIndex - startIndex);
-      for (int i = startIndex; i <= endIndex; i++)
-      {
-         this.indexes.add(new Integer(i));
-      }
-   }
-
-   public List<Integer> getIndexes()
-   {
-      return indexes;
-   }
-
-   public void setIndexes(List<Integer> indexes)
-   {
-      this.indexes = indexes;
-   }
-
-   public int getRecordsCount()
-   {
-      return recordsCount;
-   }
-
-   public void setRecordsCount(int recordsCount)
-   {
-      this.recordsCount = recordsCount;
-   }
-
-   public int getStartIndex()
-   {
-      return startIndex;
-   }
-
-   public void setStartIndex(int startIndex)
-   {
-      this.startIndex = startIndex;
-   }
-
-   public int getEndIndex()
-   {
-      return endIndex;
-   }
-
-   public void setEndIndex(int endIndex)
-   {
-      this.endIndex = endIndex;
-   }
-}

Modified: examples/trunk/jsf/pastecode/src/main/webapp/pagination.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/pagination.xhtml	2010-06-16 19:26:39 UTC (rev 6460)
+++ examples/trunk/jsf/pastecode/src/main/webapp/pagination.xhtml	2010-06-16 19:33:43 UTC (rev 6461)
@@ -6,22 +6,22 @@
 
 	<ui:composition>
 	
-		<h:panelGroup rendered="#{history.info.pagesCount gt 1}">
+		<h:panelGroup rendered="#{history.paginator.pagesCount gt 1}">
 		<div id="paging" style="width:99%;text-align:center;">
 				
-				<a href="history.jsf?page=#{(history.info.page-1)>=0?(history.info.page-1):0}" style="text-decoration:none;">
+				<a href="history.jsf?page=#{(history.paginator.page-1)>=0?(history.paginator.page-1):0}" style="text-decoration:none;">
 					<span id="edgelink">&lt;&lt;</span>
 				</a>
 				&nbsp;
 				
-				<ui:repeat var="page" value="#{history.info.indexes}">
+				<ui:repeat var="page" value="#{history.paginator.indexes}">
     				<a href="history.jsf?page=#{page}" style="text-decoration:none;">
-    					<span id="normallink" style="width:23px;display: inline-block;}">#{(history.info.page eq page)?'(':''}#{page+1}#{(history.info.page eq page)?')':''}</span>
+    					<span id="normallink" style="width:23px;display: inline-block;}">#{(history.paginator.page eq page)?'(':''}#{page+1}#{(history.paginator.page eq page)?')':''}</span>
     				</a>
 				</ui:repeat>
 				
 				&nbsp;
-				<a href="history.jsf?page=#{(history.info.page+1)>history.info.pagesCount?history.info.pagesCount:(history.info.page+1)}" style="text-decoration:none;">
+				<a href="history.jsf?page=#{(history.paginator.page+1)>history.paginator.pagesCount?history.paginator.pagesCount:(history.paginator.page+1)}" style="text-decoration:none;">
 					<span id="edgelink">&gt;&gt;</span>
 				</a>
 				



More information about the weld-commits mailing list