Weld SVN: r6483 - in examples/trunk/jsf/pastecode/src/main: webapp and 1 other directories.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-06-18 07:35:05 -0400 (Fri, 18 Jun 2010)
New Revision: 6483
Modified:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/Paginator.java
examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml
examples/trunk/jsf/pastecode/src/main/webapp/history.xhtml
examples/trunk/jsf/pastecode/src/main/webapp/pagination.xhtml
examples/trunk/jsf/pastecode/src/main/webapp/style/style.css
Log:
updated history and pagination styles
Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/Paginator.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/Paginator.java 2010-06-18 09:57:12 UTC (rev 6482)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/Paginator.java 2010-06-18 11:35:05 UTC (rev 6483)
@@ -97,7 +97,7 @@
public void setBoundedIndexes(int startIndex, int endIndex)
{
this.indexes = new ArrayList<Integer>(endIndex - startIndex);
- for (int i = startIndex; i <= endIndex; i++)
+ for (int i = startIndex; i < endIndex; i++)
{
this.indexes.add(new Integer(i));
}
Modified: examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml 2010-06-18 09:57:12 UTC (rev 6482)
+++ examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml 2010-06-18 11:35:05 UTC (rev 6483)
@@ -49,7 +49,7 @@
<!--h:outputLabel for="unwrap" value="Unwrap code: "/>
<h:selectBooleanCheckbox id="unwrap" onchange="unwrap('codearea');"/-->
- <div id="codearea" style="width:99%; border: 1px solid #7F7F7F; height:450px; overflow:scroll;">
+ <div class="displayCode">
<pre class="brush: #{pasteWindow.codeFragment.language.brush}">#{pasteWindow.codeFragment.text}</pre>
</div>
Modified: examples/trunk/jsf/pastecode/src/main/webapp/history.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/history.xhtml 2010-06-18 09:57:12 UTC (rev 6482)
+++ examples/trunk/jsf/pastecode/src/main/webapp/history.xhtml 2010-06-18 11:35:05 UTC (rev 6483)
@@ -13,52 +13,46 @@
</f:metadata>
</ui:define>
- <ui:define name="themes">
- </ui:define>
+ <ui:define name="themes"/>
<ui:define name="mainarea">
- <div style="width: 100%; padding: 7px;">
+
+ <div class="paging">
+ <ui:include src="pagination.xhtml"/>
+ </div>
+
+ <ui:repeat value="#{history.codes}" var="codeFragment">
+ <div class="contentHeader">
+ <span>Posted by </span>
+ <h:outputLink id="user" value="#{codeFragment.id}">
+ <!-- display.jsf?id= -->
+ <h:outputText value="#{codeFragment.user}"></h:outputText>
+ </h:outputLink>
+ <span> on </span>
+ <h:outputText id="datetime" value="#{codeFragment.datetime}">
+ <f:convertDateTime type="both" pattern="d MMM yyyy 'at' h:mma" />
+ </h:outputText>
- <div id="paging"
- style="width: 98%; border-width: 0px; background-color: #C1C1E8;">
- <!-- height: 40px; --> <ui:include src="pagination.xhtml"></ui:include>
+ <div style="float:right">
+ Language: #{codeFragment.language.name}
+ </div>
+ </div>
+
+ <h:outputText value="Code (truncated): " />
+
+ <div class="historyCode">
+ <pre>
+ <h:outputText value="#{codeFragment.text}">
+ <f:converter converterId="truncatingConverter"/>
+ </h:outputText>
+ </pre>
+ </div>
+
+ </ui:repeat>
+
+ <div class="paging">
+ <ui:include src="pagination.xhtml"/>
</div>
- <br />
- <h:dataTable value="#{history.codes}" var="codeFragment" width="99%">
- <h:column>
- <div id="searched"><h:panelGroup>
- <h:outputLabel for="user" value="User: " />
- <h:outputLink id="user" value="#{codeFragment.id}">
- <!-- display.jsf?id= -->
- <h:outputText value="#{codeFragment.user}"></h:outputText>
- </h:outputLink>
- </h:panelGroup> <h:panelGroup>
- <h:outputLabel for="language" value="Language: " />
- <h:outputText id="language" value="#{codeFragment.language.name}"></h:outputText>
- </h:panelGroup> <h:panelGroup>
- <h:outputLabel for="datetime" value="Date: " />
- <h:outputText id="datetime" value="#{codeFragment.datetime}">
- <f:convertDateTime type="both" pattern="yyyy-MM-dd HH:mm:ss" />
- </h:outputText>
- </h:panelGroup></div>
- <br />
- <h:outputText value="Code (truncated): " />
- <div
- style="height: 100px; width: 99%; border: 1px solid #7F7F7F; overflow: auto; padding: 1px;">
- <pre>
- <h:outputText value="#{codeFragment.text}">
- <f:converter converterId="truncatingConverter"/>
- </h:outputText>
- </pre></div>
- <br />
- <br />
- </h:column>
- </h:dataTable> <br />
- <div id="paging"
- style="width: 98%; border-width: 0px; background-color: #C1C1E8;">
- <!-- height: 40px; --> <ui:include src="pagination.xhtml"></ui:include>
- </div>
- </div>
</ui:define>
Modified: examples/trunk/jsf/pastecode/src/main/webapp/pagination.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/pagination.xhtml 2010-06-18 09:57:12 UTC (rev 6482)
+++ examples/trunk/jsf/pastecode/src/main/webapp/pagination.xhtml 2010-06-18 11:35:05 UTC (rev 6483)
@@ -6,28 +6,33 @@
<ui:composition>
- <h:panelGroup rendered="#{history.paginator.pagesCount gt 1}">
- <div id="paging" style="width:99%;text-align:center;">
+ <ui:fragment rendered="#{history.paginator.pagesCount gt 1}">
+
+ <span>Page #{history.paginator.page + 1} of #{history.paginator.pagesCount}</span>
+
+ <div style="float:right">
+ <ui:fragment rendered="#{history.paginator.page ge 1}">
+ <a href="history.jsf?page=#{(history.paginator.page-1)}" class="pagination">Prev</a>
+ </ui:fragment>
- <a href="history.jsf?page=#{(history.paginator.page-1)>=0?(history.paginator.page-1):0}" style="text-decoration:none;">
- <span id="edgelink"><<</span>
- </a>
-
-
<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.paginator.page eq page)?'(':''}#{page+1}#{(history.paginator.page eq page)?')':''}</span>
- </a>
+ <ui:fragment rendered="#{history.paginator.page eq page}">
+ <span class="currentPage">#{page+1}</span>
+ </ui:fragment>
+ <ui:fragment rendered="#{history.paginator.page ne page}">
+ <a href="history.jsf?page=#{page}" class="pagination">#{page+1}</a>
+ </ui:fragment>
+
</ui:repeat>
-
- <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">>></span>
- </a>
+ <ui:fragment rendered="#{history.paginator.page lt (history.paginator.pagesCount-1)}">
+ <a href="history.jsf?page=#{(history.paginator.page+1)}" class="pagination">Next</a>
+ </ui:fragment>
- </div>
- </h:panelGroup>
+ </div>
+
+ </ui:fragment>
</ui:composition>
-</html>
\ No newline at end of file
+</html>
Modified: examples/trunk/jsf/pastecode/src/main/webapp/style/style.css
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/style/style.css 2010-06-18 09:57:12 UTC (rev 6482)
+++ examples/trunk/jsf/pastecode/src/main/webapp/style/style.css 2010-06-18 11:35:05 UTC (rev 6483)
@@ -149,7 +149,7 @@
color: #ff0000;
}
-/** Recent pastes styles */
+/* Recent pastes styles */
div.recentPastes {
width: 230px;
@@ -190,7 +190,7 @@
color: #000000;
}
-/** Search params styles */
+/* Search params styles */
div.searchParams {
width: 230px;
@@ -243,3 +243,44 @@
padding: 4px 8px 16px 2px;
}
+/* Code listing styles */
+
+div.displayCode {
+ width: 99%;
+ border: 1px solid #7f7f7f;
+ height: 450px;
+ overflow: scroll;
+ padding: 1px;
+}
+
+div.historyCode {
+ width: 99%;
+ border: 1px solid #7f7f7f;
+ height: 120px;
+ overflow: auto;
+ padding: 1px;
+ margin-bottom: 22px;
+}
+
+/* Pagination styles */
+
+div.paging {
+ font-size: 12px;
+ margin-bottom: 4px;
+}
+
+.currentPage {
+ text-decoration: underline;
+ margin-left: 2px;
+ margin-right: 2px;
+}
+
+a.pagination, a.pagination:visited {
+ color: #aaaaaa;
+ text-decoration: none;
+}
+
+a.pagination:hover {
+ color: #777777;
+ text-decoration: none;
+}
14 years, 7 months
Weld SVN: r6482 - in examples/trunk/jsf/pastecode/src/main/webapp: img and 1 other directories.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-06-18 05:57:12 -0400 (Fri, 18 Jun 2010)
New Revision: 6482
Added:
examples/trunk/jsf/pastecode/src/main/webapp/img/search.png
Modified:
examples/trunk/jsf/pastecode/src/main/webapp/history.xhtml
examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml
examples/trunk/jsf/pastecode/src/main/webapp/style/style.css
Log:
start restyling history page
Modified: examples/trunk/jsf/pastecode/src/main/webapp/history.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/history.xhtml 2010-06-17 19:54:38 UTC (rev 6481)
+++ examples/trunk/jsf/pastecode/src/main/webapp/history.xhtml 2010-06-18 09:57:12 UTC (rev 6482)
@@ -64,40 +64,49 @@
<ui:define name="rightmenu">
- <div id="rightmenuhead" style="width: 350px;"><strong>Search:</strong>
- </div>
+ <div class="searchParams">
+ <div class="searchParamsHeader">Refine search</div>
- <div id="rightmenubody" style="width: 350px;"><h:panelGrid
- cellpadding="0" cellspacing="0" columns="2" width="100%">
- <h:outputLabel for="user" value="User:"></h:outputLabel>
- <h:inputText id="user" maxlength="30" style="width:97%;"
- value="#{history.codeFragmentPrototype.user}" />
- <h:outputLabel for="language" value="Language:" />
- <h:selectOneMenu id="language" value="#{history.codeFragmentPrototype.language}">
- <f:selectItem itemLabel="Any" itemValue="" />
- <f:selectItems value="#{languages}" var="language"
- itemLabel="#{language.name}" itemValue="#{language}" />
- </h:selectOneMenu>
- <h:outputLabel for="note" value="Note:"></h:outputLabel>
- <h:inputText id="note" maxlength="30" style="width:97%;"
- value="#{history.codeFragmentPrototype.note}" />
- <h:outputLabel for="pasteDate" value="Date: " />
- <h:inputText value="#{history.codeFragmentPrototype.datetime}" id="pasteDate"
- style="width:97%;" alt="yyyy-mm-dd" title="yyyy-mm-dd"
- converterMessage="Enter date formatted as yyyy-mm-dd !">
- <f:convertDateTime type="date" pattern="yyyy-MM-dd" />
- </h:inputText>
- <h:outputLabel for="code" value="Code:" style="width:100%;"></h:outputLabel>
- <h:inputTextarea id="code" maxlength="30" rows="2" style="width:97%;"
- value="#{history.codeFragmentPrototype.text}">
- <f:validateBean disabled="true" />
- </h:inputTextarea>
- </h:panelGrid>
- <div style="width: 100%; text-align: right;"><h:commandButton
- value="Search" action="#{history.newSearch}" /></div>
- <br />
- <h:message for="pasteDate" /></div>
+ <div class="searchParam">
+ <h:outputLabel for="user" value="User:"/>
+ <h:inputText id="user" maxlength="30" value="#{history.codeFragmentPrototype.user}" />
+ </div>
+ <div class="searchParam">
+ <h:outputLabel for="language" value="Language:" />
+ <h:selectOneMenu id="language" value="#{history.codeFragmentPrototype.language}">
+ <f:selectItem itemLabel="Any" itemValue="" />
+ <f:selectItems value="#{languages}" var="language"
+ itemLabel="#{language.name}" itemValue="#{language}" />
+ </h:selectOneMenu>
+ </div>
+
+ <div class="searchParam">
+ <h:outputLabel for="pasteDate" value="Date: " />
+ <h:inputText value="#{history.codeFragmentPrototype.datetime}" id="pasteDate"
+ alt="yyyy-mm-dd" title="yyyy-mm-dd"
+ converterMessage="Enter date formatted as yyyy-mm-dd !">
+ <f:convertDateTime type="date" pattern="yyyy-MM-dd" />
+ </h:inputText>
+ </div>
+
+ <div class="searchParam">
+ <h:outputLabel for="code" value="Code:" style="width:100%;"/>
+ <h:inputTextarea id="code" maxlength="30" rows="2"
+ value="#{history.codeFragmentPrototype.text}">
+ <f:validateBean disabled="true" />
+ </h:inputTextarea>
+ </div>
+
+ <div class="searchParamButtons">
+ <h:commandButton action="#{history.newSearch}" image="img/search.png"/>
+ </div>
+
+ <h:message for="pasteDate" />
+
+ <br style="clear:both"/>
+ </div>
+
</ui:define>
</ui:composition>
Modified: examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml 2010-06-17 19:54:38 UTC (rev 6481)
+++ examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml 2010-06-18 09:57:12 UTC (rev 6482)
@@ -26,7 +26,7 @@
</div>
<div class="formRow">
- <h:outputLabel for="secured" value="Exposure"/>
+ <h:outputLabel for="exposure" value="Exposure"/>
<h:selectOneMenu id="exposure" value="#{pasteWindow.privateFragment}">
<f:selectItem itemValue="#{true}" itemLabel="Private"/>
<f:selectItem itemValue="#{false}" itemLabel="Public"/>
Added: examples/trunk/jsf/pastecode/src/main/webapp/img/search.png
===================================================================
(Binary files differ)
Property changes on: examples/trunk/jsf/pastecode/src/main/webapp/img/search.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: examples/trunk/jsf/pastecode/src/main/webapp/style/style.css
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/style/style.css 2010-06-17 19:54:38 UTC (rev 6481)
+++ examples/trunk/jsf/pastecode/src/main/webapp/style/style.css 2010-06-18 09:57:12 UTC (rev 6482)
@@ -116,7 +116,6 @@
div.formRow {
padding: 3px 4px 3px 2px;
-/* clear: both;*/
}
div.formRow label {
@@ -191,5 +190,56 @@
color: #000000;
}
+/** Search params styles */
+div.searchParams {
+ width: 230px;
+ background-color: #ffffff;
+ padding: 0px;
+ border: 0px;
+}
+div.searchParamsHeader {
+ background-color: #cccccc;
+ color: #000000;
+ font-weight: bold;
+ padding: 4px;
+ border: 0px;
+}
+
+div.searchParam {
+ padding: 3px 4px 3px 2px;
+}
+
+div.searchParam label {
+ float: left;
+ width: 100px;
+ padding: 4px 2px 2px 2px;
+}
+
+div.searchParam input[type='text'] {
+ width: 100px;
+ background-color: #fafafc;
+ border: 1px solid #cccccc;
+ padding: 4px;
+}
+
+div.searchParam textarea {
+ width: 210px;
+ background-color: #fafafc;
+ border: 1px solid #cccccc;
+ padding: 4px;
+}
+
+div.searchParam select {
+ width: 110px;
+ background-color: #fafafc;
+ border: 1px solid #cccccc;
+ padding: 4px;
+}
+
+div.searchParamButtons {
+ float: right;
+ padding: 4px 8px 16px 2px;
+}
+
14 years, 7 months
Weld SVN: r6481 - in examples/trunk/jsf/pastecode/src/main: java/org/jboss/weld/examples/pastecode/session and 1 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-06-17 15:54:38 -0400 (Thu, 17 Jun 2010)
New Revision: 6481
Removed:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/AccessLog.java
Modified:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeFragment.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/DatabasePopulater.java
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PasteWindow.java
examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml
Log:
add messages, remove Note, AccessLog
Deleted: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/AccessLog.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/AccessLog.java 2010-06-17 18:44:00 UTC (rev 6480)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/AccessLog.java 2010-06-17 19:54:38 UTC (rev 6481)
@@ -1,97 +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.model;
-
-import static javax.persistence.GenerationType.AUTO;
-
-import java.util.Date;
-
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-@Entity
-public class AccessLog
-{
-
- @Id @GeneratedValue(strategy = AUTO)
- private int id;
-
- @Temporal(TemporalType.TIMESTAMP)
- private Date datetime;
-
- @ManyToOne
- private CodeFragment codeFragment;
-
- private String access;
-
- public AccessLog(CodeFragment codeFragment, Date dateTime, String access)
- {
- this.codeFragment = codeFragment;
- this.datetime = dateTime;
- this.access = access;
- }
-
- public int getId()
- {
- return id;
- }
-
- public void setId(int id)
- {
- this.id = id;
- }
-
- public CodeFragment getCodeFragment()
- {
- return codeFragment;
- }
-
- public void setCodeFragment(CodeFragment codeFragment)
- {
- this.codeFragment = codeFragment;
- }
-
- public String getAccess()
- {
- return access;
- }
-
- public void setAccess(String access)
- {
- this.access = access;
- }
-
- public Date getDatetime()
- {
- return this.datetime;
- }
-
- public void setDatetime(Date datetime)
- {
- this.datetime = datetime;
- }
-
-}
Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeFragment.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeFragment.java 2010-06-17 18:44:00 UTC (rev 6480)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeFragment.java 2010-06-17 19:54:38 UTC (rev 6481)
@@ -25,9 +25,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.List;
-import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@@ -35,7 +33,6 @@
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Lob;
-import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
@@ -67,9 +64,6 @@
private Language language;
@Lob
- private String note;
-
- @Lob
@Size(min=1, message="Must enter some text!")
private String text;
@@ -77,9 +71,6 @@
private String hash;
- @OneToMany(mappedBy = "codeFragment", cascade = CascadeType.REMOVE)
- List<AccessLog> largeCodeFragmentAccessLog;
-
public int getId()
{
return id;
@@ -174,16 +165,6 @@
this.language = language;
}
- public String getNote()
- {
- return this.note;
- }
-
- public void setNote(String note)
- {
- this.note = note;
- }
-
public String getText()
{
return this.text;
@@ -203,14 +184,4 @@
{
this.user = user;
}
-
- public List<AccessLog> getLargeCodeFragmentAccessLog()
- {
- return largeCodeFragmentAccessLog;
- }
-
- public void setLargeCodeFragmentAccessLog(List<AccessLog> largeCodeFragmentAccessLog)
- {
- this.largeCodeFragmentAccessLog = largeCodeFragmentAccessLog;
- }
}
\ No newline at end of file
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-17 18:44:00 UTC (rev 6480)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java 2010-06-17 19:54:38 UTC (rev 6481)
@@ -192,10 +192,6 @@
{
predicates.add( builder.equal(root.get(CodeFragment_.language), codeFragment.getLanguage()) );
}
- if (!isEmpty(codeFragment.getNote()))
- {
- predicates.add( builder.like(root.get(CodeFragment_.note), codeFragment.getNote().toLowerCase()) );
- }
if (!isEmpty(codeFragment.getText()))
{
predicates.add( builder.like(root.get(CodeFragment_.text), codeFragment.getText().toLowerCase()) );
Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java 2010-06-17 18:44:00 UTC (rev 6480)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java 2010-06-17 19:54:38 UTC (rev 6481)
@@ -81,8 +81,8 @@
st.nextToken();
c.setLanguage(Language.valueOf(st.nextToken()));
st.nextToken();
- c.setNote(st.nextToken());
st.nextToken();
+ st.nextToken();
c.setUser(st.nextToken());
st.nextToken();
c.setText(st.nextToken());
Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PasteWindow.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PasteWindow.java 2010-06-17 18:44:00 UTC (rev 6480)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PasteWindow.java 2010-06-17 19:54:38 UTC (rev 6481)
@@ -22,8 +22,9 @@
package org.jboss.weld.examples.pastecode.session;
import javax.ejb.EJBException;
-import javax.enterprise.inject.Model;
+import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
+import javax.inject.Named;
import org.jboss.weld.examples.pastecode.model.CodeFragment;
@@ -31,7 +32,8 @@
* PasteWindow holds the code fragment and other selections when a code fragment is viewed and entered
*
*/
-@Model
+@Named
+@RequestScoped
public class PasteWindow
{
private CodeFragment codeFragment;
Modified: examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml 2010-06-17 18:44:00 UTC (rev 6480)
+++ examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml 2010-06-17 19:54:38 UTC (rev 6481)
@@ -14,7 +14,7 @@
<ui:define name="mainarea">
- <div class="contentHeader">Post a new PasteCode</div>
+ <div class="contentHeader">Post a new PasteCode <h:messages style="color: red" /></div>
<h:inputTextarea id="text" styleClass="pastecode" value="#{pasteWindow.codeFragment.text}"/>
14 years, 7 months
Weld SVN: r6480 - in examples/trunk/jsf/pastecode/src/main: webapp and 1 other directory.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-06-17 14:44:00 -0400 (Thu, 17 Jun 2010)
New Revision: 6480
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/HashComputer.java
examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml
Log:
minor
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-17 17:37:07 UTC (rev 6479)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/CodeFragmentManagerImpl.java 2010-06-17 18:44:00 UTC (rev 6480)
@@ -46,14 +46,15 @@
@Stateless
public class CodeFragmentManagerImpl implements CodeFragmentManager
{
-
- @Inject Logger log;
// The number of code fragments to return in our recentCodeFragments query
private static int MAX_RECENT_FRAGMENTS = 7;
// The number of code fragments to display per page
private static int PAGE_SIZE = 2;
+
+ @Inject
+ private Logger log;
@PersistenceContext
private EntityManager entityManager;
Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/HashComputer.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/HashComputer.java 2010-06-17 17:37:07 UTC (rev 6479)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/HashComputer.java 2010-06-17 18:44:00 UTC (rev 6480)
@@ -24,9 +24,11 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import javax.ejb.Stateless;
+
import org.jboss.weld.examples.pastecode.model.CodeFragment;
-// TODO @Stateless
+@Stateless
public class HashComputer
{
Modified: examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml 2010-06-17 17:37:07 UTC (rev 6479)
+++ examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml 2010-06-17 18:44:00 UTC (rev 6480)
@@ -33,7 +33,7 @@
<ui:define name="mainarea">
<div class="contentHeader">
- Posted by #{pasteWindow.codeFragment.user} on #{pasteWindow.codeFragment.friendlyDate}
+ Posted by #{pasteWindow.codeFragment.user} <h:outputText value="on" rendered="#{pasteWindow.codeFragment.friendlyDate != 'just now'}" /> #{pasteWindow.codeFragment.friendlyDate}
<div style="float:right">
<a href="download?id=#{pasteWindow.codeFragment.hash == null ? pasteWindow.codeFragment.id : pasteWindow.codeFragment.hash}" style="text-decoration: none;">DOWNLOAD</a>
</div>
14 years, 7 months
Weld SVN: r6479 - examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-06-17 13:37:07 -0400 (Thu, 17 Jun 2010)
New Revision: 6479
Added:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java
Modified:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java
Log:
missing class!
Modified: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java 2010-06-17 12:53:23 UTC (rev 6478)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java 2010-06-17 17:37:07 UTC (rev 6479)
@@ -44,10 +44,9 @@
* external database to run this example.
*
*/
-// TODO Make into an EJB Singleton which executes at startup
@ApplicationScoped
@Named("database")
-//TODO @Singleton @Startup
+// TODO @Singleton @Startup
public class DatabasePopulater
{
Added: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java (rev 0)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java 2010-06-17 17:37:07 UTC (rev 6479)
@@ -0,0 +1,40 @@
+package org.jboss.weld.examples.pastecode.session;
+
+import java.util.Date;
+import java.util.LinkedList;
+
+import javax.ejb.Stateful;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+
+@SessionScoped
+@Stateful // Add passivation capabilities....
+public class PostTracker
+{
+
+ private LinkedList<Date> posts;
+
+ @Inject DatabasePopulater databasePopulater;
+
+ public PostTracker()
+ {
+ this.posts = new LinkedList<Date>();
+ }
+
+ public void addPost()
+ {
+ this.posts.offerFirst(new Date());
+ }
+
+ public boolean isNewPostAllowed()
+ {
+ // if we are populating the database, skip
+ if (!databasePopulater.isPopulated())
+ {
+ return true;
+ }
+ long diff = new Date().getTime() - posts.get(2).getTime();
+ return diff > 20 * 1000;
+ }
+
+}
Property changes on: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PostTracker.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
14 years, 7 months
Weld SVN: r6478 - archetypes/branches/prototype.
by weld-commits@lists.jboss.org
Author: sboscarine
Date: 2010-06-17 08:53:23 -0400 (Thu, 17 Jun 2010)
New Revision: 6478
Added:
archetypes/branches/prototype/build.sh
Modified:
archetypes/branches/prototype/pom.xml
Log:
minor updates
Added: archetypes/branches/prototype/build.sh
===================================================================
--- archetypes/branches/prototype/build.sh (rev 0)
+++ archetypes/branches/prototype/build.sh 2010-06-17 12:53:23 UTC (rev 6478)
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+mvn clean archetype:create-from-project
+mvn -f target/generated-sources/archetype/pom.xml install
+
+
Property changes on: archetypes/branches/prototype/build.sh
___________________________________________________________________
Name: svn:executable
+ *
Modified: archetypes/branches/prototype/pom.xml
===================================================================
--- archetypes/branches/prototype/pom.xml 2010-06-17 03:16:43 UTC (rev 6477)
+++ archetypes/branches/prototype/pom.xml 2010-06-17 12:53:23 UTC (rev 6478)
@@ -2,10 +2,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>com.mycompany</groupId>
- <artifactId>myproject</artifactId>
+ <groupId>org.jboss.weld.archetypes</groupId>
+ <artifactId>javaee6</artifactId>
<packaging>war</packaging>
- <name>myproject</name>
+ <name>Java EE 6.0 Archetype</name>
<version>1.0.0-SNAPSHOT</version>
<properties>
@@ -80,6 +80,7 @@
<classifier>jdk15</classifier>
</dependency>
</dependencies>
+ <description>Java EE 6.0 Archetype</description>
<build>
<finalName>${artifactId}</finalName>
<plugins>
@@ -115,6 +116,19 @@
</fileNames>
</configuration>
</plugin>
+ <!-- Configure the Embedded GlassFish Maven plugin -->
+ <plugin>
+ <groupId>org.glassfish</groupId>
+ <artifactId>maven-embedded-glassfish-plugin</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <app>${expr_start}project.build.directory${expr_end}/${expr_start}build.finalName${expr_end}.war</app>
+ <port>7070</port>
+ <containerType>web</containerType>
+ <instanceRoot>${expr_start}project.build.directory${expr_end}/gfembed${expr_start}maven.build.timestamp${expr_end}</instanceRoot>
+ <autoDelete>true</autoDelete>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
14 years, 7 months
Weld SVN: r6477 - in examples/trunk/jsf/pastecode/src/main: webapp/WEB-INF and 1 other directory.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-06-16 23:16:43 -0400 (Wed, 16 Jun 2010)
New Revision: 6477
Added:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/FloodingDecorator.java
Removed:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/LargeCodeDecorator.java
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PopulateDatabaseBean.java
Modified:
examples/trunk/jsf/pastecode/src/main/webapp/WEB-INF/beans.xml
Log:
change to FloodingDecorator
Copied: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java (from rev 6470, examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PopulateDatabaseBean.java)
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java (rev 0)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/DatabasePopulater.java 2010-06-17 03:16:43 UTC (rev 6477)
@@ -0,0 +1,123 @@
+/*
+ * 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.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.text.SimpleDateFormat;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.jboss.weld.examples.pastecode.model.CodeFragment;
+import org.jboss.weld.examples.pastecode.model.Language;
+
+/**
+ * This bean only populates database with preformatted data. This is due to need
+ * for Hypersonic database which doesn't allow multi-line inserts. Hypersonic
+ * database is embedded in JBoss AS and so there is no need to configure any
+ * external database to run this example.
+ *
+ */
+// TODO Make into an EJB Singleton which executes at startup
+@ApplicationScoped
+@Named("database")
+//TODO @Singleton @Startup
+public class DatabasePopulater
+{
+
+ @Inject Logger log;
+
+ private static final String DATA_FILE_NAME = "data.sql";
+
+ @Inject
+ private CodeFragmentManager codeFragmentManager;
+
+ private boolean populated;
+
+ // TODO @PostConstruct
+ public synchronized void populate()
+ {
+ if (populated)
+ {
+ return;
+ }
+
+ try
+ {
+ String fileContent = readFileData(DATA_FILE_NAME);
+ StringTokenizer st = new StringTokenizer(fileContent, "'");
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+ while (st.countTokens() > 1)
+ {
+ CodeFragment c = new CodeFragment();
+ st.nextToken();
+ c.setDatetime(formatter.parse(st.nextToken()));
+ st.nextToken();
+ c.setLanguage(Language.valueOf(st.nextToken()));
+ st.nextToken();
+ c.setNote(st.nextToken());
+ st.nextToken();
+ c.setUser(st.nextToken());
+ st.nextToken();
+ c.setText(st.nextToken());
+
+ codeFragmentManager.addCodeFragment(c, false);
+ }
+ }
+ catch (Exception e)
+ {
+ log.log(Level.WARNING, "Unable to read all records from " + DATA_FILE_NAME + " file");
+ }
+
+ log.info("Successfully imported data!");
+ populated = true;
+ }
+
+ public boolean isPopulated()
+ {
+ return populated;
+ }
+
+ private String readFileData(String fileName) throws IOException
+ {
+ InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+
+ String line;
+ StringBuilder sb = new StringBuilder();
+
+ while ((line = br.readLine()) != null)
+ {
+ sb.append(line).append("\n");
+ }
+
+ return sb.toString();
+ }
+}
Copied: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/FloodingDecorator.java (from rev 6470, examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/LargeCodeDecorator.java)
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/FloodingDecorator.java (rev 0)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/FloodingDecorator.java 2010-06-17 03:16:43 UTC (rev 6477)
@@ -0,0 +1,52 @@
+/*
+ * 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 javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+import org.jboss.weld.examples.pastecode.model.CodeFragment;
+
+@Decorator
+public abstract class FloodingDecorator implements CodeFragmentManager
+{
+ @Inject @Delegate
+ private CodeFragmentManager codeFragmentManager;
+
+ @Inject
+ private PostTracker postTracker;
+
+ public String addCodeFragment(CodeFragment code, boolean privateFragment)
+ {
+ if (postTracker.isNewPostAllowed())
+ {
+ postTracker.addPost();
+ return codeFragmentManager.addCodeFragment(code, privateFragment);
+ }
+ else
+ {
+ throw new IllegalStateException("You've posted more than 2 fragments in the last 20s. No flooding allowed!");
+ }
+ }
+
+}
Deleted: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/LargeCodeDecorator.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/LargeCodeDecorator.java 2010-06-17 02:53:26 UTC (rev 6476)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/LargeCodeDecorator.java 2010-06-17 03:16:43 UTC (rev 6477)
@@ -1,122 +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.Date;
-
-import javax.annotation.Resource;
-import javax.decorator.Decorator;
-import javax.decorator.Delegate;
-import javax.ejb.TransactionManagement;
-import javax.ejb.TransactionManagementType;
-import javax.enterprise.inject.Any;
-import javax.inject.Inject;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.transaction.UserTransaction;
-
-import org.jboss.weld.examples.pastecode.model.CodeFragment;
-import org.jboss.weld.examples.pastecode.model.AccessLog;
-
-/**
- * This Decorator performs logging of information about large
- * transactions. A transaction is large if the pasted code has
- * more than 65kB. When such a transaction is performed the
- * following pieces of information are being recorded:
- * - id of the transaction,
- * - time of the transaction
- * - "w" - if it was written, "r" - if it was read
- *
- */
-@Decorator
-(a)TransactionManagement(TransactionManagementType.BEAN)
-public abstract class LargeCodeDecorator implements CodeFragmentManager
-{
- /* injecting Delagation point - mandatory */
- @Inject @Delegate @Any CodeFragmentManager eao;
-
- @PersistenceContext(unitName = "pastecodeDatabase")
- private EntityManager em;
-
- @Resource UserTransaction ut;
-
- private long LARGE_CODE = 65536;
-
- public String addCodeFragment(CodeFragment code, boolean secured)
- {
-
- String codeId = eao.addCodeFragment(code, secured);
-
- if (code.getText().length() > LARGE_CODE)
- {
- try
- {
- ut.begin();
- em.joinTransaction();
- em.persist(new AccessLog(code, code.getDatetime(), "w")); //writing large code
- ut.commit();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- try
- {
- ut.rollback();
- }
- catch (Exception ex)
- {
- }
- }
- }
-
- return codeId;
- }
-
- public CodeFragment getCodeFragment(String id)
- {
- CodeFragment code = eao.getCodeFragment(id);
-
- if (code.getText().length() > LARGE_CODE)
- {
- try
- {
- ut.begin();
- em.joinTransaction();
- em.persist(new AccessLog(code, new Date(), "r")); //reading large code
- ut.commit();
- }
- catch(Exception e)
- {
- e.printStackTrace();
- try
- {
- ut.rollback();
- }
- catch (Exception ex)
- {
- }
- }
- }
-
- return code;
- }
-}
Deleted: examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PopulateDatabaseBean.java
===================================================================
--- examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PopulateDatabaseBean.java 2010-06-17 02:53:26 UTC (rev 6476)
+++ examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/session/PopulateDatabaseBean.java 2010-06-17 03:16:43 UTC (rev 6477)
@@ -1,118 +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.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.text.SimpleDateFormat;
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.jboss.weld.examples.pastecode.model.CodeFragment;
-import org.jboss.weld.examples.pastecode.model.Language;
-
-/**
- * This bean only populates database with preformatted data. This is due to need
- * for Hypersonic database which doesn't allow multi-line inserts. Hypersonic
- * database is embedded in JBoss AS and so there is no need to configure any
- * external database to run this example.
- *
- */
-// TODO Make into an EJB Singleton which executes at startup
-@ApplicationScoped
-@Named("database")
-//TODO @Singleton @Startup
-public class PopulateDatabaseBean
-{
-
- @Inject Logger log;
-
- private static final String DATA_FILE_NAME = "data.sql";
-
- @Inject
- private CodeFragmentManager codeFragmentManager;
-
- private boolean populated;
-
- // TODO @PostConstruct
- public synchronized void populate()
- {
- if (populated)
- {
- return;
- }
-
- try
- {
- String fileContent = readFileData(DATA_FILE_NAME);
- StringTokenizer st = new StringTokenizer(fileContent, "'");
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
- while (st.countTokens() > 1)
- {
- CodeFragment c = new CodeFragment();
- st.nextToken();
- c.setDatetime(formatter.parse(st.nextToken()));
- st.nextToken();
- c.setLanguage(Language.valueOf(st.nextToken()));
- st.nextToken();
- c.setNote(st.nextToken());
- st.nextToken();
- c.setUser(st.nextToken());
- st.nextToken();
- c.setText(st.nextToken());
-
- codeFragmentManager.addCodeFragment(c, false);
- }
- }
- catch (Exception e)
- {
- log.log(Level.WARNING, "Unable to read all records from " + DATA_FILE_NAME + " file");
- }
-
- log.info("Successfully imported data!");
- populated = true;
- }
-
- private String readFileData(String fileName) throws IOException
- {
- InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
-
- String line;
- StringBuilder sb = new StringBuilder();
-
- while ((line = br.readLine()) != null)
- {
- sb.append(line).append("\n");
- }
-
- return sb.toString();
- }
-}
Modified: examples/trunk/jsf/pastecode/src/main/webapp/WEB-INF/beans.xml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/WEB-INF/beans.xml 2010-06-17 02:53:26 UTC (rev 6476)
+++ examples/trunk/jsf/pastecode/src/main/webapp/WEB-INF/beans.xml 2010-06-17 03:16:43 UTC (rev 6477)
@@ -10,7 +10,7 @@
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<decorators>
- <class>org.jboss.weld.examples.pastecode.session.LargeCodeDecorator</class>
+ <class>org.jboss.weld.examples.pastecode.session.FloodingDecorator</class>
</decorators>
</beans>
14 years, 7 months
Weld SVN: r6476 - examples/trunk/jsf/pastecode/src/main/webapp.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-06-16 22:53:26 -0400 (Wed, 16 Jun 2010)
New Revision: 6476
Modified:
examples/trunk/jsf/pastecode/src/main/webapp/help.xhtml
Log:
minor
Modified: examples/trunk/jsf/pastecode/src/main/webapp/help.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/help.xhtml 2010-06-17 02:46:34 UTC (rev 6475)
+++ examples/trunk/jsf/pastecode/src/main/webapp/help.xhtml 2010-06-17 02:53:26 UTC (rev 6476)
@@ -9,11 +9,11 @@
<ui:define name="mainarea">
<div style="width: 100%; padding: 7px;">
- <div id="paging" style="width:98%; border-width:0px; background-color:#C1C1E8;text-align:center;"> <!-- height: 40px; -->
- <strong>Useful Information</strong>
- </div>
- <br/>
- <strong>Paste Code:</strong><br/>
+
+ <div class="contentHeader">Useful Information</div>
+
+ <h3>Paste Code:</h3>
+
<ul>
<li>Enter your nick - this is optional, if omitted, your paste will be anonymous</li>
<li>Choose the language of your code - this allows syntax highlighting</li>
@@ -24,13 +24,13 @@
<li>Submit the form!</li>
</ul>
- <strong>Search Pastes:</strong><br/>
+ <h3>Search Pastes:</h3>
<ul>
<li>Go to a history page - now you can see all the posts with pagination</li>
<li>You can narrow down the pastes by using the search form</li>
</ul>
- <strong>Weld Features Covered:</strong><br/>
+ <h3>Weld Features Covered:</h3>
<ul>
<li>Injection into POJO, EJBs and Servlets</li>
@@ -39,13 +39,15 @@
<li>JPA access</li>
<li>Decorators</li>
</ul>
- <br/><br/><strong>Enjoy work with Weld!</strong>
+ <br/><br/>
+
+ <strong>Enjoy working with Weld!</strong>
</div>
</ui:define>
<ui:define name="rightmenu">
- <ui:include src="rightMenuDefault.xhtml"/>
+ <ui:include src="rightMenuDefault.xhtml"/>
</ui:define>
</ui:composition>
14 years, 7 months
Weld SVN: r6475 - in examples/trunk/jsf/pastecode/src/main/webapp: style and 1 other directory.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-06-16 22:46:34 -0400 (Wed, 16 Jun 2010)
New Revision: 6475
Modified:
examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml
examples/trunk/jsf/pastecode/src/main/webapp/style/style.css
Log:
adjust styles on display page
Modified: examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml 2010-06-17 02:24:50 UTC (rev 6474)
+++ examples/trunk/jsf/pastecode/src/main/webapp/display.xhtml 2010-06-17 02:46:34 UTC (rev 6475)
@@ -32,41 +32,27 @@
</ui:define>
<ui:define name="mainarea">
- <div style="width: 100%; padding: 7px;">
-
- <h:panelGrid columns="3" style="width: 80%; margin: 0px; padding: 0px;">
+ <div class="contentHeader">
+ Posted by #{pasteWindow.codeFragment.user} on #{pasteWindow.codeFragment.friendlyDate}
+ <div style="float:right">
+ <a href="download?id=#{pasteWindow.codeFragment.hash == null ? pasteWindow.codeFragment.id : pasteWindow.codeFragment.hash}" style="text-decoration: none;">DOWNLOAD</a>
+ </div>
+ </div>
- <h:panelGroup>
- <h:outputLabel for="user" value="User: "/>
- <h:outputText id="user" maxlength="30" size="30" value="#{pasteWindow.codeFragment.user}"/>
- </h:panelGroup>
-
- <h:panelGroup>
- <h:outputLabel for="theme" value="Choose theme: "/>
- <h:selectOneMenu id="theme" value="#{pasteWindow.theme}" onchange="chooseStyle(this.value);"> <!-- this.form.submit() -->
- <f:selectItems value="#{themes}" var="theme" itemLabel="#{theme.name}" itemValue="#{theme.name}" />
- </h:selectOneMenu>
- <a href="download?id=#{pasteWindow.codeFragment.hash == null ? pasteWindow.codeFragment.id : pasteWindow.codeFragment.hash}" style="text-decoration: none;"><input type="button" value="Download file" /></a>
- </h:panelGroup>
-
- <h:panelGroup style="text-align:right;">
- <h:outputLabel for="unwrap" value="Unwrap code: "/>
- <h:selectBooleanCheckbox id="unwrap" onchange="unwrap('codearea');"/>
- </h:panelGroup>
-
- </h:panelGrid>
+ <div class="formRow">
+ <h:outputLabel for="theme" value="Choose theme: "/>
+ <h:selectOneMenu id="theme" value="#{pasteWindow.theme}" onchange="chooseStyle(this.value);"> <!-- this.form.submit() -->
+ <f:selectItems value="#{themes}" var="theme" itemLabel="#{theme.name}" itemValue="#{theme.name}" />
+ </h:selectOneMenu>
+ </div>
+
+ <!--h:outputLabel for="unwrap" value="Unwrap code: "/>
+ <h:selectBooleanCheckbox id="unwrap" onchange="unwrap('codearea');"/-->
- <h:outputText value="Pasted code: "/>
- <div id="codearea" style="width:99%; border: 1px solid #7F7F7F; height:450px; overflow:scroll;">
- <pre class="brush: #{pasteWindow.codeFragment.language.brush}">#{pasteWindow.codeFragment.text}</pre>
- </div>
-
- <br/>
- <h:outputLabel for="note" value="Note: "/>
- <div >
- <h:outputText id="note" value="#{pasteWindow.codeFragment.note}"/>
- </div>
+ <div id="codearea" style="width:99%; border: 1px solid #7F7F7F; height:450px; overflow:scroll;">
+ <pre class="brush: #{pasteWindow.codeFragment.language.brush}">#{pasteWindow.codeFragment.text}</pre>
</div>
+
</ui:define>
<ui:define name="rightmenu">
Modified: examples/trunk/jsf/pastecode/src/main/webapp/style/style.css
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/style/style.css 2010-06-17 02:24:50 UTC (rev 6474)
+++ examples/trunk/jsf/pastecode/src/main/webapp/style/style.css 2010-06-17 02:46:34 UTC (rev 6475)
@@ -98,6 +98,11 @@
margin: 8px 4px 8px 4px;
}
+div.contentHeader a, div.contentHeader a:visited, div.contentHeader a:hover {
+ font-weight: normal;
+ color: #ff0000;
+}
+
/* General form styles */
.pastecode {
@@ -111,7 +116,7 @@
div.formRow {
padding: 3px 4px 3px 2px;
- clear: both;
+/* clear: both;*/
}
div.formRow label {
14 years, 7 months
Weld SVN: r6474 - examples/trunk/jsf/pastecode/src/main/webapp.
by weld-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2010-06-16 22:24:50 -0400 (Wed, 16 Jun 2010)
New Revision: 6474
Modified:
examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml
Log:
argh i can't spell good
Modified: examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml 2010-06-17 02:24:11 UTC (rev 6473)
+++ examples/trunk/jsf/pastecode/src/main/webapp/home.xhtml 2010-06-17 02:24:50 UTC (rev 6474)
@@ -14,7 +14,7 @@
<ui:define name="mainarea">
- <div class="contentHeader">Poste a new PasteCode</div>
+ <div class="contentHeader">Post a new PasteCode</div>
<h:inputTextarea id="text" styleClass="pastecode" value="#{pasteWindow.codeFragment.text}"/>
14 years, 7 months