Seam SVN: r10362 - in trunk: ui/src/main/java/org/jboss/seam/ui and 1 other directories.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-08 18:58:39 -0400 (Wed, 08 Apr 2009)
New Revision: 10362
Added:
trunk/ui/src/main/java/org/jboss/seam/ui/RenderStampStore.java
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Components.xml
trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/TokenRendererBase.java
Log:
JBSEAM-4076
Modified: trunk/doc/Seam_Reference_Guide/en-US/Components.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Components.xml 2009-04-08 22:51:53 UTC (rev 10361)
+++ trunk/doc/Seam_Reference_Guide/en-US/Components.xml 2009-04-08 22:58:39 UTC (rev 10362)
@@ -192,6 +192,28 @@
</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><literal>org.jboss.seam.ui.renderStampStore</literal></term>
+ <listitem>
+ <para>
+ A component (session-scoped by default) responsible for maintaining
+ a collection of render stamps. A render stamp is an indicator as
+ to whether a form which was rendered has been submitted. This store
+ is useful when the client-side state saving method of JSF is being
+ used because it puts the determination of whether a form has been
+ posted in the control of the server rather than in the component tree
+ which is maintained on the client.
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>maxSize</literal> — The maximum number of stamps
+ to be kept in the store. Default: 100
+ </para>
+ </listitem>
+ </itemizedlist>
+ </listitem>
+ </varlistentry>
</variablelist>
<para>
Added: trunk/ui/src/main/java/org/jboss/seam/ui/RenderStampStore.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/RenderStampStore.java (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/RenderStampStore.java 2009-04-08 22:58:39 UTC (rev 10362)
@@ -0,0 +1,96 @@
+package org.jboss.seam.ui;
+
+import static org.jboss.seam.ScopeType.SESSION;
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.intercept.BypassInterceptors;
+
+/**
+ * A class that stores render stamps for use with <s:token> when client side
+ * state saving is in use. By default the render stamp store will never remove a
+ * render stamp unless instructed to by a UIToken. If the maxSize property is
+ * larger than zero then it will control the maximum number of tokens stored,
+ * with the oldest token being removed when a token is inserted that will take
+ * the store over the maxSize limit. The default maxSize is 100.
+ *
+ * @author Stuart Douglas
+ */
+@Name("org.jboss.seam.ui.renderStampStore")
+@Scope(SESSION)
+@Install(precedence = BUILT_IN, value = false)
+@AutoCreate
+@BypassInterceptors
+public class RenderStampStore implements Serializable {
+
+ class RenderStamp {
+ String stamp;
+ Date timeStamp;
+ }
+
+ int maxSize = 100;
+
+ Map<String, RenderStamp> store = new ConcurrentHashMap<String, RenderStamp>();
+
+ /**
+ * Stores a stamp in the store, and returns the key it is stored under.
+ */
+ public String storeStamp(String stamp) {
+ if (maxSize > 0) {
+ if (store.size() == maxSize) {
+ Date oldest = null;
+ String oldestSigniture = null;
+ for (String sig : store.keySet()) {
+ RenderStamp s = store.get(sig);
+ if (oldest == null || s.timeStamp.before(oldest)) {
+ oldestSigniture = sig;
+ }
+ }
+ store.remove(oldestSigniture);
+ }
+ }
+ RenderStamp s = new RenderStamp();
+ s.stamp = stamp;
+ s.timeStamp = new Date();
+ String key;
+ do {
+ key = UUID.randomUUID().toString();
+ } while (!store.containsKey(key));
+ store.put(key, s);
+ return key;
+ }
+
+ public void removeStamp(String viewSigniture) {
+ store.remove(viewSigniture);
+ }
+
+ public String getStamp(String viewSigniture) {
+ RenderStamp s = store.get(viewSigniture);
+ if (s != null) {
+ return store.get(viewSigniture).stamp;
+ }
+ return null;
+ }
+
+ public static RenderStampStore instance() {
+ return (RenderStampStore) Component.getInstance(RenderStampStore.class);
+ }
+
+ public int getMaxSize() {
+ return maxSize;
+ }
+
+ public void setMaxSize(int maxSize) {
+ this.maxSize = maxSize;
+ }
+}
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/TokenRendererBase.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/TokenRendererBase.java 2009-04-08 22:51:53 UTC (rev 10361)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/TokenRendererBase.java 2009-04-08 22:58:39 UTC (rev 10362)
@@ -10,6 +10,7 @@
import javax.faces.context.ResponseWriter;
import javax.servlet.http.HttpSession;
+import org.jboss.seam.ui.RenderStampStore;
import org.jboss.seam.ui.UnauthorizedCommandException;
import org.jboss.seam.ui.component.UIToken;
import org.jboss.seam.ui.util.HTML;
@@ -20,7 +21,10 @@
/**
* <p>
* The <strong>TokenRendererBase</strong> renders the form's signature as a
- * hidden form field for the UIToken component.
+ * hidden form field for the UIToken component. If the renderStampStore
+ * component is enabled, the actually signature will be stored in the session
+ * and the key to this token store in the hidden form field, providing the same
+ * guarantee for client-side state saving as with server-side state saving.
* </p>
*
* <p>
@@ -41,18 +45,30 @@
* sha1(signature = contextPath + viewId + "," + formClientId + "," + random alphanum + sessionId, salt = clientUid)
* </pre>
*
- * <p>The decode method performs the following steps:</p>
+ * <p>
+ * The decode method performs the following steps:
+ * </p>
* <ol>
- * <li>check if this is a postback, otherwise skip the check</li>
- * <li>check that this form was the one that was submitted, otherwise skip the check</li>
- * <li>get the unique client identifier (from cookie), otherwise throw an exception that the browser must have unique identifier</li>
- * <li>get the javax.faces.FormSignature request parameter, otherwise throw an exception that the form signature is missing</li>
- * <li>generate the hash as before and verify that it equals the value of the javax.faces.FormSignature request parameter, otherwise throw an exception</li>
+ * <li>Check if this is a postback, otherwise skip the check</li>
+ * <li>Check that this form was the one that was submitted, otherwise skip the
+ * check</li>
+ * <li>Get the unique client identifier (from cookie), otherwise throw an
+ * exception that the browser must have unique identifier</li>
+ * <li>Get the javax.faces.FormSignature request parameter, otherwise throw an
+ * exception that the form signature is missing</li>
+ * <li>If the renderStampStore component is enabled, retrieve the render stamp
+ * from the store using the key stored in the render stamp attribute of the form.</li>
+ * <li>Generate the hash as before and verify that it equals the value of the
+ * javax.faces.FormSignature request parameter, otherwise throw an exception</li>
* </ol>
*
- * <p>If all of that passes, we are okay to process the form (advance to validate phase as decode() is called in apply request values).</p>
+ * <p>
+ * If all of that passes, we are okay to process the form (advance to validate
+ * phase as decode() is called in apply request values).
+ * </p>
*
* @author Dan Allen
+ * @author Stuart Douglas
* @see UnauthorizedCommandException
*/
public class TokenRendererBase extends RendererBase
@@ -60,7 +76,7 @@
public static final String FORM_SIGNATURE_PARAM = "javax.faces.FormSignature";
public static final String RENDER_STAMP_ATTR = "javax.faces.RenderStamp";
-
+
private static final String COOKIE_CHECK_SCRIPT_KEY = "org.jboss.seam.ui.COOKIE_CHECK_SCRIPT";
@Override
@@ -93,7 +109,12 @@
{
throw new UnauthorizedCommandException(viewId, "Form signature invalid");
}
-
+ RenderStampStore store = RenderStampStore.instance();
+ if (store != null)
+ {
+ // remove the key from the store if we are using it
+ store.removeStamp(String.valueOf(form.getAttributes().get(RENDER_STAMP_ATTR)));
+ }
form.getAttributes().remove(RENDER_STAMP_ATTR);
}
}
@@ -107,11 +128,23 @@
{
throw new IllegalStateException("UIToken must be inside a UIForm.");
}
-
+
+ String renderStamp = RandomStringUtils.randomAlphanumeric(50);
+ RenderStampStore store = RenderStampStore.instance();
+ if (store != null)
+ {
+ // if the store is not null we store the key
+ // instead of the actual stamp; this puts the
+ // server in control of this value rather than
+ // the component tree, which is owned by the client
+ // when using client-side state saving
+ renderStamp = store.storeStamp(renderStamp);
+ }
+
writeCookieCheckScript(context, writer, token);
token.getClientUidSelector().seed();
- form.getAttributes().put(RENDER_STAMP_ATTR, RandomStringUtils.randomAlphanumeric(50));
+ form.getAttributes().put(RENDER_STAMP_ATTR, renderStamp);
writer.startElement(HTML.INPUT_ELEM, component);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, HTML.TYPE_ATTR);
writer.writeAttribute(HTML.NAME_ATTR, FORM_SIGNATURE_PARAM, HTML.NAME_ATTR);
@@ -141,7 +174,16 @@
String rawViewSignature = context.getExternalContext().getRequestContextPath() + "," + context.getViewRoot().getViewId() + "," + form.getClientId(context);
if (useRenderStamp)
{
- rawViewSignature += "," + form.getAttributes().get(RENDER_STAMP_ATTR);
+ String renderStamp = form.getAttributes().get(RENDER_STAMP_ATTR).toString();
+ RenderStampStore store = RenderStampStore.instance();
+ if (store != null)
+ {
+ // if we are using the RenderStampStore the key to access the render
+ // stamp
+ // is stored in the view root instead of the actual render stamp
+ renderStamp = store.getStamp(renderStamp);
+ }
+ rawViewSignature += "," + renderStamp;
}
if (useSessionId)
{
@@ -164,5 +206,5 @@
return null;
}
}
-
+
}
15 years, 7 months
Seam SVN: r10361 - trunk/src/test/integration/src/org/jboss/seam/test/integration.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2009-04-08 18:51:53 -0400 (Wed, 08 Apr 2009)
New Revision: 10361
Modified:
trunk/src/test/integration/src/org/jboss/seam/test/integration/EntityTest.java
Log:
JBSEAM-4090
Modified: trunk/src/test/integration/src/org/jboss/seam/test/integration/EntityTest.java
===================================================================
--- trunk/src/test/integration/src/org/jboss/seam/test/integration/EntityTest.java 2009-04-08 22:38:15 UTC (rev 10360)
+++ trunk/src/test/integration/src/org/jboss/seam/test/integration/EntityTest.java 2009-04-08 22:51:53 UTC (rev 10361)
@@ -75,7 +75,8 @@
}.run();
}
- @Test
+ // XXX - JBSEAM-4090
+ // @Test
public void testStale() throws Exception {
final Map<String, Long> holder = new HashMap<String, Long>();
15 years, 7 months
Seam SVN: r10360 - trunk/examples/quartz/src/org/jboss/seam/example/quartz/test.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2009-04-08 18:38:15 -0400 (Wed, 08 Apr 2009)
New Revision: 10360
Modified:
trunk/examples/quartz/src/org/jboss/seam/example/quartz/test/EventsTest.java
Log:
fix timing issue with test
Modified: trunk/examples/quartz/src/org/jboss/seam/example/quartz/test/EventsTest.java
===================================================================
--- trunk/examples/quartz/src/org/jboss/seam/example/quartz/test/EventsTest.java 2009-04-08 22:26:20 UTC (rev 10359)
+++ trunk/examples/quartz/src/org/jboss/seam/example/quartz/test/EventsTest.java 2009-04-08 22:38:15 UTC (rev 10360)
@@ -197,6 +197,7 @@
@Override
protected void renderResponse() throws Exception
{
+ Thread.sleep(1000);
assert ((Boolean)getValue("#{accountHome.idDefined}"));
Account account = (Account) getValue("#{selectedAccount}");
assert account !=null;
15 years, 7 months
Seam SVN: r10359 - branches/community/Seam_2_0/src/main/org/jboss/seam/persistence.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-08 18:26:20 -0400 (Wed, 08 Apr 2009)
New Revision: 10359
Modified:
branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java
branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/PersistenceContexts.java
branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/PersistenceProvider.java
Log:
JBSEAM-3030 fix regression where actual flush mode was not being restored after render
Modified: branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java
===================================================================
--- branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2009-04-08 21:55:33 UTC (rev 10358)
+++ branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2009-04-08 22:26:20 UTC (rev 10359)
@@ -145,7 +145,7 @@
@Override
public void setRenderFlushMode()
{
- PersistenceContexts.instance().changeFlushMode(FlushModeType.MANUAL);
+ PersistenceContexts.instance().changeFlushMode(FlushModeType.MANUAL, true);
}
@Override
Modified: branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/PersistenceContexts.java
===================================================================
--- branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/PersistenceContexts.java 2009-04-08 21:55:33 UTC (rev 10358)
+++ branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/PersistenceContexts.java 2009-04-08 22:26:20 UTC (rev 10359)
@@ -36,7 +36,7 @@
private static final LogProvider log = Logging.getLogProvider(PersistenceContexts.class);
private Set<String> set = new HashSet<String>();
private FlushModeType flushMode = FlushModeType.AUTO;
- private FlushModeType actualFlushMode = FlushModeType.AUTO;
+ private FlushModeType originalFlushMode;
public FlushModeType getFlushMode()
{
@@ -69,11 +69,18 @@
return null;
}
}
-
+
public void changeFlushMode(FlushModeType flushMode)
{
+ changeFlushMode(flushMode, false);
+ }
+
+ public void changeFlushMode(FlushModeType flushMode, boolean temporary)
+ {
+ if (temporary) {
+ this.originalFlushMode = this.flushMode;
+ }
this.flushMode = flushMode;
- this.actualFlushMode = flushMode;
changeFlushModes();
}
@@ -102,13 +109,14 @@
// some JPA providers may not support MANUAL flushing
// defer the decision to the provider manager component
PersistenceProvider.instance().setRenderFlushMode();
- changeFlushModes();
}
public void afterRender()
{
- flushMode = actualFlushMode;
- changeFlushModes();
+ if (originalFlushMode != null && originalFlushMode != flushMode) {
+ flushMode = originalFlushMode;
+ changeFlushModes();
+ }
}
}
Modified: branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/PersistenceProvider.java
===================================================================
--- branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/PersistenceProvider.java 2009-04-08 21:55:33 UTC (rev 10358)
+++ branches/community/Seam_2_0/src/main/org/jboss/seam/persistence/PersistenceProvider.java 2009-04-08 22:26:20 UTC (rev 10359)
@@ -47,9 +47,11 @@
/**
* <p>
* Set the FlushMode the persistence contexts should use during rendering by
- * calling {@link PersistenceContexts#changeFlushMode(FlushModeType)}. The
+ * calling {@link PersistenceContexts#changeFlushMode(FlushModeType, boolean)}. The
* actual changing of the flush mode is handled by the
- * {@link PersistenceContexts} instance.
+ * {@link PersistenceContexts} instance. The boolean argument indicates whether
+ * the flush mode is temporary and should be set to true. The original flush
+ * mode will be restore after rendering is complete.
* </p>
* <p>
* Ideally, this should be MANUAL since changes should never flush to the
15 years, 7 months
Seam SVN: r10357 - trunk/examples/itext/src/org/jboss/seam/example/pdf.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2009-04-08 17:50:45 -0400 (Wed, 08 Apr 2009)
New Revision: 10357
Added:
trunk/examples/itext/src/org/jboss/seam/example/pdf/JFreeData.java
Modified:
trunk/examples/itext/src/org/jboss/seam/example/pdf/DynamicChart.java
trunk/examples/itext/src/org/jboss/seam/example/pdf/SwingComponent.java
Log:
JBSEAM-3956
Modified: trunk/examples/itext/src/org/jboss/seam/example/pdf/DynamicChart.java
===================================================================
--- trunk/examples/itext/src/org/jboss/seam/example/pdf/DynamicChart.java 2009-04-08 19:48:18 UTC (rev 10356)
+++ trunk/examples/itext/src/org/jboss/seam/example/pdf/DynamicChart.java 2009-04-08 21:50:45 UTC (rev 10357)
@@ -307,12 +307,11 @@
}
public void removeSeries(String id) {
- System.out.println("REMOVE: " + id);
+ // System.out.println("REMOVE: " + id);
}
public void newSeries() {
String newId = findUniqueSeriesId();
- System.out.println("** series " + newId);
Data set = new Data();
set.setId(newId);
Added: trunk/examples/itext/src/org/jboss/seam/example/pdf/JFreeData.java
===================================================================
--- trunk/examples/itext/src/org/jboss/seam/example/pdf/JFreeData.java (rev 0)
+++ trunk/examples/itext/src/org/jboss/seam/example/pdf/JFreeData.java 2009-04-08 21:50:45 UTC (rev 10357)
@@ -0,0 +1,151 @@
+package org.jboss.seam.example.pdf;
+
+import org.jboss.seam.annotations.*;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.GradientPaint;
+import java.awt.Paint;
+import java.awt.geom.Rectangle2D;
+
+import javax.swing.JPanel;
+
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.LegendItem;
+import org.jfree.chart.LegendItemCollection;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.renderer.category.BarRenderer;
+import org.jfree.chart.title.LegendTitle;
+import org.jfree.chart.title.TextTitle;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.ui.ApplicationFrame;
+import org.jfree.ui.HorizontalAlignment;
+import org.jfree.ui.RectangleEdge;
+import org.jfree.ui.RectangleInsets;
+import org.jfree.ui.RefineryUtilities;
+
+@Name("jfree")
+public class JFreeData {
+
+ public JFreeChart getChart() {
+ return createChart(getDataset());
+ }
+
+ public CategoryDataset getDataset() {
+ DefaultCategoryDataset dataset = new DefaultCategoryDataset();
+
+ dataset.addValue(81.0, "Against all torture", "Italy");
+ dataset.addValue(72.0, "Against all torture", "Great Britain");
+ dataset.addValue(58.0, "Against all torture", "USA");
+ dataset.addValue(48.0, "Against all torture", "Israel");
+ dataset.addValue(43.0, "Against all torture", "Russia");
+ dataset.addValue(23.0, "Against all torture", "India");
+ dataset.addValue(59.0, "Against all torture", "Average (*)");
+
+
+ dataset.addValue(5.0, "-", "Italy");
+ dataset.addValue(4.0, "-", "Great Britain");
+ dataset.addValue(6.0, "-", "USA");
+ dataset.addValue(9.0, "-", "Israel");
+ dataset.addValue(20.0, "-", "Russia");
+ dataset.addValue(45.0, "-", "India");
+ dataset.addValue(12.0, "-", "Average (*)");
+
+ dataset.addValue(14.0, "Some degree permissible", "Italy");
+ dataset.addValue(24.0, "Some degree permissible", "Great Britain");
+ dataset.addValue(36.0, "Some degree permissible", "USA");
+ dataset.addValue(43.0, "Some degree permissible", "Israel");
+ dataset.addValue(37.0, "Some degree permissible", "Russia");
+ dataset.addValue(32.0, "Some degree permissible", "India");
+ dataset.addValue(29.0, "Some degree permissible", "Average (*)");
+
+ return dataset;
+ }
+
+ /**
+ * Creates a sample chart.
+ *
+ * @param dataset the dataset.
+ *
+ * @return The chart.
+ */
+ private JFreeChart createChart(CategoryDataset dataset) {
+
+ // create the chart...
+ JFreeChart chart = ChartFactory.createStackedBarChart(
+ "Public Opinion : Torture of Prisoners",
+ "Country", // domain axis label
+ "%", // range axis label
+ dataset, // data
+ PlotOrientation.HORIZONTAL, // orientation
+ false, // include legend
+ true, // tooltips?
+ false // URLs?
+ );
+
+ // set the background color for the chart...
+ chart.setBackgroundPaint(Color.white);
+ chart.getTitle().setMargin(2.0, 0.0, 0.0, 0.0);
+
+ TextTitle tt = new TextTitle(
+ "Source: http://news.bbc.co.uk/1/hi/world/6063386.stm",
+ new Font("Dialog", Font.PLAIN, 11));
+ tt.setPosition(RectangleEdge.BOTTOM);
+ tt.setHorizontalAlignment(HorizontalAlignment.RIGHT);
+ tt.setMargin(0.0, 0.0, 4.0, 4.0);
+ chart.addSubtitle(tt);
+
+ TextTitle t = new TextTitle(
+ "(*) Across 27,000 respondents in 25 countries",
+ new Font("Dialog", Font.PLAIN, 11));
+ t.setPosition(RectangleEdge.BOTTOM);
+ t.setHorizontalAlignment(HorizontalAlignment.RIGHT);
+ t.setMargin(4.0, 0.0, 2.0, 4.0);
+ chart.addSubtitle(t);
+
+ // get a reference to the plot for further customisation...
+ CategoryPlot plot = (CategoryPlot) chart.getPlot();
+ LegendItemCollection items = new LegendItemCollection();
+ items.add(new LegendItem("Against all torture", null, null, null,
+ new Rectangle2D.Double(-6.0, -3.0, 12.0, 6.0), Color.green));
+ items.add(new LegendItem("Some degree permissible", null, null, null,
+ new Rectangle2D.Double(-6.0, -3.0, 12.0, 6.0), Color.red));
+ plot.setFixedLegendItems(items);
+ plot.setInsets(new RectangleInsets(5, 5, 5, 20));
+ LegendTitle legend = new LegendTitle(plot);
+ legend.setPosition(RectangleEdge.BOTTOM);
+ chart.addSubtitle(legend);
+
+ plot.setBackgroundPaint(Color.lightGray);
+ plot.setDomainGridlinePaint(Color.white);
+ plot.setDomainGridlinesVisible(true);
+ plot.setRangeGridlinePaint(Color.white);
+
+ // set the range axis to display integers only...
+ NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
+ rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
+ rangeAxis.setUpperMargin(0.0);
+
+ // disable bar outlines...
+ BarRenderer renderer = (BarRenderer) plot.getRenderer();
+ renderer.setDrawBarOutline(false);
+
+ // set up gradient paints for series...
+ GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
+ Paint gp1 = new Color(0, 0, 0, 0);
+ GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
+ //renderer.setSeriesPaint(0, gp0);
+ renderer.setSeriesPaint(0, Color.green);
+ renderer.setSeriesPaint(1, gp1);
+ //renderer.setSeriesPaint(2, gp2);
+ renderer.setSeriesPaint(2, Color.red);
+
+ return chart;
+ }
+}
\ No newline at end of file
Modified: trunk/examples/itext/src/org/jboss/seam/example/pdf/SwingComponent.java
===================================================================
--- trunk/examples/itext/src/org/jboss/seam/example/pdf/SwingComponent.java 2009-04-08 19:48:18 UTC (rev 10356)
+++ trunk/examples/itext/src/org/jboss/seam/example/pdf/SwingComponent.java 2009-04-08 21:50:45 UTC (rev 10357)
@@ -16,8 +16,6 @@
} catch(Exception e) {
System.out.println("Error setting Java LAF: " + e);
}
-
- //System.out.println("** " + UIManager.getLookAndFeel());
}
public Component getLabel1() {
15 years, 7 months
Seam SVN: r10356 - in trunk/src/pdf: org/jboss/seam/pdf/ui and 1 other directory.
by seam-commits@lists.jboss.org
Author: norman.richards(a)jboss.com
Date: 2009-04-08 15:48:18 -0400 (Wed, 08 Apr 2009)
New Revision: 10356
Added:
trunk/src/pdf/org/jboss/seam/pdf/ui/UIAnyChart.java
Modified:
trunk/src/pdf/META-INF/faces-config.xml
trunk/src/pdf/META-INF/seam-pdf.taglib.xml
trunk/src/pdf/org/jboss/seam/pdf/ui/UIChart.java
Log:
JBSEAM-3956
Modified: trunk/src/pdf/META-INF/faces-config.xml
===================================================================
--- trunk/src/pdf/META-INF/faces-config.xml 2009-04-08 17:50:00 UTC (rev 10355)
+++ trunk/src/pdf/META-INF/faces-config.xml 2009-04-08 19:48:18 UTC (rev 10356)
@@ -110,6 +110,10 @@
</component>
<component>
+ <component-type>org.jboss.seam.pdf.ui.UIAnyChart</component-type>
+ <component-class>org.jboss.seam.pdf.ui.UIAnyChart</component-class>
+ </component>
+ <component>
<component-type>org.jboss.seam.pdf.ui.UIBarChart</component-type>
<component-class>org.jboss.seam.pdf.ui.UIBarChart</component-class>
</component>
Modified: trunk/src/pdf/META-INF/seam-pdf.taglib.xml
===================================================================
--- trunk/src/pdf/META-INF/seam-pdf.taglib.xml 2009-04-08 17:50:00 UTC (rev 10355)
+++ trunk/src/pdf/META-INF/seam-pdf.taglib.xml 2009-04-08 19:48:18 UTC (rev 10356)
@@ -147,6 +147,13 @@
</tag>
<tag>
+ <tag-name>chart</tag-name>
+ <component>
+ <component-type>org.jboss.seam.pdf.ui.UIAnyChart</component-type>
+ </component>
+ </tag>
+
+ <tag>
<tag-name>piechart</tag-name>
<component>
<component-type>org.jboss.seam.pdf.ui.UIPieChart</component-type>
Added: trunk/src/pdf/org/jboss/seam/pdf/ui/UIAnyChart.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIAnyChart.java (rev 0)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIAnyChart.java 2009-04-08 19:48:18 UTC (rev 10356)
@@ -0,0 +1,24 @@
+package org.jboss.seam.pdf.ui;
+
+import javax.faces.context.FacesContext;
+
+import org.jfree.chart.JFreeChart;
+import org.jfree.data.general.Dataset;
+
+public class UIAnyChart
+ extends UIChart
+{
+
+ @Override
+ public JFreeChart createChart(FacesContext context)
+ {
+ throw new RuntimeException("the chart tag requires a chart");
+ }
+
+ @Override
+ public Dataset createDataset()
+ {
+ return null;
+ }
+
+}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIChart.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIChart.java 2009-04-08 17:50:00 UTC (rev 10355)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIChart.java 2009-04-08 19:48:18 UTC (rev 10356)
@@ -67,8 +67,7 @@
}
public int getHeight() {
- return (Integer) valueBinding(FacesContext.getCurrentInstance(),
- "height", height);
+ return (Integer) valueBinding(FacesContext.getCurrentInstance(), "height", height);
}
public void setWidth(int width) {
@@ -76,8 +75,7 @@
}
public int getWidth() {
- return (Integer) valueBinding(FacesContext.getCurrentInstance(),
- "width", width);
+ return (Integer) valueBinding(FacesContext.getCurrentInstance(), "width", width);
}
public void setLegend(boolean legend) {
@@ -101,8 +99,7 @@
}
public String getBorderBackgroundPaint() {
- return (String) valueBinding(FacesContext.getCurrentInstance(),
- "borderBackgroundPaint", borderBackgroundPaint);
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "borderBackgroundPaint", borderBackgroundPaint);
}
public void setBorderPaint(String borderPaint) {
@@ -110,8 +107,7 @@
}
public String getBorderPaint() {
- return (String) valueBinding(FacesContext.getCurrentInstance(),
- "borderPaint", borderPaint);
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "borderPaint", borderPaint);
}
public void setBorderStroke(String borderStroke) {
@@ -119,8 +115,7 @@
}
public String getBorderStroke() {
- return (String) valueBinding(FacesContext.getCurrentInstance(),
- "borderStroke", borderStroke);
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "borderStroke", borderStroke);
}
public void setBorderVisible(boolean borderVisible) {
@@ -128,8 +123,7 @@
}
public boolean getBorderVisible() {
- return (Boolean) valueBinding(FacesContext.getCurrentInstance(),
- "borderVisible", borderVisible);
+ return (Boolean) valueBinding(FacesContext.getCurrentInstance(), "borderVisible", borderVisible);
}
public void setPlotBackgroundAlpha(Float plotBackgroundAlpha) {
@@ -137,8 +131,7 @@
}
public Float getPlotBackgroundAlpha() {
- return (Float) valueBinding(FacesContext.getCurrentInstance(),
- "plotBackgroundAlpha", plotBackgroundAlpha);
+ return (Float) valueBinding(FacesContext.getCurrentInstance(), "plotBackgroundAlpha", plotBackgroundAlpha);
}
public void setPlotBackgroundPaint(String plotBackgroundPaint) {
@@ -146,8 +139,7 @@
}
public String getPlotBackgroundPaint() {
- return (String) valueBinding(FacesContext.getCurrentInstance(),
- "plotBackgroundPaint", plotBackgroundPaint);
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "plotBackgroundPaint", plotBackgroundPaint);
}
public void setPlotForegroundAlpha(Float plotForegroundAlpha) {
@@ -155,8 +147,7 @@
}
public Float getPlotForegroundAlpha() {
- return (Float) valueBinding(FacesContext.getCurrentInstance(),
- "plotForegroundAlpha", plotForegroundAlpha);
+ return (Float) valueBinding(FacesContext.getCurrentInstance(), "plotForegroundAlpha", plotForegroundAlpha);
}
public void setPlotOutlinePaint(String plotOutlinePaint) {
@@ -164,8 +155,7 @@
}
public String getPlotOutlinePaint() {
- return (String) valueBinding(FacesContext.getCurrentInstance(),
- "plotOutlinePaint", plotOutlinePaint);
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "plotOutlinePaint", plotOutlinePaint);
}
public void setPlotOutlineStroke(String plotOutlineStroke) {
@@ -173,8 +163,7 @@
}
public String getPlotOutlineStroke() {
- return (String) valueBinding(FacesContext.getCurrentInstance(),
- "plotOutlineStroke", plotOutlineStroke);
+ return (String) valueBinding(FacesContext.getCurrentInstance(), "plotOutlineStroke", plotOutlineStroke);
}
public void setDataset(Dataset dataset) {
@@ -182,10 +171,17 @@
}
public Dataset getDataset() {
- return (Dataset) valueBinding(FacesContext.getCurrentInstance(),
- "dataset", dataset);
+ return (Dataset) valueBinding(FacesContext.getCurrentInstance(), "dataset", dataset);
}
+
+ public void setChart(JFreeChart chart) {
+ this.chart = chart;
+ }
+ public JFreeChart getChart() {
+ return (JFreeChart) valueBinding(FacesContext.getCurrentInstance(), "chart", chart);
+ }
+
@Override
public void restoreState(FacesContext context, Object state) {
Object[] values = (Object[]) state;
@@ -253,8 +249,7 @@
return null;
}
- UIComponent component = FacesContext.getCurrentInstance().getViewRoot()
- .findComponent(id);
+ UIComponent component = FacesContext.getCurrentInstance().getViewRoot().findComponent(id);
if (component instanceof UIStroke) {
return ((UIStroke) component).getStroke();
@@ -266,10 +261,6 @@
public abstract JFreeChart createChart(FacesContext context);
- public JFreeChart getChart() {
- return chart;
- }
-
@Override
public void createITextObject(FacesContext context) {
@@ -357,7 +348,11 @@
if (dataset == null) {
dataset = createDataset();
}
- chart = createChart(context);
+
+ chart = getChart();
+ if (chart == null) {
+ chart = createChart(context);
+ }
}
@Override
15 years, 7 months
Seam SVN: r10355 - trunk/src/main/org/jboss/seam/persistence.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-08 13:50:00 -0400 (Wed, 08 Apr 2009)
New Revision: 10355
Modified:
trunk/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java
trunk/src/main/org/jboss/seam/persistence/PersistenceContexts.java
trunk/src/main/org/jboss/seam/persistence/PersistenceProvider.java
Log:
JBSEAM-3030 fix regression where actual flush mode was not being restored after render
Modified: trunk/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2009-04-08 17:48:06 UTC (rev 10354)
+++ trunk/src/main/org/jboss/seam/persistence/HibernatePersistenceProvider.java 2009-04-08 17:50:00 UTC (rev 10355)
@@ -153,7 +153,7 @@
@Override
public void setRenderFlushMode()
{
- PersistenceContexts.instance().changeFlushMode(FlushModeType.MANUAL);
+ PersistenceContexts.instance().changeFlushMode(FlushModeType.MANUAL, true);
}
@Override
Modified: trunk/src/main/org/jboss/seam/persistence/PersistenceContexts.java
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/PersistenceContexts.java 2009-04-08 17:48:06 UTC (rev 10354)
+++ trunk/src/main/org/jboss/seam/persistence/PersistenceContexts.java 2009-04-08 17:50:00 UTC (rev 10355)
@@ -38,7 +38,8 @@
private static final LogProvider log = Logging.getLogProvider(PersistenceContexts.class);
private Set<String> set = new HashSet<String>();
private FlushModeType flushMode;
- private FlushModeType actualFlushMode;
+ // the real flush mode is a backup of the flush mode when doing a temporary switch (such as during render)
+ private FlushModeType realFlushMode;
@Create
public void create()
@@ -47,12 +48,10 @@
if (defaultFlushMode != null)
{
flushMode = defaultFlushMode;
- actualFlushMode = defaultFlushMode;
}
else
{
flushMode = FlushModeType.AUTO;
- actualFlushMode = FlushModeType.AUTO;
}
}
@@ -90,11 +89,30 @@
public void changeFlushMode(FlushModeType flushMode)
{
+ changeFlushMode(flushMode, false);
+ }
+
+ public void changeFlushMode(FlushModeType flushMode, boolean temporary)
+ {
+ if (temporary) {
+ realFlushMode = this.flushMode;
+ }
this.flushMode = flushMode;
- this.actualFlushMode = flushMode;
- changeFlushModes();
+ changeFlushModes();
}
+ /**
+ * Restore the previous flush mode if the current flush mode is marked
+ * as temporary.
+ */
+ public void restoreFlushMode() {
+ if (realFlushMode != null && realFlushMode != flushMode) {
+ flushMode = realFlushMode;
+ realFlushMode = null;
+ changeFlushModes();
+ }
+ }
+
private void changeFlushModes()
{
for (String name: set)
@@ -120,13 +138,11 @@
// some JPA providers may not support MANUAL flushing
// defer the decision to the provider manager component
PersistenceProvider.instance().setRenderFlushMode();
- changeFlushModes();
}
public void afterRender()
{
- flushMode = actualFlushMode;
- changeFlushModes();
+ restoreFlushMode();
}
}
Modified: trunk/src/main/org/jboss/seam/persistence/PersistenceProvider.java
===================================================================
--- trunk/src/main/org/jboss/seam/persistence/PersistenceProvider.java 2009-04-08 17:48:06 UTC (rev 10354)
+++ trunk/src/main/org/jboss/seam/persistence/PersistenceProvider.java 2009-04-08 17:50:00 UTC (rev 10355)
@@ -78,9 +78,11 @@
/**
* <p>
* Set the FlushMode the persistence contexts should use during rendering by
- * calling {@link PersistenceContexts#changeFlushMode(FlushModeType)}. The
+ * calling {@link PersistenceContexts#changeFlushMode(FlushModeType, true)}. The
* actual changing of the flush mode is handled by the
- * {@link PersistenceContexts} instance.
+ * {@link PersistenceContexts} instance. The boolean argument should be true
+ * to indicate that this is a temporary change and that the old flush mode
+ * should be restored after render.
* </p>
* <p>
* Ideally, this should be MANUAL since changes should never flush to the
15 years, 7 months
Seam SVN: r10354 - trunk/seam-gen/src.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-08 13:48:06 -0400 (Wed, 08 Apr 2009)
New Revision: 10354
Modified:
trunk/seam-gen/src/Query.java
Log:
add FIXME
Modified: trunk/seam-gen/src/Query.java
===================================================================
--- trunk/seam-gen/src/Query.java 2009-04-08 17:47:50 UTC (rev 10353)
+++ trunk/seam-gen/src/Query.java 2009-04-08 17:48:06 UTC (rev 10354)
@@ -19,6 +19,7 @@
setMaxResults(25);
}
+ // FIXME this causes the query to run over and over again
@RequestParameter
@Override
public void setFirstResult(Integer firstResult) {
15 years, 7 months
Seam SVN: r10353 - trunk/seam-gen.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2009-04-08 13:47:50 -0400 (Wed, 08 Apr 2009)
New Revision: 10353
Modified:
trunk/seam-gen/build.xml
Log:
surround HTML comment with <ui:remove> to prevent blank menu item
Modified: trunk/seam-gen/build.xml
===================================================================
--- trunk/seam-gen/build.xml 2009-04-08 17:38:22 UTC (rev 10352)
+++ trunk/seam-gen/build.xml 2009-04-08 17:47:50 UTC (rev 10353)
@@ -1249,7 +1249,7 @@
</copy>
<replace file="${project.home}/view/layout/menu.xhtml">
<replacetoken><![CDATA[<!-- @newMenuItem@ -->]]></replacetoken>
- <replacevalue><![CDATA[<s:link view="/useradmin/home.xhtml" id="identityManagement" value="Identity Management" propagation="none" rendered="#{true or identity.hasRole('admin')}"/> <!-- temporarily enabled for all -->
+ <replacevalue><![CDATA[<s:link view="/useradmin/home.xhtml" id="identityManagement" value="Identity Management" propagation="none" rendered="#{true or identity.hasRole('admin')}"/><ui:remove><!-- temporarily enabled for all --></ui:remove>
<!-- @newMenuItem@ -->]]></replacevalue>
</replace>
<replace file="${project.home}/resources/WEB-INF/components.xml">
15 years, 7 months