Seam SVN: r9861 - trunk/ui/src/main/java/org/jboss/seam/ui/validator.
by seam-commits@lists.jboss.org
Author: danielc.roth
Date: 2009-01-04 16:21:13 -0500 (Sun, 04 Jan 2009)
New Revision: 9861
Modified:
trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java
Log:
JBSEAM-3676
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java 2009-01-04 19:52:09 UTC (rev 9860)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/validator/EqualityValidator.java 2009-01-04 21:21:13 UTC (rev 9861)
@@ -6,6 +6,7 @@
import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
import javax.faces.component.StateHolder;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -18,6 +19,7 @@
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
+import org.jboss.seam.ui.component.UIDecorate;
/**
* Validate two fields are equal
@@ -90,12 +92,12 @@
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException
{
- String forId = getFor();
- if (forId == null)
+ if (getFor() == null)
{
throw new FacesException("Must specify a component to validate equality against");
}
- UIComponent otherComponent = component.findComponent(forId);
+ UIComponent otherComponent = findOtherComponent(component);
+
Object other = new OtherComponent(context, otherComponent).getValue();
if (value == null && other == null)
{
@@ -145,6 +147,49 @@
}
}
+ private UIComponent findOtherComponent(UIComponent component)
+ {
+ UIComponent otherComponent = component.findComponent(getFor());
+
+ /**
+ * If s:decorate is used, otherComponent will be null We have to look it
+ * up ourselves
+ */
+ if (otherComponent == null)
+ {
+ UIComponent decorateParent = null;
+ UIComponent parent = component.getParent();
+ while (decorateParent == null && parent != null)
+ {
+ if (parent instanceof NamingContainer && !(parent instanceof UIDecorate))
+ {
+ decorateParent = parent;
+ }
+ parent = parent.getParent();
+ }
+ if (decorateParent != null)
+ otherComponent = findChildComponent(decorateParent);
+
+ }
+ return otherComponent;
+ }
+
+ private UIComponent findChildComponent(UIComponent parent)
+ {
+ UIComponent ret = null;
+ for (UIComponent child : parent.getChildren())
+ {
+ if (child.getId().equals(getFor()))
+ ret = child;
+ else
+ ret = findChildComponent(child);
+ if (ret != null)
+ break;
+ }
+ return ret;
+
+ }
+
private int compare(Object value, Object other) throws IllegalArgumentException
{
try
15 years, 3 months
Seam SVN: r9860 - trunk/doc/Seam_Reference_Guide/it-IT.
by seam-commits@lists.jboss.org
Author: nico.ben
Date: 2009-01-04 14:52:09 -0500 (Sun, 04 Jan 2009)
New Revision: 9860
Modified:
trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po
Log:
JBSEAM-3767: Italian translation of Seam guide
Modified: trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po
===================================================================
--- trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po 2009-01-04 19:33:46 UTC (rev 9859)
+++ trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po 2009-01-04 19:52:09 UTC (rev 9860)
@@ -6,7 +6,7 @@
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2008-12-13 17:58+0000\n"
-"PO-Revision-Date: 2009-01-03 13:20+0100\n"
+"PO-Revision-Date: 2009-01-04 20:51+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -2012,25 +2012,25 @@
#: Tutorial.xml:821
#, no-c-format
msgid "The description property accepts user input form the JSP page, and exposes it to the process definition, allowing the task description to be set."
-msgstr ""
+msgstr "La proprietà descrizione accetta un'input utente dalla pagina JSP e lo espone alla definizione del processo, consentendo che venga impostata la descrizione del task."
#. Tag: para
#: Tutorial.xml:825
#, no-c-format
msgid "The Seam <literal>@CreateProcess</literal> annotation creates a new jBPM process instance for the named process definition."
-msgstr ""
+msgstr "L'annotazione Seam <literal>@CreateProcess</literal> crea una nuova istanza di processo jBPM dalla definizione del processo."
#. Tag: para
#: Tutorial.xml:829
#, no-c-format
msgid "The Seam <literal>@StartTask</literal> annotation starts work on a task. The <literal>@EndTask</literal> ends the task, and allows the business process execution to resume."
-msgstr ""
+msgstr "L'annotazione Seam <literal>@StartTask</literal> avvia un task. <literal>@EndTask</literal> termina il task, e consente di ripristinare l'esecuzione del processo di business."
#. Tag: para
#: Tutorial.xml:838
#, no-c-format
msgid "In a more realistic example, <literal>@StartTask</literal> and <literal>@EndTask</literal> would not appear on the same method, because there is usually work to be done using the application in order to complete the task."
-msgstr ""
+msgstr "In un esempio più realistico <literal>@StartTask</literal> e <literal>@EndTask</literal> non apparirebbero nello stesso metodo, poiché solitamente c'è del lavoro da fare in un'applicazione prima che il task venga terminato."
#. Tag: para
#: Tutorial.xml:842
@@ -2221,7 +2221,7 @@
#: Tutorial.xml:858
#, no-c-format
msgid "Each element of the list is an instance of the jBPM class <literal>TaskInstance</literal>. The following code simply displays the interesting properties of each task in the list. For the description, priority and due date, we use input controls, to allow the user to update these values."
-msgstr ""
+msgstr "Ciascun elemento della lista è un'istanza della classe jBPM <literal>TaskInstance</literal>. Il codice seguente mostra semplicemente le proprietà di interesse per ogni task della lista. Per consentire all'utente di aggiornare i valori di descrizione, priorità e data di ultimazione, si usano i controlli d'input.."
#. Tag: programlisting
#: Tutorial.xml:862
15 years, 3 months
Seam SVN: r9859 - trunk/doc/Seam_Reference_Guide/en-US.
by seam-commits@lists.jboss.org
Author: nico.ben
Date: 2009-01-04 14:33:46 -0500 (Sun, 04 Jan 2009)
New Revision: 9859
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Tutorial.xml
Log:
Corrected error
Modified: trunk/doc/Seam_Reference_Guide/en-US/Tutorial.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Tutorial.xml 2009-01-04 00:15:12 UTC (rev 9858)
+++ trunk/doc/Seam_Reference_Guide/en-US/Tutorial.xml 2009-01-04 19:33:46 UTC (rev 9859)
@@ -1295,7 +1295,7 @@
}]]></programlisting>
<calloutlist>
<callout arearefs="todo-description">
- <para> The description property accepts user input form the JSP page, and exposes it to the
+ <para> The description property accepts user input from the JSP page, and exposes it to the
process definition, allowing the task description to be set. </para>
</callout>
<callout arearefs="todo-createprocess-annotation">
15 years, 3 months
Seam SVN: r9858 - trunk/doc/Seam_Reference_Guide/en-US.
by seam-commits@lists.jboss.org
Author: danielc.roth
Date: 2009-01-03 19:15:12 -0500 (Sat, 03 Jan 2009)
New Revision: 9858
Modified:
trunk/doc/Seam_Reference_Guide/en-US/Controls.xml
Log:
JBSEAM-1350 Docs
Modified: trunk/doc/Seam_Reference_Guide/en-US/Controls.xml
===================================================================
--- trunk/doc/Seam_Reference_Guide/en-US/Controls.xml 2009-01-03 12:21:16 UTC (rev 9857)
+++ trunk/doc/Seam_Reference_Guide/en-US/Controls.xml 2009-01-04 00:15:12 UTC (rev 9858)
@@ -1133,6 +1133,93 @@
</section>
<section>
+ <title><literal><s:resource></literal></title>
+
+ <para><emphasis>Description</emphasis></para>
+ <para>
+ A tag that acts a file download provider. It must be alone in the JSF page.
+ To be able to use this contol, web.xml must be set up as follows.
+ </para>
+
+ <para><emphasis>Configuration</emphasis></para>
+
+ <programlisting role="XML"><![CDATA[<servlet>
+ <servlet-name>Document Store Servlet</servlet-name>
+ <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class>
+</servlet>
+<servlet-mapping>
+ <servlet-name>Document Store Servlet</servlet-name>
+ <url-pattern>/seam/docstore/*</url-pattern>
+</servlet-mapping>
+]]></programlisting>
+
+
+ <para><emphasis>Attributes</emphasis></para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>data</literal> — Data that should be downloaded.
+ May be a java.util.File, an InputStream or a byte array.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>fileName</literal> — Filename of the file to be served
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>contentType</literal> — content type of the file to be downloaded
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <literal>disposition</literal> — disposition to use. Default is inline
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para><emphasis>Usage</emphasis></para>
+ <para>Here is an example on how to use the tag:</para>
+ <programlisting role="XHTML"><![CDATA[<s:resource xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ data="#{resources.data}"
+ contentType="#{resources.contentType}"
+ fileName="#{resources.fileName}" />
+]]></programlisting>
+
+ <para>The bean named <literal>resources</literal> is some backing bean that given
+ some request parameters servers a specific file, see <literal>s:download</literal>.</para>
+ </section>
+
+ <section>
+ <title><literal><s:download></literal></title>
+ <para><emphasis>Description</emphasis></para>
+ <para>Builds a RESTful link to a <literal><s:resource></literal>.
+ Nested <literal>f:param</literal> build up the url.
+ </para>
+
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ <literal>src</literal> — Resource file serving files.
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para><emphasis>Attributes</emphasis></para>
+ <programlisting role="XHTML"><![CDATA[<s:download src="/resources.xhtml">
+ <f:param name="fileId" value="#{someBean.downloadableFileId}"/>
+</s:download>]]></programlisting>
+
+ <para>
+ Will produce something like:
+ <literal><![CDATA[http://localhost/resources.seam?fileId=1]]></literal>
+ </para>
+ </section>
+
+ <section>
<title><literal><s:graphicImage></literal></title>
<para><emphasis>Description</emphasis></para>
15 years, 3 months
Seam SVN: r9857 - trunk/doc/Seam_Reference_Guide/it-IT.
by seam-commits@lists.jboss.org
Author: nico.ben
Date: 2009-01-03 07:21:16 -0500 (Sat, 03 Jan 2009)
New Revision: 9857
Modified:
trunk/doc/Seam_Reference_Guide/it-IT/Jbpm.po
trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po
Log:
JBSEAM-3767: Italian translation of Seam guide
Modified: trunk/doc/Seam_Reference_Guide/it-IT/Jbpm.po
===================================================================
--- trunk/doc/Seam_Reference_Guide/it-IT/Jbpm.po 2009-01-02 23:59:49 UTC (rev 9856)
+++ trunk/doc/Seam_Reference_Guide/it-IT/Jbpm.po 2009-01-03 12:21:16 UTC (rev 9857)
@@ -6,7 +6,7 @@
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2008-10-14 11:38+0000\n"
-"PO-Revision-Date: 2008-12-27 14:28+0100\n"
+"PO-Revision-Date: 2009-01-03 12:17+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -41,7 +41,7 @@
#: Jbpm.xml:30
#, no-c-format
msgid "Defining the overarching business process. The business process may span multiple conversations with multiple users. Its state is persistent in the jBPM database, so it is considered long-running. Coordination of the activities of multiple users is a much more complex problem than scripting an interaction with a single user, so jBPM offers sophisticated facilities for task management and dealing with multiple concurrent paths of execution."
-msgstr "Definizione del processo di business sottostante. Il processo di business può comportare una serie di conversazioni con più utenti. Il suo stato viene persistito nel database jBPM, divenendo così di lunga durata. Il coordinamento delle attività di più utenti è un problema molto più complesso che descrivere l'interazione di un singolo utente, cosicché jBPM offre dei modi sofisticati per la gestione dei compiti (task) e per la gestione di più percorsi concorrenti di esecuzione ."
+msgstr "Definizione del processo di business sottostante. Il processo di business può comportare una serie di conversazioni con più utenti. Il suo stato viene persistito nel database jBPM, divenendo così di lunga durata. Il coordinamento delle attività di più utenti è un problema molto più complesso che descrivere l'interazione di un singolo utente, cosicché jBPM offre dei modi sofisticati per la gestione dei compiti (task) e per la gestione di più percorsi concorrenti di esecuzione."
#. Tag: para
#: Jbpm.xml:42
@@ -222,7 +222,7 @@
#: Jbpm.xml:119
#, no-c-format
msgid "Note that this results in a redirect. You can even specify parameters to be used in the redirect:"
-msgstr "Si noti che questo comporta un redirect. Si può persino specificare i parametri da usare nel redirect:"
+msgstr "Si noti che questo comporta un redirect. Si possono persino specificare i parametri da usare nel redirect:"
#. Tag: programlisting
#: Jbpm.xml:124
Modified: trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po
===================================================================
--- trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po 2009-01-02 23:59:49 UTC (rev 9856)
+++ trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po 2009-01-03 12:21:16 UTC (rev 9857)
@@ -6,7 +6,7 @@
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2008-12-13 17:58+0000\n"
-"PO-Revision-Date: 2009-01-01 17:51+0100\n"
+"PO-Revision-Date: 2009-01-03 13:20+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -1502,37 +1502,37 @@
#: Tutorial.xml:602
#, no-c-format
msgid "This stateful bean has an EJB3 <emphasis>extended persistence context</emphasis>. The messages retrieved in the query remain in the managed state as long as the bean exists, so any subsequent method calls to the stateful bean can update them without needing to make any explicit call to the <literal>EntityManager</literal>."
-msgstr ""
+msgstr "Questo bean stateful ha un <emphasis>contesto di persistenza EJB3 esteso</emphasis>. I messaggi recuperati nella query rimangono nello stato gestito finché esiste il bean, quindi ogni chiamata di metodo conseguente al bean può aggiornarli senza il bisogno di chiamare esplicitamente l'<literal>EntityManager</literal>."
#. Tag: para
#: Tutorial.xml:608
#, no-c-format
msgid "The first time we navigate to the JSP page, there will be no value in the <literal>messageList</literal> context variable. The <literal>@Factory</literal> annotation tells Seam to create an instance of <literal>MessageManagerBean</literal> and invoke the <literal>findMessages()</literal> method to initialize the value. We call <literal>findMessages()</literal> a <emphasis>factory method</emphasis> for <literal>messages</literal>."
-msgstr ""
+msgstr "La prima volta che si naviga in un pagina JSP, non c'è alcun valore nella variabile di contesto <literal>messageList</literal>. L'annotazione <literal>@Factory</literal> dice a Seam di creare un'istanza di <literal>MessageManagerBean</literal> e di invocare il metodo <literal>findMessages()</literal> per inizializzare il valore. <literal>findMessages()</literal> viene chiamato <emphasis>metodo factory</emphasis> di <literal>messages</literal>."
#. Tag: para
#: Tutorial.xml:616
#, no-c-format
msgid "The <literal>select()</literal> action listener method marks the selected <literal>Message</literal> as read, and updates it in the database."
-msgstr ""
+msgstr "Il metodo action listener <literal>select()</literal> marca il <literal>Message</literal> selezionato come letto e lo aggiorna nel database."
#. Tag: para
#: Tutorial.xml:620
#, no-c-format
msgid "The <literal>delete()</literal> action listener method removes the selected <literal>Message</literal> from the database."
-msgstr ""
+msgstr "Il metodo action listener <literal>delete()</literal> rimuove il <literal>Message</literal> dal database."
#. Tag: para
#: Tutorial.xml:624
#, no-c-format
msgid "All stateful session bean Seam components <emphasis>must</emphasis> have a method with no parameters marked <literal>@Remove</literal> that Seam uses to remove the stateful bean when the Seam context ends, and clean up any server-side state."
-msgstr ""
+msgstr "Tutti i componenti Seam bean di sessione stateful <emphasis>devono</emphasis> avere un metodo senza parametri marcato <literal>@Remove</literal> che Seam utilizza per rimuovere il bean stateful quando termina il contesto di Seam, e viene pulito tutto lo stato lato server."
#. Tag: para
#: Tutorial.xml:633
#, no-c-format
msgid "Note that this is a session-scoped Seam component. It is associated with the user login session, and all requests from a login session share the same instance of the component. (In Seam applications, we usually use session-scoped components sparingly.)"
-msgstr ""
+msgstr "Si noti che questo è un componente Seam di sessione. E' associato alla sessione di login dell'utente e tutte le richieste da una login di sessione condividono la stessa istanza del componente. (Nelle applicazioni Seam, solitamente si usano componenti con scope di sessione in maniera contenuta.)"
#. Tag: title
#: Tutorial.xml:640
@@ -1584,7 +1584,7 @@
#: Tutorial.xml:650
#, no-c-format
msgid "Let's skip over <literal>components.xml</literal>, <literal>persistence.xml</literal>, <literal>web.xml</literal>, <literal>ejb-jar.xml</literal>, <literal>faces-config.xml</literal> and <literal>application.xml</literal> since they are much the same as the previous example, and go straight to the JSP."
-msgstr ""
+msgstr "Saltiamo i file <literal>components.xml</literal>, <literal>persistence.xml</literal>, <literal>web.xml</literal>, <literal>ejb-jar.xml</literal>, <literal>faces-config.xml</literal> e <literal>application.xml</literal> poiché sono praticamente uguali all'esempio precedente e andiamo dritti alla pagina JSP."
#. Tag: title
#: Tutorial.xml:658
@@ -1702,19 +1702,19 @@
#: Tutorial.xml:675
#, no-c-format
msgid "The first time we navigate to the <literal>messages.jsp</literal> page, the page will try to resolve the <literal>messageList</literal> context variable. Since this context variable is not initialized, Seam will call the factory method <literal>findMessages()</literal>, which performs a query against the database and results in a <literal>DataModel</literal> being outjected. This <literal>DataModel</literal> provides the row data needed for rendering the <literal><h:dataTable></literal>."
-msgstr ""
+msgstr "La prima volta che si naviga nella pagina <literal>messages.jsp</literal>, la pagina proverà a risolvere la variabile di contesto <literal>messageList</literal>. Poiché questa variabile non è inizializzata, Seam chiamerà il metodo factory <literal>findMessages()</literal>, che esegue la query del database ed mette i risultati in un <literal>DataModel</literal> di cui verrà fatta l'outjection. Questo <literal>DataModel</literal> fornisce i dati di riga necessari per generare la <literal><h:dataTable></literal>."
#. Tag: para
#: Tutorial.xml:682
#, no-c-format
msgid "When the user clicks the <literal><h:commandLink></literal>, JSF calls the <literal>select()</literal> action listener. Seam intercepts this call and injects the selected row data into the <literal>message</literal> attribute of the <literal>messageManager</literal> component. The action listener fires, marking the selected <literal>Message</literal> as read. At the end of the call, Seam outjects the selected <literal>Message</literal> to the context variable named <literal>message</literal>. Next, the EJB container commits the transaction, and the change to the <literal>Message</literal> is flushed to the database. Finally, the page is re-rendered, redisplaying the message list, and displaying the selected message below it."
-msgstr ""
+msgstr "Quando l'utente clicca il <literal><h:commandLink></literal>, JSF chiama l'action listener <literal>select()</literal>. Seam intercetta questa chiamata ed inietta i dati di riga selezionati nell'attributo del componente <literal>messageManager</literal>. L'action listener viene eseguito, marcando come letto il <literal>Message</literal> selezionato. Alla fine della chiamata, Seam esegue l'outjection del <literal>Message</literal> selezionato nella variabile di contesto chiamata <literal>message</literal>. Poi il container EJB committa la transazione ed i cambiamenti a <literal>message</literal> vengono comunicati al database. Infine la pagina vienere rigenerata, rimostrando la lista dei messaggi e mostrando sotto il messaggio selezionato."
#. Tag: para
#: Tutorial.xml:691
#, no-c-format
msgid "If the user clicks the <literal><h:commandButton></literal>, JSF calls the <literal>delete()</literal> action listener. Seam intercepts this call and injects the selected row data into the <literal>message</literal> attribute of the <literal>messageList</literal> component. The action listener fires, removing the selected <literal>Message</literal> from the list, and also calling <literal>remove()</literal> on the <literal>EntityManager</literal>. At the end of the call, Seam refreshes the <literal>messageList</literal> context variable and clears the context variable named <literal>message</literal>. The EJB container commits the transaction, and deletes the <literal>Message</literal> from the database. Finally, the page is re-rendered, redisplaying the message list."
-msgstr ""
+msgstr "Se l'utente clicca <literal><h:commandButton></literal>, JSF chiama l'action listener <literal>delete()</literal>. Seam intercetta questa chiamata ed inietta i dati selezionati nell'attributo <literal>message</literal> del componente <literal>messageList</literal>. L'action listener viene eseguito, rimuovendo dalla lista il <literal>Message</literal>, e chiamando anche il metodo <literal>remove()</literal> dell'<literal>EntityManager</literal>. Alla fine della chiamata, Seam aggiorna la variabile di contesto <literal>messageList</literal> e pulisce la variabiledicontesto chiamata <literal>message</literal>. Il container EJB committa latransazione ecancella <literal>Message</literal> dal database. Infine la pagina viene rigenerata, rimostrando la lista dei messaggi."
#. Tag: title
#: Tutorial.xml:706
@@ -1726,13 +1726,13 @@
#: Tutorial.xml:708
#, no-c-format
msgid "jBPM provides sophisticated functionality for workflow and task management. To get a small taste of how jBPM integrates with Seam, we'll show you a simple \"todo list\" application. Since managing lists of tasks is such core functionality for jBPM, there is hardly any Java code at all in this example."
-msgstr ""
+msgstr "jBPM fornisce una funzionalità sofisticata per il workflow e la gestione dei task. Per provare come jBPM si integra con Seam, viene mostrata l'applicazione \"todo list\". Poiché gestire liste di task è la funzione base di jBPM, non c'è praticamente alcun codice Java in quest'esempio."
#. Tag: para
#: Tutorial.xml:723
#, no-c-format
msgid "The center of this example is the jBPM process definition. There are also two JSPs and two trivial JavaBeans (There was no reason to use session beans, since they do not access the database, or have any other transactional behavior). Let's start with the process definition:"
-msgstr ""
+msgstr "La parte centrale dell'esempio è la definizione del processo jBPM. Ci sono anche due pagine JSP e due banalissimi JavaBean (Non c'è alcuna ragione per usare session bean, poiché questi non accedono al database, e non hanno un comportamento transazionale). Cominciamo con la definizione del processo:"
#. Tag: title
#: Tutorial.xml:728
@@ -1782,49 +1782,49 @@
#: Tutorial.xml:740
#, no-c-format
msgid "The <literal><start-state></literal> node represents the logical start of the process. When the process starts, it immediately transitions to the <literal>todo</literal> node."
-msgstr ""
+msgstr "Il nodo <literal><start-state></literal> rappresenta l'inizio logico del processo. Quando il processo inizia, transita subito nel nodo <literal>todo</literal>."
#. Tag: para
#: Tutorial.xml:745
#, no-c-format
msgid "The <literal><task-node></literal> node represents a <emphasis>wait state</emphasis>, where business process execution pauses, waiting for one or more tasks to be performed."
-msgstr ""
+msgstr "Il nodo <literal><task-node></literal> rappresenta uno <emphasis>stato di attesa</emphasis>, dove l'esecuzione del processo di business va in pausa, ed aspetta che uno o pià task vengano eseguiti."
#. Tag: para
#: Tutorial.xml:750
#, no-c-format
msgid "The <literal><task></literal> element defines a task to be performed by a user. Since there is only one task defined on this node, when it is complete, execution resumes, and we transition to the end state. The task gets its description from a Seam component named <literal>todoList</literal> (one of the JavaBeans)."
-msgstr ""
+msgstr "L'elemento <literal><task></literal> definisce un task che deve essere eseguito da un utente. Poiché c'è solo un task definito su questo nodo, quando completa, l'esecuzione riprende e si transita verso lo stato finale. Il task recupera la sua descrizione da un componente Seam chiamato <literal>todoList</literal> (uno dei JavaBean)."
#. Tag: para
#: Tutorial.xml:756
#, no-c-format
msgid "Tasks need to be assigned to a user or group of users when they are created. In this case, the task is assigned to the current user, which we get from a built-in Seam component named <literal>actor</literal>. Any Seam component may be used to perform task assignment."
-msgstr ""
+msgstr "I task devono essere assegnati ad un utente od un gruppo di utenti quando vengono creati. In questo caso il task viene assegnato all'utente corrente che viene recuperato dal componente Seam predefinito chiamato <literal>actor</literal>. Ogni componente Seam può essegre impiegato per assegnare un task."
#. Tag: para
#: Tutorial.xml:762
#, no-c-format
msgid "The <literal><end-state></literal> node defines the logical end of the business process. When execution reaches this node, the process instance is destroyed."
-msgstr ""
+msgstr "Il nodo <literal><end-state></literal> definisce la fine logica del processo di business. Quando l'esecuzione raggiunge questo nodo, l'istanza di processo viene distrutta."
#. Tag: para
#: Tutorial.xml:771
#, no-c-format
msgid "If we view this process definition using the process definition editor provided by JBossIDE, this is what it looks like:"
-msgstr ""
+msgstr "Se viene impiegato l'editor per le definizioni di processo fornito da JBossIDE, questa apparirà così:"
#. Tag: para
#: Tutorial.xml:783
#, no-c-format
msgid "This document defines our <emphasis>business process</emphasis> as a graph of nodes. This is the most trivial possible business process: there is one <emphasis>task</emphasis> to be performed, and when that task is complete, the business process ends."
-msgstr ""
+msgstr "Questo documento definisce il <emphasis>processo di business</emphasis> come un grafo di nodi. Questo è un processo di business molto banale: c'è un <emphasis>task</emphasis> da eseguire e quando questo viene completato, il processo termina."
#. Tag: para
#: Tutorial.xml:787
#, no-c-format
msgid "The first JavaBean handles the login screen <literal>login.jsp</literal>. Its job is just to initialize the jBPM actor id using the <literal>actor</literal> component. In a real application, it would also need to authenticate the user."
-msgstr ""
+msgstr "Il primo javaBean gestisce la pagina <literal>login.jsp</literal>. Il suo compito è quello di inizializzare l'id actor jBPM usando il componente <literal>actor</literal>. Nelle applicazioni occorrerà autenticare l'utente."
#. Tag: title
#: Tutorial.xml:791
@@ -2185,7 +2185,7 @@
#: Tutorial.xml:849
#, no-c-format
msgid "Let's take this one piece at a time."
-msgstr ""
+msgstr "Si prenda un pezzo alla volta."
#. Tag: para
#: Tutorial.xml:851
15 years, 3 months
Seam SVN: r9856 - in trunk: src/excel/org/jboss/seam/excel/ui and 5 other directories.
by seam-commits@lists.jboss.org
Author: danielc.roth
Date: 2009-01-02 18:59:49 -0500 (Fri, 02 Jan 2009)
New Revision: 9856
Modified:
trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java
trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java
trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java
trunk/src/main/org/jboss/seam/document/DocumentStore.java
trunk/src/main/org/jboss/seam/navigation/Pages.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java
trunk/src/rss/org/jboss/seam/rss/ui/UIFeed.java
trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java
Log:
JBSEAM-3684 and some minors
Modified: trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java 2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java 2009-01-02 23:59:49 UTC (rev 9856)
@@ -153,7 +153,7 @@
private void redirectExport()
{
String viewId = Pages.getViewId(FacesContext.getCurrentInstance());
- String baseName = UIWorkbook.baseNameForViewId(viewId);
+ String baseName = Pages.getCurrentBaseName();
DocumentData documentData = new ByteArrayDocumentData(baseName, excelWorkbook.getDocumentType(), excelWorkbook.getBytes());
String id = DocumentStore.instance().newId();
String url = DocumentStore.instance().preferredUrlForContent(baseName, excelWorkbook.getDocumentType().getExtension(), id);
Modified: trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java 2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java 2009-01-02 23:59:49 UTC (rev 9856)
@@ -326,7 +326,7 @@
DocumentType type = excelWorkbook.getDocumentType();
String viewId = Pages.getViewId(context);
- String baseName = baseNameForViewId(viewId);
+ String baseName = Pages.getCurrentBaseName();
DocumentData documentData = new ByteArrayDocumentData(baseName, type, bytes);
documentData.setFilename(getFilename());
@@ -362,23 +362,6 @@
}
}
- public static String baseNameForViewId(String viewId)
- {
- int pos = viewId.lastIndexOf("/");
- if (pos != -1)
- {
- viewId = viewId.substring(pos + 1);
- }
-
- pos = viewId.lastIndexOf(".");
- if (pos != -1)
- {
- viewId = viewId.substring(0, pos);
- }
-
- return viewId;
- }
-
public boolean isSendRedirect()
{
return (Boolean) valueOf("sendRedirect", sendRedirect);
Modified: trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java
===================================================================
--- trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java 2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java 2009-01-02 23:59:49 UTC (rev 9856)
@@ -11,6 +11,7 @@
public ByteArrayDocumentData(String baseName, DocumentType documentType, byte[] data)
{
super(baseName, documentType);
+ this.data = data;
}
@Override
Modified: trunk/src/main/org/jboss/seam/document/DocumentStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/document/DocumentStore.java 2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/main/org/jboss/seam/document/DocumentStore.java 2009-01-02 23:59:49 UTC (rev 9856)
@@ -20,7 +20,7 @@
public class DocumentStore
implements Serializable
{
- public static final String DOCSTORE_BASE_URL = "/seam-docstore";
+ public static final String DOCSTORE_BASE_URL = "/seam/docstore/";
private static final long serialVersionUID = -357154201942127711L;
Modified: trunk/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Pages.java 2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/main/org/jboss/seam/navigation/Pages.java 2009-01-02 23:59:49 UTC (rev 9856)
@@ -1654,6 +1654,25 @@
return getViewId( FacesContext.getCurrentInstance() );
}
+ public static String getCurrentBaseName()
+ {
+ String viewId = getViewId(FacesContext.getCurrentInstance());
+
+ int pos = viewId.lastIndexOf("/");
+ if (pos != -1)
+ {
+ viewId = viewId.substring(pos + 1);
+ }
+
+ pos = viewId.lastIndexOf(".");
+ if (pos != -1)
+ {
+ viewId = viewId.substring(0, pos);
+ }
+
+ return viewId;
+ }
+
public static String getViewId(FacesContext facesContext)
{
if (facesContext!=null)
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java 2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java 2009-01-02 23:59:49 UTC (rev 9856)
@@ -293,23 +293,6 @@
}
}
- protected String baseNameForViewId(String viewId)
- {
- int pos = viewId.lastIndexOf("/");
- if (pos != -1)
- {
- viewId = viewId.substring(pos + 1);
- }
-
- pos = viewId.lastIndexOf(".");
- if (pos != -1)
- {
- viewId = viewId.substring(0, pos);
- }
-
- return viewId;
- }
-
@Override
public void encodeEnd(FacesContext context) throws IOException
{
@@ -323,7 +306,7 @@
}
String viewId = Pages.getViewId(context);
- String baseName = baseNameForViewId(viewId);
+ String baseName = Pages.getCurrentBaseName();
DocumentData documentData = new ByteArrayDocumentData(baseName, documentType, bytes);
String dispositionValue = (String) valueBinding(context, "disposition", disposition);
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java 2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java 2009-01-02 23:59:49 UTC (rev 9856)
@@ -102,7 +102,7 @@
}
String viewId = Pages.getViewId(facesContext);
- String baseName = baseNameForViewId(viewId);
+ String baseName = Pages.getCurrentBaseName();
DocumentStore store = DocumentStore.instance();
DocumentType documentType = new DocumentData.DocumentType("pdf", "application/pdf");
@@ -124,23 +124,6 @@
facesContext.getExternalContext().redirect(url);
}
- public static String baseNameForViewId(String viewId)
- {
- int pos = viewId.lastIndexOf("/");
- if (pos != -1)
- {
- viewId = viewId.substring(pos + 1);
- }
-
- pos = viewId.lastIndexOf(".");
- if (pos != -1)
- {
- viewId = viewId.substring(0, pos);
- }
-
- return viewId;
- }
-
@Override
public String getFamily()
{
Modified: trunk/src/rss/org/jboss/seam/rss/ui/UIFeed.java
===================================================================
--- trunk/src/rss/org/jboss/seam/rss/ui/UIFeed.java 2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/rss/org/jboss/seam/rss/ui/UIFeed.java 2009-01-02 23:59:49 UTC (rev 9856)
@@ -6,10 +6,10 @@
import java.text.SimpleDateFormat;
import java.util.Date;
+import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;
import org.jboss.seam.contexts.Contexts;
-import javax.faces.context.FacesContext;
import yarfraw.core.datamodel.ChannelFeed;
import yarfraw.core.datamodel.FeedFormat;
@@ -18,23 +18,23 @@
/*
* atomFeed =
- element atom:feed {
- atomCommonAttributes,
- (atomAuthor*
- & atomCategory*
- & atomContributor*
- & atomGenerator?
- & atomIcon?
- & atomId
- & atomLink*
- & atomLogo?
- & atomRights?
- & atomSubtitle?
- & atomTitle
- & atomUpdated
- & extensionElement*),
- atomEntry*
- }
+ element atom:feed {
+ atomCommonAttributes,
+ (atomAuthor*
+ & atomCategory*
+ & atomContributor*
+ & atomGenerator?
+ & atomIcon?
+ & atomId
+ & atomLink*
+ & atomLogo?
+ & atomRights?
+ & atomSubtitle?
+ & atomTitle
+ & atomUpdated
+ & extensionElement*),
+ atomEntry*
+ }
*/
public class UIFeed extends SyndicationComponent
@@ -52,7 +52,6 @@
private String link;
private FeedFormat feedFormat = FeedFormat.ATOM10;
-
@SuppressWarnings("unchecked")
@Override
public void encodeBegin(FacesContext facesContext) throws IOException
@@ -61,7 +60,8 @@
channelFeed.setUid(getUid());
channelFeed.setTitle(getTitle());
channelFeed.setDescriptionOrSubtitle(getSubtitle());
- if (getUpdated() != null) {
+ if (getUpdated() != null)
+ {
channelFeed.setPubDate(getUpdated(), new SimpleDateFormat(ATOM_DATE_FORMAT));
}
channelFeed.addLink(getLink());
@@ -73,17 +73,20 @@
{
ChannelFeed channelFeed = (ChannelFeed) Contexts.getEventContext().get(FEED_IMPL_KEY);
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
- try {
+ try
+ {
FeedWriter.writeChannel(feedFormat, channelFeed, byteStream);
- } catch (YarfrawException e) {
+ }
+ catch (YarfrawException e)
+ {
/**
* Was IOException, but 1.5 does not have this constructor
* http://java.sun.com/j2se/1.5.0/docs/api/java/io/IOException.html
*/
throw new RuntimeException("Could not create feed", e);
}
- Writer responseWriter = ((HttpServletResponse)facesContext.getExternalContext().getResponse()).getWriter();
- HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
+ Writer responseWriter = ((HttpServletResponse) facesContext.getExternalContext().getResponse()).getWriter();
+ HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
response.setContentType(MIMETYPE);
response.setContentLength(byteStream.size());
responseWriter.write(byteStream.toString());
@@ -91,23 +94,6 @@
facesContext.responseComplete();
}
- public static String baseNameForViewId(String viewId)
- {
- int pos = viewId.lastIndexOf("/");
- if (pos != -1)
- {
- viewId = viewId.substring(pos + 1);
- }
-
- pos = viewId.lastIndexOf(".");
- if (pos != -1)
- {
- viewId = viewId.substring(0, pos);
- }
-
- return viewId;
- }
-
public boolean isSendRedirect()
{
return sendRedirect;
@@ -184,5 +170,4 @@
this.uid = uid;
}
-
}
Modified: trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java 2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java 2009-01-02 23:59:49 UTC (rev 9856)
@@ -20,7 +20,7 @@
public static String addResourceToDataStore(FacesContext ctx, UIResource resource)
{
- String baseName = baseNameForViewId(Pages.getCurrentViewId());
+ String baseName = Pages.getCurrentBaseName();
String viewId = Pages.getViewId(ctx);
DocumentStore store = DocumentStore.instance();
@@ -77,26 +77,4 @@
}
- /**
- * TODO: This part should be refactored in to Pages.java Used (at least)
- * here, in pdf module and excel
- *
- */
- public static String baseNameForViewId(String viewId)
- {
- int pos = viewId.lastIndexOf("/");
- if (pos != -1)
- {
- viewId = viewId.substring(pos + 1);
- }
-
- pos = viewId.lastIndexOf(".");
- if (pos != -1)
- {
- viewId = viewId.substring(0, pos);
- }
-
- return viewId;
- }
-
}
15 years, 3 months
Seam SVN: r9855 - in trunk: examples/ui/resources/WEB-INF and 7 other directories.
by seam-commits@lists.jboss.org
Author: danielc.roth
Date: 2009-01-02 17:56:08 -0500 (Fri, 02 Jan 2009)
New Revision: 9855
Added:
trunk/examples/ui/src/org/jboss/seam/example/ui/Resources.java
trunk/examples/ui/view/resource.xhtml
trunk/examples/ui/view/resources.xhtml
trunk/ui/src/main/config/component/download.xml
trunk/ui/src/main/config/component/resource.xml
trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java
trunk/ui/src/main/java/org/jboss/seam/ui/component/UIDownload.java
trunk/ui/src/main/java/org/jboss/seam/ui/component/UIResource.java
trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/DownloadRendererBase.java
trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/ResourceRendererBase.java
Modified:
trunk/examples/mail/src/org/jboss/seam/example/mail/test/MailTest.java
trunk/examples/ui/resources/WEB-INF/web.xml
trunk/examples/ui/view/template.xhtml
trunk/src/main/org/jboss/seam/document/package-info.java
Log:
JBSEAM-1350 pt2/3
Modified: trunk/examples/mail/src/org/jboss/seam/example/mail/test/MailTest.java
===================================================================
--- trunk/examples/mail/src/org/jboss/seam/example/mail/test/MailTest.java 2009-01-02 22:13:54 UTC (rev 9854)
+++ trunk/examples/mail/src/org/jboss/seam/example/mail/test/MailTest.java 2009-01-02 22:56:08 UTC (rev 9855)
@@ -4,7 +4,6 @@
import static javax.mail.Message.RecipientType.CC;
import java.io.InputStream;
-import java.util.Enumeration;
import javax.faces.FacesException;
import javax.faces.context.FacesContext;
@@ -14,13 +13,13 @@
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
-import org.jboss.seam.mail.ui.UIAttachment;
-import org.jboss.seam.mail.ui.UIMessage;
+import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.document.ByteArrayDocumentData;
import org.jboss.seam.document.DocumentData;
-import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.example.mail.Person;
import org.jboss.seam.mail.MailSession;
+import org.jboss.seam.mail.ui.UIAttachment;
+import org.jboss.seam.mail.ui.UIMessage;
import org.jboss.seam.mock.MockTransport;
import org.jboss.seam.mock.SeamTest;
import org.testng.annotations.Test;
Modified: trunk/examples/ui/resources/WEB-INF/web.xml
===================================================================
--- trunk/examples/ui/resources/WEB-INF/web.xml 2009-01-02 22:13:54 UTC (rev 9854)
+++ trunk/examples/ui/resources/WEB-INF/web.xml 2009-01-02 22:56:08 UTC (rev 9855)
@@ -20,6 +20,15 @@
<url-pattern>/seam/resource/*</url-pattern>
</servlet-mapping>
+ <servlet>
+ <servlet-name>Document Store Servlet</servlet-name>
+ <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Document Store Servlet</servlet-name>
+ <url-pattern>/seam/docstore/*</url-pattern>
+ </servlet-mapping>
+
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
Added: trunk/examples/ui/src/org/jboss/seam/example/ui/Resources.java
===================================================================
--- trunk/examples/ui/src/org/jboss/seam/example/ui/Resources.java (rev 0)
+++ trunk/examples/ui/src/org/jboss/seam/example/ui/Resources.java 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,101 @@
+package org.jboss.seam.example.ui;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.web.RequestParameter;
+
+@Name("resources")
+(a)Scope(ScopeType.EVENT)
+public class Resources
+{
+
+ private static Map<String, ResourceItem> resources = new HashMap<String, ResourceItem>();
+
+ static
+ {
+ resources.put("1", new ResourceItem("text.txt", new byte[] { 'a', 'b', 'c' }, null, "text/plain"));
+ ByteArrayInputStream str = new ByteArrayInputStream(new byte[] { '1', '2', '3' });
+ resources.put("2", new ResourceItem("numbers.txt", str, null, "text/plain"));
+ }
+
+ @RequestParameter
+ private String id;
+
+ private ResourceItem item;
+
+ @Create
+ public void create()
+ {
+ item = resources.get(id);
+ }
+
+ public static class ResourceItem
+ {
+
+ public ResourceItem(String fileName, Object data, String disposition, String contentType)
+ {
+ this.fileName = fileName;
+ this.data = data;
+ this.disposition = disposition;
+ this.contentType = contentType;
+ }
+
+ public String fileName;
+ public Object data;
+ public String disposition;
+ public String contentType;
+
+ public String getFileName()
+ {
+ return fileName;
+ }
+
+ public Object getData()
+ {
+ return data;
+ }
+
+ public String getDisposition()
+ {
+ return disposition;
+ }
+
+ public String getContentType()
+ {
+ return contentType;
+ }
+
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public ResourceItem getItem()
+ {
+ return item;
+ }
+
+ public void setItem(ResourceItem item)
+ {
+ this.item = item;
+ }
+
+ public ResourceItem getTextItem()
+ {
+ return resources.get("1");
+ }
+
+}
Added: trunk/examples/ui/view/resource.xhtml
===================================================================
--- trunk/examples/ui/view/resource.xhtml (rev 0)
+++ trunk/examples/ui/view/resource.xhtml 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,26 @@
+<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ template="template.xhtml">
+ <ui:param name="tagName" value="s:resource, s:download" />
+ <ui:define name="body">
+ <p>Download a file.</p>
+ <h:panelGrid columns="3">
+ <h:outputText value="Totally restful" />
+ <h:outputLink value="resources.seam?id=1">Text</h:outputLink>
+ <h:outputLink value="resources.seam?id=2">Numbers</h:outputLink>
+ <h:outputText value="Restful with s:download" />
+ <s:download src="/resources.xhtml">
+ <h:outputText value="Text" />
+ <f:param name="id" value="1" />
+ </s:download>
+ <s:download src="/resources.xhtml">
+ <h:outputText value="Numbers" />
+ <f:param name="id" value="2" />
+ </s:download>
+ </h:panelGrid>
+ </ui:define>
+</ui:composition>
Added: trunk/examples/ui/view/resources.xhtml
===================================================================
--- trunk/examples/ui/view/resources.xhtml (rev 0)
+++ trunk/examples/ui/view/resources.xhtml 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,5 @@
+<s:resource xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:s="http://jboss.com/products/seam/taglib"
+ data="#{resources.item.data}"
+ contentType="#{resources.item.contentType}"
+ fileName="#{resources.item.fileName}" />
Modified: trunk/examples/ui/view/template.xhtml
===================================================================
--- trunk/examples/ui/view/template.xhtml 2009-01-02 22:13:54 UTC (rev 9854)
+++ trunk/examples/ui/view/template.xhtml 2009-01-02 22:56:08 UTC (rev 9855)
@@ -105,7 +105,12 @@
<li><s:link view="/equalityValidatorWConvert.xhtml">
<code>s:validateEquality(2)</code>
</s:link></li>
+
+ <li><s:link view="/resource.xhtml">
+ <code>s:resource/download</code>
+ </s:link></li>
+
<li><s:span title="#{spanTitle}" style="font-weight:bold">
<code>s:span</code>
</s:span>
Modified: trunk/src/main/org/jboss/seam/document/package-info.java
===================================================================
--- trunk/src/main/org/jboss/seam/document/package-info.java 2009-01-02 22:13:54 UTC (rev 9854)
+++ trunk/src/main/org/jboss/seam/document/package-info.java 2009-01-02 22:56:08 UTC (rev 9855)
@@ -2,3 +2,4 @@
package org.jboss.seam.document;
import org.jboss.seam.annotations.Namespace;
+
Added: trunk/ui/src/main/config/component/download.xml
===================================================================
--- trunk/ui/src/main/config/component/download.xml (rev 0)
+++ trunk/ui/src/main/config/component/download.xml 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "http://jboss.org/jbossrichfaces/component-config.dtd" >
+<components>
+ <component>
+ <name>org.jboss.seam.ui.Download</name>
+ <family>org.jboss.seam.ui.Download</family>
+ <classname>org.jboss.seam.ui.component.html.HtmlDownload</classname>
+ <superclass>org.jboss.seam.ui.component.UIDownload</superclass>
+ <description>
+ <![CDATA[Link for downloading a file]]>
+ </description>
+ <renderer generate="false" override="false">
+ <name>org.jboss.seam.ui.DownloadRenderer</name>
+ <classname>org.jboss.seam.ui.renderkit.DownloadRendererBase</classname>
+ </renderer>
+ <tag>
+ <name>download</name>
+ <classname>org.jboss.seam.ui.taglib.DownloadTag</classname>
+ <superclass>
+ org.jboss.seam.ui.util.cdk.UIComponentTagBase
+ </superclass>
+ </tag>
+ &html_style_attributes;
+ <property>
+ <name>src</name>
+ <classname>java.lang.String</classname>
+ <description>Source xhtml file that acts as resource holder</description>
+ </property>
+ <property>
+ <name>rendered</name>
+ <classname>boolean</classname>
+ <description>true iff this component should be rendered</description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ </component>
+</components>
Added: trunk/ui/src/main/config/component/resource.xml
===================================================================
--- trunk/ui/src/main/config/component/resource.xml (rev 0)
+++ trunk/ui/src/main/config/component/resource.xml 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "http://jboss.org/jbossrichfaces/component-config.dtd" >
+<components>
+ <component>
+ <name>org.jboss.seam.ui.Resource</name>
+ <family>org.jboss.seam.ui.Resource</family>
+ <classname>org.jboss.seam.ui.component.html.HtmlResource</classname>
+ <superclass>org.jboss.seam.ui.component.UIResource</superclass>
+ <description>
+ <![CDATA[Given a data in form of an inputstream, java.util.File or byte[] and a content-type, this tag sends the data to the browser]]>
+ </description>
+ <renderer generate="false" override="false">
+ <name>org.jboss.seam.ui.ResourceRenderer</name>
+ <classname>org.jboss.seam.ui.renderkit.ResourceRendererBase</classname>
+ </renderer>
+ <tag>
+ <name>resource</name>
+ <classname>org.jboss.seam.ui.taglib.ResourceTag</classname>
+ <superclass>
+ org.jboss.seam.ui.util.cdk.UIComponentTagBase
+ </superclass>
+ </tag>
+ <property>
+ <name>data</name>
+ <classname>java.lang.Object</classname>
+ <description>Inputstream, File or byte[].</description>
+ </property>
+ <property>
+ <name>contentType</name>
+ <classname>java.lang.String</classname>
+ <description>Content-type of given data</description>
+ </property>
+ <property>
+ <name>fileName</name>
+ <classname>java.lang.String</classname>
+ <description>file name to send to browser (default: name of view)</description>
+ </property>
+ <property>
+ <name>disposition</name>
+ <classname>java.lang.String</classname>
+ <description>Content-Disposition for file (default: inline)</description>
+ </property>
+ </component>
+</components>
Added: trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,102 @@
+package org.jboss.seam.ui;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.faces.context.FacesContext;
+
+import org.jboss.seam.core.Manager;
+import org.jboss.seam.document.DocumentData;
+import org.jboss.seam.document.DocumentStore;
+import org.jboss.seam.document.DocumentData.DocumentType;
+import org.jboss.seam.navigation.Pages;
+import org.jboss.seam.ui.component.UIResource;
+
+public class DocumentStoreUtils
+{
+
+ public static String addResourceToDataStore(FacesContext ctx, UIResource resource)
+ {
+ String baseName = baseNameForViewId(Pages.getCurrentViewId());
+ String viewId = Pages.getViewId(ctx);
+
+ DocumentStore store = DocumentStore.instance();
+ String id = store.newId();
+
+ DocumentType type = new DocumentType("", resource.getContentType());
+
+ DocumentData documentData = new DownloadableDocumentData(baseName, type, resource.getData());
+ documentData.setFilename(resource.getFileName());
+ documentData.setDisposition(resource.getDisposition());
+
+ String url = store.preferredUrlForContent(resource.getFileName(), type.getExtension(), id);
+ url = Manager.instance().encodeConversationId(url, viewId);
+ store.saveData(id, documentData);
+ return url;
+ }
+
+ static class DownloadableDocumentData extends DocumentData
+ {
+
+ private Object data;
+
+ public DownloadableDocumentData(String baseName, DocumentType type, Object data)
+ {
+ super(baseName, type);
+ this.data = data;
+ }
+
+ @Override
+ public void writeDataToStream(OutputStream os) throws IOException
+ {
+ if (data instanceof byte[])
+ {
+ os.write((byte[]) data);
+ }
+ else if (data instanceof File)
+ {
+ writeStream(os, new FileInputStream((File) data));
+ }
+ else if (data instanceof InputStream)
+ {
+ writeStream(os, (InputStream) data);
+ }
+
+ }
+
+ private void writeStream(OutputStream os, InputStream is) throws IOException
+ {
+ while (is.available() > 0)
+ {
+ os.write(is.read());
+ }
+ }
+
+ }
+
+ /**
+ * TODO: This part should be refactored in to Pages.java Used (at least)
+ * here, in pdf module and excel
+ *
+ */
+ public static String baseNameForViewId(String viewId)
+ {
+ int pos = viewId.lastIndexOf("/");
+ if (pos != -1)
+ {
+ viewId = viewId.substring(pos + 1);
+ }
+
+ pos = viewId.lastIndexOf(".");
+ if (pos != -1)
+ {
+ viewId = viewId.substring(0, pos);
+ }
+
+ return viewId;
+ }
+
+}
Added: trunk/ui/src/main/java/org/jboss/seam/ui/component/UIDownload.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/component/UIDownload.java (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/component/UIDownload.java 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,14 @@
+package org.jboss.seam.ui.component;
+
+/**
+ *
+ * @author Daniel Roth
+ *
+ */
+public abstract class UIDownload extends UILink
+{
+ public abstract String getSrc();
+
+ public abstract void setSrc(String src);
+
+}
Added: trunk/ui/src/main/java/org/jboss/seam/ui/component/UIResource.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/component/UIResource.java (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/component/UIResource.java 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,41 @@
+package org.jboss.seam.ui.component;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Daniel Roth
+ */
+public abstract class UIResource extends UIComponentBase
+{
+
+ public abstract Object getData();
+
+ public abstract void setData(Object data);
+
+ public abstract String getContentType();
+
+ public abstract void setContentType(String contentType);
+
+ public abstract String getDisposition();
+
+ public abstract void setDisposition(String disposition);
+
+ public abstract String getFileName();
+
+ public abstract void setFileName(String fileName);
+
+ @Override
+ public void encodeBegin(FacesContext arg0) throws IOException
+ {
+ if (!(getParent() instanceof UIViewRoot || getParent() instanceof UIDownload))
+ {
+ throw new IllegalArgumentException("s:remote must be nested in a s:download or alone in the page");
+ }
+ super.encodeBegin(arg0);
+ }
+
+}
Added: trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/DownloadRendererBase.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/DownloadRendererBase.java (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/DownloadRendererBase.java 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,81 @@
+package org.jboss.seam.ui.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIParameter;
+import javax.faces.context.FacesContext;
+
+import org.jboss.seam.ui.component.UIDownload;
+import org.jboss.seam.ui.component.UIResource;
+import org.jboss.seam.ui.util.HTML;
+import org.jboss.seam.ui.util.ViewUrlBuilder;
+import org.jboss.seam.ui.util.cdk.RendererBase;
+
+public class DownloadRendererBase extends RendererBase
+{
+
+ @Override
+ protected Class getComponentClass()
+ {
+ return UIDownload.class;
+ }
+
+ @Override
+ protected void doEncodeBegin(javax.faces.context.ResponseWriter writer, FacesContext ctx, UIComponent component) throws IOException
+ {
+ UIDownload download = (UIDownload) component;
+
+ if (!download.isRendered())
+ return;
+
+ if (download.getSrc() != null)
+ {
+
+ ViewUrlBuilder builder = new ViewUrlBuilder(download.getSrc(), null);
+
+ for (Object child : download.getChildren())
+ {
+ if (child instanceof UIParameter)
+ {
+ builder.addParameter((UIParameter) child);
+ }
+
+ }
+ writeStartTag(writer, download, builder.getEncodedUrl());
+ renderNonResourceChildren(ctx, download);
+ writer.endElement(HTML.ANCHOR_ELEM);
+
+ }
+
+ }
+
+ private void renderNonResourceChildren(FacesContext ctx, UIComponent component) throws IOException
+ {
+ for (Object child : component.getChildren())
+ {
+ if (!(child instanceof UIParameter) && !(child instanceof UIResource) && (child instanceof UIComponent))
+ {
+ renderChild(ctx, (UIComponent) child);
+ }
+
+ }
+ }
+
+ private void writeStartTag(javax.faces.context.ResponseWriter writer, UIDownload download, String url) throws IOException
+ {
+ writer.startElement(HTML.ANCHOR_ELEM, null);
+ writer.writeAttribute(HTML.HREF_ATTR, url, null);
+ if (download.getStyle() != null)
+ writer.writeAttribute(HTML.STYLE_ATTR, download.getStyle(), null);
+ if (download.getStyleClass() != null)
+ writer.writeAttribute(HTML.STYLE_CLASS_ATTR, download.getStyleClass(), null);
+ }
+
+ @Override
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+}
Added: trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/ResourceRendererBase.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/ResourceRendererBase.java (rev 0)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/renderkit/ResourceRendererBase.java 2009-01-02 22:56:08 UTC (rev 9855)
@@ -0,0 +1,35 @@
+package org.jboss.seam.ui.renderkit;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.jboss.seam.ui.DocumentStoreUtils;
+import org.jboss.seam.ui.component.UIResource;
+import org.jboss.seam.ui.util.cdk.RendererBase;
+
+public class ResourceRendererBase extends RendererBase
+{
+
+ @Override
+ protected Class getComponentClass()
+ {
+ return UIResource.class;
+ }
+
+ @Override
+ protected void doEncodeBegin(javax.faces.context.ResponseWriter writer, FacesContext ctx, UIComponent component) throws IOException
+ {
+
+ UIResource resource = (UIResource) component;
+
+ String url = DocumentStoreUtils.addResourceToDataStore(ctx, resource);
+
+ ctx.getExternalContext().redirect(url);
+
+ }
+
+
+
+}
15 years, 3 months
Seam SVN: r9854 - in trunk: examples/itext/src/org/jboss/seam/example/pdf and 7 other directories.
by seam-commits@lists.jboss.org
Author: danielc.roth
Date: 2009-01-02 17:13:54 -0500 (Fri, 02 Jan 2009)
New Revision: 9854
Added:
trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java
Modified:
trunk/examples/excel/src/org/jboss/seam/excel/test/RenderTest.java
trunk/examples/itext/src/org/jboss/seam/example/pdf/FillInForms.java
trunk/examples/itext/src/org/jboss/seam/example/pdf/test/DocumentTests.java
trunk/examples/mail/src/org/jboss/seam/example/mail/test/MailTest.java
trunk/examples/openid/
trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java
trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java
trunk/src/main/org/jboss/seam/document/DocumentData.java
trunk/src/main/org/jboss/seam/document/DocumentStorePhaseListener.java
trunk/src/main/org/jboss/seam/document/DocumentStoreServlet.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java
Log:
Prep for JBSEAM-1350
Modified: trunk/examples/excel/src/org/jboss/seam/excel/test/RenderTest.java
===================================================================
--- trunk/examples/excel/src/org/jboss/seam/excel/test/RenderTest.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/examples/excel/src/org/jboss/seam/excel/test/RenderTest.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -8,6 +8,7 @@
import jxl.Workbook;
import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.document.ByteArrayDocumentData;
import org.jboss.seam.document.DocumentData;
import org.jboss.seam.excel.ExcelTest.Person;
import org.jboss.seam.faces.Renderer;
@@ -38,7 +39,7 @@
Renderer.instance().render("/simple.xhtml");
DocumentData data = (DocumentData) Contexts.getEventContext().get("testExport");
- Workbook workbook = Workbook.getWorkbook(new ByteArrayInputStream(data.getData()));
+ Workbook workbook = Workbook.getWorkbook(new ByteArrayInputStream(((ByteArrayDocumentData)data).getData()));
Sheet sheet = workbook.getSheet("Developers");
assert sheet != null;
Modified: trunk/examples/itext/src/org/jboss/seam/example/pdf/FillInForms.java
===================================================================
--- trunk/examples/itext/src/org/jboss/seam/example/pdf/FillInForms.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/examples/itext/src/org/jboss/seam/example/pdf/FillInForms.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -1,5 +1,6 @@
-package org.domain.PDF.session;
+package org.jboss.seam.example.pdf;
+
import java.util.ArrayList;
import java.util.List;
@@ -12,132 +13,156 @@
@Name("fillInForms")
@Scope(ScopeType.CONVERSATION)
-public class FillInForms {
- private String name;
- private String address;
- private String postalCode;
- private String email;
- private String[] programming;
- private String language;
- private String preferred;
- private List<String> knowledge;
- private List<SelectItem> programmingLanguages;
- private List<SelectItem> languages;
-
-
- public List<String> getKnowledge() {
- return knowledge;
- }
-
- public void setKnowledge(List<String> knowledge) {
- this.knowledge = knowledge;
- }
-
-
- public List<SelectItem> getLanguages() {
- return languages;
- }
-
- public void setLanguages(List<SelectItem> languages) {
- this.languages = languages;
- }
-
- public List<SelectItem> getProgrammingLanguages() {
- return programmingLanguages;
- }
-
- public void setProgrammingLanguages(List<SelectItem> programmingLanguages) {
- this.programmingLanguages = programmingLanguages;
- }
-
- @Create
- public void init() {
- knowledge = new ArrayList<String>();
- programmingLanguages = new ArrayList<SelectItem>();
- programmingLanguages.add(new SelectItem("JAVA", "Java"));
- programmingLanguages.add(new SelectItem("C", "C/C++"));
- programmingLanguages.add(new SelectItem("CS", "C#"));
- programmingLanguages.add(new SelectItem("VB", "VB"));
- languages = new ArrayList<SelectItem>();
- languages.add(new SelectItem("EN", "English"));
- languages.add(new SelectItem("FR", "French"));
- languages.add(new SelectItem("NL", "Dutch"));
- knowledge.add("FR");
- language = "FR";
- preferred = "FR";
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getAddress() {
- return address;
- }
-
- public void setAddress(String address) {
- this.address = address;
- }
-
- public String getPostalCode() {
- return postalCode;
- }
-
- public void setPostalCode(String postalCode) {
- this.postalCode = postalCode;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String[] getProgramming() {
- return programming;
- }
+public class FillInForms
+{
+ private String name;
+ private String address;
+ private String postalCode;
+ private String email;
+ private String[] programming;
+ private String language;
+ private String preferred;
+ private List<String> knowledge;
+ private List<SelectItem> programmingLanguages;
+ private List<SelectItem> languages;
- public void setProgramming(String[] programming) {
- this.programming = programming;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public String getPreferred() {
- return preferred;
- }
-
- public void setPreferred(String preferred) {
- this.preferred = preferred;
- }
-
- public String submit() {
- return "/form.xhtml";
- }
-
- public boolean isKnowsEnglish() {
- boolean knows = knowledge.contains("EN");
- return knows;
- }
-
- public boolean isKnowsFrench() {
- return knowledge.contains("FR");
- }
-
- public boolean isKnowsDutch() {
- return knowledge.contains("NL");
- }
-
+ public List<String> getKnowledge()
+ {
+ return knowledge;
+ }
+
+ public void setKnowledge(List<String> knowledge)
+ {
+ this.knowledge = knowledge;
+ }
+
+ public List<SelectItem> getLanguages()
+ {
+ return languages;
+ }
+
+ public void setLanguages(List<SelectItem> languages)
+ {
+ this.languages = languages;
+ }
+
+ public List<SelectItem> getProgrammingLanguages()
+ {
+ return programmingLanguages;
+ }
+
+ public void setProgrammingLanguages(List<SelectItem> programmingLanguages)
+ {
+ this.programmingLanguages = programmingLanguages;
+ }
+
+ @Create
+ public void init()
+ {
+ knowledge = new ArrayList<String>();
+ programmingLanguages = new ArrayList<SelectItem>();
+ programmingLanguages.add(new SelectItem("JAVA", "Java"));
+ programmingLanguages.add(new SelectItem("C", "C/C++"));
+ programmingLanguages.add(new SelectItem("CS", "C#"));
+ programmingLanguages.add(new SelectItem("VB", "VB"));
+ languages = new ArrayList<SelectItem>();
+ languages.add(new SelectItem("EN", "English"));
+ languages.add(new SelectItem("FR", "French"));
+ languages.add(new SelectItem("NL", "Dutch"));
+ knowledge.add("FR");
+ language = "FR";
+ preferred = "FR";
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getAddress()
+ {
+ return address;
+ }
+
+ public void setAddress(String address)
+ {
+ this.address = address;
+ }
+
+ public String getPostalCode()
+ {
+ return postalCode;
+ }
+
+ public void setPostalCode(String postalCode)
+ {
+ this.postalCode = postalCode;
+ }
+
+ public String getEmail()
+ {
+ return email;
+ }
+
+ public void setEmail(String email)
+ {
+ this.email = email;
+ }
+
+ public String[] getProgramming()
+ {
+ return programming;
+ }
+
+ public void setProgramming(String[] programming)
+ {
+ this.programming = programming;
+ }
+
+ public String getLanguage()
+ {
+ return language;
+ }
+
+ public void setLanguage(String language)
+ {
+ this.language = language;
+ }
+
+ public String getPreferred()
+ {
+ return preferred;
+ }
+
+ public void setPreferred(String preferred)
+ {
+ this.preferred = preferred;
+ }
+
+ public String submit()
+ {
+ return "/form.xhtml";
+ }
+
+ public boolean isKnowsEnglish()
+ {
+ boolean knows = knowledge.contains("EN");
+ return knows;
+ }
+
+ public boolean isKnowsFrench()
+ {
+ return knowledge.contains("FR");
+ }
+
+ public boolean isKnowsDutch()
+ {
+ return knowledge.contains("NL");
+ }
+
}
Modified: trunk/examples/itext/src/org/jboss/seam/example/pdf/test/DocumentTests.java
===================================================================
--- trunk/examples/itext/src/org/jboss/seam/example/pdf/test/DocumentTests.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/examples/itext/src/org/jboss/seam/example/pdf/test/DocumentTests.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -2,77 +2,81 @@
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Conversation;
-import org.jboss.seam.mock.SeamTest;
+import org.jboss.seam.document.ByteArrayDocumentData;
import org.jboss.seam.document.DocumentData;
import org.jboss.seam.document.DocumentStore;
+import org.jboss.seam.mock.SeamTest;
import org.jboss.seam.pdf.ui.UIDocument;
import org.testng.annotations.Test;
/**
- * This is just a placeholder until I can find a way to actually test the
- * UI components.
+ * This is just a placeholder until I can find a way to actually test the UI
+ * components.
*/
-public class DocumentTests
- extends SeamTest
-{
- @Test
- public void documentStore()
- throws Exception
- {
- String conversationId = new FacesRequest("/whyseam.xhtml") {
+public class DocumentTests extends SeamTest
+{
+ @Test
+ public void documentStore() throws Exception
+ {
+ String conversationId = new FacesRequest("/whyseam.xhtml")
+ {
-
- @Override
- protected void invokeApplication() throws Exception {
- Conversation.instance().begin();
-
- DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
- String docId = store.newId();
-
- Contexts.getSessionContext().set("docId", docId);
-
- DocumentData documentData = new DocumentData("base", UIDocument.PDF, new byte[100]);
- store.saveData(docId, documentData);
- }
-
- @Override
- protected void renderResponse() throws Exception {
- String docId = (String) getValue("#{docId}");
- assert docId != null;
-
- DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
- assert store.idIsValid(docId);
-
-
- }
- }.run();
-
- // different conversation
- new FacesRequest("/whyseam.xhtml") {
- @Override
- protected void renderResponse() throws Exception {
- String docId = (String) getValue("#{docId}");
- assert docId != null;
-
- DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
- assert !store.idIsValid(docId);
- }
- }.run();
-
- new FacesRequest("/whyseam.xhtml", conversationId) {
- @Override
- protected void renderResponse() throws Exception {
- String docId = (String) getValue("#{docId}");
- assert docId != null;
-
- DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
- assert store.idIsValid(docId);
-
- DocumentData data = store.getDocumentData(docId);
- assert data.getDocumentType().equals(UIDocument.PDF);
- assert data.getData().length == 100;
- }
- }.run();
- }
+ @Override
+ protected void invokeApplication() throws Exception
+ {
+ Conversation.instance().begin();
+ DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
+ String docId = store.newId();
+
+ Contexts.getSessionContext().set("docId", docId);
+
+ DocumentData documentData = new ByteArrayDocumentData("base", UIDocument.PDF, new byte[100]);
+ store.saveData(docId, documentData);
+ }
+
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ String docId = (String) getValue("#{docId}");
+ assert docId != null;
+
+ DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
+ assert store.idIsValid(docId);
+
+ }
+ }.run();
+
+ // different conversation
+ new FacesRequest("/whyseam.xhtml")
+ {
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ String docId = (String) getValue("#{docId}");
+ assert docId != null;
+
+ DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
+ assert !store.idIsValid(docId);
+ }
+ }.run();
+
+ new FacesRequest("/whyseam.xhtml", conversationId)
+ {
+ @Override
+ protected void renderResponse() throws Exception
+ {
+ String docId = (String) getValue("#{docId}");
+ assert docId != null;
+
+ DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
+ assert store.idIsValid(docId);
+
+ ByteArrayDocumentData data = (ByteArrayDocumentData)store.getDocumentData(docId);
+ assert data.getDocumentType().equals(UIDocument.PDF);
+ assert data.getData().length == 100;
+ }
+ }.run();
+ }
+
}
Modified: trunk/examples/mail/src/org/jboss/seam/example/mail/test/MailTest.java
===================================================================
--- trunk/examples/mail/src/org/jboss/seam/example/mail/test/MailTest.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/examples/mail/src/org/jboss/seam/example/mail/test/MailTest.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -16,6 +16,7 @@
import org.jboss.seam.mail.ui.UIAttachment;
import org.jboss.seam.mail.ui.UIMessage;
+import org.jboss.seam.document.ByteArrayDocumentData;
import org.jboss.seam.document.DocumentData;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.example.mail.Person;
@@ -220,7 +221,7 @@
UIMessage message = new UIMessage();
attachment.setParent(message);
message.setMailSession(MailSession.instance());
- DocumentData doc = new DocumentData("filename", new DocumentData.DocumentType("pdf", "application/pdf"), new byte[] {});
+ DocumentData doc = new ByteArrayDocumentData("filename", new DocumentData.DocumentType("pdf", "application/pdf"), new byte[] {});
attachment.setValue(doc);
attachment.encodeEnd(FacesContext.getCurrentInstance());
Property changes on: trunk/examples/openid
___________________________________________________________________
Name: svn:ignore
+ dist
exploded-archives
test-build
Modified: trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -18,6 +18,7 @@
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.core.Interpolator;
import org.jboss.seam.core.Manager;
+import org.jboss.seam.document.ByteArrayDocumentData;
import org.jboss.seam.document.DocumentData;
import org.jboss.seam.document.DocumentStore;
import org.jboss.seam.excel.ExcelFactory;
@@ -153,7 +154,7 @@
{
String viewId = Pages.getViewId(FacesContext.getCurrentInstance());
String baseName = UIWorkbook.baseNameForViewId(viewId);
- DocumentData documentData = new DocumentData(baseName, excelWorkbook.getDocumentType(), excelWorkbook.getBytes());
+ DocumentData documentData = new ByteArrayDocumentData(baseName, excelWorkbook.getDocumentType(), excelWorkbook.getBytes());
String id = DocumentStore.instance().newId();
String url = DocumentStore.instance().preferredUrlForContent(baseName, excelWorkbook.getDocumentType().getExtension(), id);
url = Manager.instance().encodeConversationId(url, viewId);
Modified: trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -9,6 +9,7 @@
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Manager;
+import org.jboss.seam.document.ByteArrayDocumentData;
import org.jboss.seam.document.DocumentData;
import org.jboss.seam.document.DocumentStore;
import org.jboss.seam.document.DocumentData.DocumentType;
@@ -310,7 +311,7 @@
// Create a new workbook
excelWorkbook.createWorkbook(this);
-
+
List<UILink> stylesheets = getChildrenOfType(getChildren(), UILink.class);
excelWorkbook.setStylesheets(stylesheets);
}
@@ -327,14 +328,15 @@
String viewId = Pages.getViewId(context);
String baseName = baseNameForViewId(viewId);
- DocumentData documentData = new DocumentData(baseName, type, bytes);
+ DocumentData documentData = new ByteArrayDocumentData(baseName, type, bytes);
documentData.setFilename(getFilename());
- if (getExportKey() != null) {
+ if (getExportKey() != null)
+ {
Contexts.getEventContext().set(getExportKey(), documentData);
return;
}
-
+
if (sendRedirect)
{
DocumentStore store = DocumentStore.instance();
Added: trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java
===================================================================
--- trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java (rev 0)
+++ trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -0,0 +1,27 @@
+package org.jboss.seam.document;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class ByteArrayDocumentData extends DocumentData
+{
+
+ private byte[] data;
+
+ public ByteArrayDocumentData(String baseName, DocumentType documentType, byte[] data)
+ {
+ super(baseName, documentType);
+ }
+
+ @Override
+ public void writeDataToStream(OutputStream stream) throws IOException
+ {
+ stream.write(data);
+ }
+
+ public byte[] getData()
+ {
+ return data;
+ }
+
+}
\ No newline at end of file
Modified: trunk/src/main/org/jboss/seam/document/DocumentData.java
===================================================================
--- trunk/src/main/org/jboss/seam/document/DocumentData.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/src/main/org/jboss/seam/document/DocumentData.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -1,73 +1,83 @@
package org.jboss.seam.document;
+import java.io.IOException;
+import java.io.OutputStream;
import java.io.Serializable;
-public class DocumentData
- implements Serializable
+public abstract class DocumentData implements Serializable
{
- byte[] data;
- DocumentType documentType;
- String baseName;
+ DocumentType documentType;
+ String baseName;
- String disposition = "inline";
- String fileName;
-
- public DocumentData(String baseName, DocumentType documentType, byte[] data) {
- super();
- this.data = data;
- this.documentType = documentType;
- this.baseName = baseName;
- }
+ String disposition = "inline";
+ String fileName;
- public byte[] getData() {
- return data;
- }
- public DocumentType getDocumentType() {
- return documentType;
- }
- public String getBaseName() {
- return baseName;
- }
+ public DocumentData(String baseName, DocumentType documentType)
+ {
+ super();
+ this.documentType = documentType;
+ this.baseName = baseName;
+ }
-
- public void setFilename(String fileName) {
- this.fileName = fileName;
- }
-
- public String getFileName() {
- if (fileName == null) {
- return getBaseName() + "." + getDocumentType().getExtension();
- } else {
- return fileName;
- }
- }
+ public abstract void writeDataToStream(OutputStream stream) throws IOException;
- public void setDisposition(String disposition) {
- this.disposition = disposition;
- }
+ public DocumentType getDocumentType()
+ {
+ return documentType;
+ }
- public String getDisposition() {
- return disposition;
- }
+ public String getBaseName()
+ {
+ return baseName;
+ }
- static public class DocumentType
- implements Serializable
- {
- private String mimeType;
- private String extension;
+ public void setFilename(String fileName)
+ {
+ this.fileName = fileName;
+ }
- public DocumentType(String extension, String mimeType) {
- this.extension = extension;
- this.mimeType = mimeType;
- }
+ public String getFileName()
+ {
+ if (fileName == null)
+ {
+ return getBaseName() + "." + getDocumentType().getExtension();
+ }
+ else
+ {
+ return fileName;
+ }
+ }
- public String getMimeType() {
- return mimeType;
- }
+ public void setDisposition(String disposition)
+ {
+ this.disposition = disposition;
+ }
- public String getExtension(){
- return extension;
- }
+ public String getDisposition()
+ {
+ return disposition;
+ }
- }
+ static public class DocumentType implements Serializable
+ {
+ private String mimeType;
+ private String extension;
+
+ public DocumentType(String extension, String mimeType)
+ {
+ this.extension = extension;
+ this.mimeType = mimeType;
+ }
+
+ public String getMimeType()
+ {
+ return mimeType;
+ }
+
+ public String getExtension()
+ {
+ return extension;
+ }
+
+ }
}
\ No newline at end of file
Modified: trunk/src/main/org/jboss/seam/document/DocumentStorePhaseListener.java
===================================================================
--- trunk/src/main/org/jboss/seam/document/DocumentStorePhaseListener.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/src/main/org/jboss/seam/document/DocumentStorePhaseListener.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -8,62 +8,61 @@
import javax.faces.event.PhaseListener;
import javax.servlet.http.HttpServletResponse;
-import org.jboss.seam.log.*;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
import org.jboss.seam.navigation.Pages;
import org.jboss.seam.web.Parameters;
-
-public class DocumentStorePhaseListener
- implements PhaseListener
+public class DocumentStorePhaseListener implements PhaseListener
{
- private static final long serialVersionUID = 7308251684939658978L;
+ private static final long serialVersionUID = 7308251684939658978L;
- private static final LogProvider log = Logging.getLogProvider(DocumentStorePhaseListener.class);
+ private static final LogProvider log = Logging.getLogProvider(DocumentStorePhaseListener.class);
- public PhaseId getPhaseId()
- {
- return PhaseId.RENDER_RESPONSE;
- }
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.RENDER_RESPONSE;
+ }
- public void afterPhase(PhaseEvent phaseEvent) {
- // ...
- }
+ public void afterPhase(PhaseEvent phaseEvent)
+ {
+ // ...
+ }
- public void beforePhase(PhaseEvent phaseEvent)
- {
- String rootId = Pages.getViewId( phaseEvent.getFacesContext() );
-
- Parameters params = Parameters.instance();
- String id = (String) params.convertMultiValueRequestParameter(params.getRequestParameters(), "docId", String.class);
- if (rootId.contains(DocumentStore.DOCSTORE_BASE_URL)) {
- sendContent(phaseEvent.getFacesContext(), id);
- }
- }
+ public void beforePhase(PhaseEvent phaseEvent)
+ {
+ String rootId = Pages.getViewId(phaseEvent.getFacesContext());
- public void sendContent(FacesContext context, String contentId)
- {
- try
- {
- DocumentData documentData = DocumentStore.instance().getDocumentData(contentId);
-
- if (documentData != null) {
- byte[] data = documentData.getData();
+ Parameters params = Parameters.instance();
+ String id = (String) params.convertMultiValueRequestParameter(params.getRequestParameters(), "docId", String.class);
+ if (rootId.contains(DocumentStore.DOCSTORE_BASE_URL))
+ {
+ sendContent(phaseEvent.getFacesContext(), id);
+ }
+ }
- HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
- response.setContentType( documentData.getDocumentType().getMimeType() );
+ public void sendContent(FacesContext context, String contentId)
+ {
+ try
+ {
+ DocumentData documentData = DocumentStore.instance().getDocumentData(contentId);
- response.setHeader("Content-Disposition",
- documentData.getDisposition() +
- "; filename=\"" + documentData.getFileName() + "\"");
+ if (documentData != null)
+ {
- if (data != null) {
- response.getOutputStream().write(data);
- }
- context.responseComplete();
- }
- } catch (IOException e) {
- log.error(e);
- }
- }
+ HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
+ response.setContentType(documentData.getDocumentType().getMimeType());
+ response.setHeader("Content-Disposition", documentData.getDisposition() + "; filename=\"" + documentData.getFileName() + "\"");
+
+ documentData.writeDataToStream(response.getOutputStream());
+ context.responseComplete();
+ }
+ }
+ catch (IOException e)
+ {
+ log.error(e);
+ }
+ }
+
}
Modified: trunk/src/main/org/jboss/seam/document/DocumentStoreServlet.java
===================================================================
--- trunk/src/main/org/jboss/seam/document/DocumentStoreServlet.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/src/main/org/jboss/seam/document/DocumentStoreServlet.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -10,58 +10,54 @@
import org.jboss.seam.servlet.ContextualHttpServletRequest;
import org.jboss.seam.web.Parameters;
-public class DocumentStoreServlet
- extends HttpServlet
+public class DocumentStoreServlet extends HttpServlet
{
- private static final long serialVersionUID = 5196002741557182072L;
+ private static final long serialVersionUID = 5196002741557182072L;
- @Override
- protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
- throws ServletException, IOException
- {
- new ContextualHttpServletRequest(request)
- {
- @Override
- public void process()
- throws ServletException, IOException
- {
- doWork(request, response);
- }
- }.run();
- }
-
-
- private static void doWork(HttpServletRequest request, HttpServletResponse response)
- throws IOException
- {
- Parameters params = Parameters.instance();
- String contentId = (String) params.convertMultiValueRequestParameter(params.getRequestParameters(), "docId", String.class);
-
- DocumentStore store = DocumentStore.instance();
-
- if (store.idIsValid(contentId)) {
- DocumentData documentData = store.getDocumentData(contentId);
-
- byte[] data = documentData.getData();
+ @Override
+ protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException
+ {
+ new ContextualHttpServletRequest(request)
+ {
+ @Override
+ public void process() throws ServletException, IOException
+ {
+ doWork(request, response);
+ }
+ }.run();
+ }
- response.setContentType(documentData.getDocumentType().getMimeType());
- response.setHeader("Content-Disposition",
- documentData.getDisposition() +
- "; filename=\"" + documentData.getFileName() + "\"");
+ private static void doWork(HttpServletRequest request, HttpServletResponse response) throws IOException
+ {
+ Parameters params = Parameters.instance();
+ String contentId = (String) params.convertMultiValueRequestParameter(params.getRequestParameters(), "docId", String.class);
- if (data != null) {
- response.getOutputStream().write(data);
+ DocumentStore store = DocumentStore.instance();
+
+ if (store.idIsValid(contentId))
+ {
+ DocumentData documentData = store.getDocumentData(contentId);
+
+ response.setContentType(documentData.getDocumentType().getMimeType());
+ response.setHeader("Content-Disposition", documentData.getDisposition() + "; filename=\"" + documentData.getFileName() + "\"");
+
+ documentData.writeDataToStream(response.getOutputStream());
+ }
+ else
+ {
+ String error = store.getErrorPage();
+ if (error != null)
+ {
+ if (error.startsWith("/"))
+ {
+ error = request.getContextPath() + error;
}
- } else{
- String error = store.getErrorPage();
- if (error != null) {
- if (error.startsWith("/")) {
- error = request.getContextPath() + error;
- }
- response.sendRedirect(error);
- } else {
- response.sendError(404);
- }
- }
- }
+ response.sendRedirect(error);
+ }
+ else
+ {
+ response.sendError(404);
+ }
+ }
+ }
}
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -9,10 +9,11 @@
import javax.faces.context.FacesContext;
import org.jboss.seam.core.Manager;
-import org.jboss.seam.navigation.Pages;
+import org.jboss.seam.document.ByteArrayDocumentData;
import org.jboss.seam.document.DocumentData;
import org.jboss.seam.document.DocumentStore;
import org.jboss.seam.document.DocumentData.DocumentType;
+import org.jboss.seam.navigation.Pages;
import org.jboss.seam.pdf.ITextUtils;
import com.lowagie.text.DocWriter;
@@ -275,17 +276,21 @@
protected void processHeaders()
{
- UIComponent facet = getFacet("header");
+ UIComponent facet = getFacet("header");
- if (facet == null) {
- return;
- }
+ if (facet == null)
+ {
+ return;
+ }
- try {
- encode(FacesContext.getCurrentInstance(), facet);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ try
+ {
+ encode(FacesContext.getCurrentInstance(), facet);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
}
protected String baseNameForViewId(String viewId)
@@ -320,7 +325,7 @@
String viewId = Pages.getViewId(context);
String baseName = baseNameForViewId(viewId);
- DocumentData documentData = new DocumentData(baseName, documentType, bytes);
+ DocumentData documentData = new ByteArrayDocumentData(baseName, documentType, bytes);
String dispositionValue = (String) valueBinding(context, "disposition", disposition);
if (dispositionValue != null)
{
Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java 2009-01-01 16:51:57 UTC (rev 9853)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java 2009-01-02 22:13:54 UTC (rev 9854)
@@ -11,137 +11,160 @@
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Manager;
+import org.jboss.seam.core.ResourceLoader;
+import org.jboss.seam.document.ByteArrayDocumentData;
import org.jboss.seam.document.DocumentData;
import org.jboss.seam.document.DocumentStore;
import org.jboss.seam.document.DocumentData.DocumentType;
import org.jboss.seam.log.Log;
import org.jboss.seam.log.Logging;
import org.jboss.seam.navigation.Pages;
-import org.jboss.seam.core.ResourceLoader;
import com.lowagie.text.DocumentException;
import com.lowagie.text.pdf.AcroFields;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfStamper;
-public class UIForm extends FormComponent {
- public static final String COMPONENT_FAMILY = "org.jboss.seam.pdf.UIForm";
+public class UIForm extends FormComponent
+{
+ public static final String COMPONENT_FAMILY = "org.jboss.seam.pdf.UIForm";
- private Log log = Logging.getLog(getClass());
+ private Log log = Logging.getLog(getClass());
- private String URL;
- private String filename;
- private String exportKey;
+ private String URL;
+ private String filename;
+ private String exportKey;
- PdfReader reader;
- PdfStamper stamper;
- AcroFields fields;
- ByteArrayOutputStream buffer;
+ PdfReader reader;
+ PdfStamper stamper;
+ AcroFields fields;
+ ByteArrayOutputStream buffer;
- public String getURL() {
- return (String) valueOf("URL", URL);
- }
+ public String getURL()
+ {
+ return (String) valueOf("URL", URL);
+ }
- public void setURL(String url) {
- URL = url;
- }
+ public void setURL(String url)
+ {
+ URL = url;
+ }
- @Override
- public void encodeBegin(FacesContext facesContext) throws IOException {
- log.info("Loading template #0", getURL());
- if (getURL().indexOf("://") < 0) {
- reader = new PdfReader(ResourceLoader.instance().getResourceAsStream(getURL()));
- } else {
- reader = new PdfReader(new URL(getURL()));
- }
- buffer = new ByteArrayOutputStream();
- try {
- stamper = new PdfStamper(reader, buffer);
- Contexts.getEventContext().set(STAMPER_KEY, stamper);
- } catch (DocumentException e) {
- throw new FacesException("Could not create PDF stamper", e);
- }
- fields = stamper.getAcroFields();
- Contexts.getEventContext().set(FIELDS_KEY, fields);
- }
+ @Override
+ public void encodeBegin(FacesContext facesContext) throws IOException
+ {
+ log.info("Loading template #0", getURL());
+ if (getURL().indexOf("://") < 0)
+ {
+ reader = new PdfReader(ResourceLoader.instance().getResourceAsStream(getURL()));
+ }
+ else
+ {
+ reader = new PdfReader(new URL(getURL()));
+ }
+ buffer = new ByteArrayOutputStream();
+ try
+ {
+ stamper = new PdfStamper(reader, buffer);
+ Contexts.getEventContext().set(STAMPER_KEY, stamper);
+ }
+ catch (DocumentException e)
+ {
+ throw new FacesException("Could not create PDF stamper", e);
+ }
+ fields = stamper.getAcroFields();
+ Contexts.getEventContext().set(FIELDS_KEY, fields);
+ }
- @Override
- public void encodeEnd(FacesContext facesContext) throws IOException {
- stamper.setFormFlattening(true);
- try {
- stamper.close();
- } catch (DocumentException e) {
- throw new FacesException("Could not flush PDF", e);
- }
+ @Override
+ public void encodeEnd(FacesContext facesContext) throws IOException
+ {
+ stamper.setFormFlattening(true);
+ try
+ {
+ stamper.close();
+ }
+ catch (DocumentException e)
+ {
+ throw new FacesException("Could not flush PDF", e);
+ }
- if (getExportKey() == null) {
- UIComponent parent = getParent();
- if (parent != null && (parent instanceof ValueHolder)) {
- log.debug("Storing PDF data in ValueHolder parent");
- ValueHolder valueHolder = (ValueHolder) parent;
- valueHolder.setValue(buffer.toByteArray());
- return;
- }
- }
+ if (getExportKey() == null)
+ {
+ UIComponent parent = getParent();
+ if (parent != null && (parent instanceof ValueHolder))
+ {
+ log.debug("Storing PDF data in ValueHolder parent");
+ ValueHolder valueHolder = (ValueHolder) parent;
+ valueHolder.setValue(buffer.toByteArray());
+ return;
+ }
+ }
- String viewId = Pages.getViewId(facesContext);
- String baseName = baseNameForViewId(viewId);
+ String viewId = Pages.getViewId(facesContext);
+ String baseName = baseNameForViewId(viewId);
- DocumentStore store = DocumentStore.instance();
- DocumentType documentType = new DocumentData.DocumentType("pdf",
- "application/pdf");
- DocumentData documentData = new DocumentData(baseName, documentType,
- buffer.toByteArray());
- documentData.setFilename(getFilename());
+ DocumentStore store = DocumentStore.instance();
+ DocumentType documentType = new DocumentData.DocumentType("pdf", "application/pdf");
+ DocumentData documentData = new ByteArrayDocumentData(baseName, documentType, buffer.toByteArray());
+ documentData.setFilename(getFilename());
- if (getExportKey() != null) {
- log.debug("Exporting PDF data to event key #0", getExportKey());
- Contexts.getEventContext().set(getExportKey(), documentData);
- return;
- }
+ if (getExportKey() != null)
+ {
+ log.debug("Exporting PDF data to event key #0", getExportKey());
+ Contexts.getEventContext().set(getExportKey(), documentData);
+ return;
+ }
- String id = store.newId();
- String url = store.preferredUrlForContent(baseName, documentType
- .getExtension(), id);
- url = Manager.instance().encodeConversationId(url, viewId);
- store.saveData(id, documentData);
- log.debug("Redirecting to #0 for PDF view", url);
- facesContext.getExternalContext().redirect(url);
- }
+ String id = store.newId();
+ String url = store.preferredUrlForContent(baseName, documentType.getExtension(), id);
+ url = Manager.instance().encodeConversationId(url, viewId);
+ store.saveData(id, documentData);
+ log.debug("Redirecting to #0 for PDF view", url);
+ facesContext.getExternalContext().redirect(url);
+ }
- public static String baseNameForViewId(String viewId) {
- int pos = viewId.lastIndexOf("/");
- if (pos != -1) {
- viewId = viewId.substring(pos + 1);
- }
+ public static String baseNameForViewId(String viewId)
+ {
+ int pos = viewId.lastIndexOf("/");
+ if (pos != -1)
+ {
+ viewId = viewId.substring(pos + 1);
+ }
- pos = viewId.lastIndexOf(".");
- if (pos != -1) {
- viewId = viewId.substring(0, pos);
- }
+ pos = viewId.lastIndexOf(".");
+ if (pos != -1)
+ {
+ viewId = viewId.substring(0, pos);
+ }
- return viewId;
- }
+ return viewId;
+ }
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
+ @Override
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
- public String getFilename() {
- return (String) valueOf("filename", filename);
- }
+ public String getFilename()
+ {
+ return (String) valueOf("filename", filename);
+ }
- public void setFilename(String filename) {
- this.filename = filename;
- }
+ public void setFilename(String filename)
+ {
+ this.filename = filename;
+ }
- public String getExportKey() {
- return (String) valueOf("exportKey", exportKey);
- }
+ public String getExportKey()
+ {
+ return (String) valueOf("exportKey", exportKey);
+ }
- public void setExportKey(String exportKey) {
- this.exportKey = exportKey;
- }
+ public void setExportKey(String exportKey)
+ {
+ this.exportKey = exportKey;
+ }
}
15 years, 3 months
Seam SVN: r9853 - trunk/doc/Seam_Reference_Guide/it-IT.
by seam-commits@lists.jboss.org
Author: nico.ben
Date: 2009-01-01 11:51:57 -0500 (Thu, 01 Jan 2009)
New Revision: 9853
Modified:
trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po
Log:
JBSEAM-3767: Italian translation of Seam guide
Modified: trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po
===================================================================
--- trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po 2008-12-31 15:51:03 UTC (rev 9852)
+++ trunk/doc/Seam_Reference_Guide/it-IT/Tutorial.po 2009-01-01 16:51:57 UTC (rev 9853)
@@ -6,7 +6,7 @@
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2008-12-13 17:58+0000\n"
-"PO-Revision-Date: 2008-12-30 23:41+0100\n"
+"PO-Revision-Date: 2009-01-01 17:51+0100\n"
"Last-Translator: Nicola Benaglia <nico.benaz(a)gmail.com>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
@@ -1198,7 +1198,7 @@
#: Tutorial.xml:506
#, no-c-format
msgid "If no user with that username exists, the <literal>\"/registered.xhtml\"</literal> outcome triggers a browser redirect to the <literal>registered.xhtml</literal> page. When JSF comes to render the page, it asks Seam to resolve the variable named <literal>user</literal> and uses property values of the returned <literal>User</literal> entity from Seam's session scope."
-msgstr ""
+msgstr "Se non esiste nessun utente con tale username, l'esito di <literal>\"/registered.xhtml\"</literal> causa un redirect del browser verso la pagina <literal>registered.xhtml</literal>. Quando JSF arriva a generare la pagina, chiede a Seam di risolvere la variabile chiamata <literal>user</literal> ed utilizza il valori di proprietà dell'entity <literal>User</literal> restituito dallo scope di sessione di Seam."
#. Tag: title
#: Tutorial.xml:516
@@ -1210,13 +1210,13 @@
#: Tutorial.xml:518
#, no-c-format
msgid "Clickable lists of database search results are such an important part of any online application that Seam provides special functionality on top of JSF to make it easier to query data using EJB-QL or HQL and display it as a clickable list using a JSF <literal><h:dataTable></literal>. The messages example demonstrates this functionality."
-msgstr ""
+msgstr "Le liste cliccabili dei risultati di ricerca del database sono una parte così importante di qualsiasi applicazione online che Seam fornisce una funzionalità speciale in cima a JSF per rendere più facile l'interrogazione dei dati usando EJB-QL o HQL e la mostra comelista cliccabile usando il JSF <literal><h:dataTable></literal>. I messaggi d'esempio mostrano questa funzionalità."
#. Tag: para
#: Tutorial.xml:534
#, no-c-format
msgid "The message list example has one entity bean, <literal>Message</literal>, one session bean, <literal>MessageListBean</literal> and one JSP."
-msgstr ""
+msgstr "L'esempio di lista messaggi ha un entity bean, <literal>Message</literal>, un session bean, <literal>MessageListBean</literal> ed una JSP."
#. Tag: title
#: Tutorial.xml:538
@@ -1228,7 +1228,7 @@
#: Tutorial.xml:540
#, no-c-format
msgid "The <literal>Message</literal> entity defines the title, text, date and time of a message, and a flag indicating whether the message has been read:"
-msgstr ""
+msgstr "L'entity <literal>Message</literal> definisce il titolo, iltesto, ladata e l'orario del messaggio e un flag indica se il messaggio è stato letto:"
#. Tag: title
#: Tutorial.xml:544
@@ -1378,19 +1378,19 @@
#: Tutorial.xml:553
#, no-c-format
msgid "Just like in the previous example, we have a session bean, <literal>MessageManagerBean</literal>, which defines the action listener methods for the two buttons on our form. One of the buttons selects a message from the list, and displays that message. The other button deletes a message. So far, this is not so different to the previous example."
-msgstr ""
+msgstr "Come nel precedente esempio, esiste un session bean, <literal>MessageManagerBean</literal>, che definisce i metodi di action listener per i due bottoni della form. Uno di questi seleziona un messaggio dalla lista, e mostra tale messaggio. L'altro cancella il messaggio. Finora non è molto diverso dal precedente esempio."
#. Tag: para
#: Tutorial.xml:558
#, no-c-format
msgid "But <literal>MessageManagerBean</literal> is also responsible for fetching the list of messages the first time we navigate to the message list page. There are various ways the user could navigate to the page, and not all of them are preceded by a JSF action—the user might have bookmarked the page, for example. So the job of fetching the message list takes place in a Seam <emphasis>factory method</emphasis>, instead of in an action listener method."
-msgstr ""
+msgstr "Ma <literal>MessageManagerBean</literal> è anche responsabile per il recupero della lista dei messaggi la prima volta che si naviga nella pagina della lista messaggi. Ci sono vari modi in cui l'utente può navigare nella pagina, e non tutti sono preceduti da un'azione JSF—l'utente può avere un memorizzato la pagina, per esempio. Quindi il compito di recuperare la lista messaggi avviene in un <emphasis>metodo factory</emphasis> di Seam, invece che in un metodo action listener."
#. Tag: para
#: Tutorial.xml:564
#, no-c-format
msgid "We want to cache the list of messages in memory between server requests, so we will make this a stateful session bean."
-msgstr ""
+msgstr "Si vuole memorizzare la lista dei messaggi tra le varie richieste server, e quindi questo session bean diventerà stateful."
#. Tag: title
#: Tutorial.xml:568
@@ -1484,19 +1484,19 @@
#: Tutorial.xml:583
#, no-c-format
msgid "The <literal>@DataModel</literal> annotation exposes an attibute of type <literal>java.util.List</literal> to the JSF page as an instance of <literal>javax.faces.model.DataModel</literal>. This allows us to use the list in a JSF <literal><h:dataTable></literal> with clickable links for each row. In this case, the <literal>DataModel</literal> is made available in a session context variable named <literal>messageList</literal>."
-msgstr ""
+msgstr "L'annotazione <literal>@DataModel</literal> espone alla pagina JSF un attributo di tipo <literal>java.util.List</literal> come istanza di <literal>javax.faces.model.DataModel</literal>. Questo permette di usare la lista in un <literal><h:dataTable></literal> di JSF con link cliccabili per ogni riga. In questo caso il <literal>DataModel</literal> è reso disponibile in una variabile con contesto sessione chiamata <literal>messageList</literal>."
#. Tag: para
#: Tutorial.xml:591
#, no-c-format
msgid "The <literal>@DataModelSelection</literal> annotation tells Seam to inject the <literal>List</literal> element that corresponded to the clicked link."
-msgstr ""
+msgstr "L'annotazione <literal>@DataModelSelection</literal> dice a Seam di iniettare l'elemento <literal>List</literal> che corrisponde al link cliccato."
#. Tag: para
#: Tutorial.xml:595
#, no-c-format
msgid "The <literal>@Out</literal> annotation then exposes the selected value directly to the page. So every time a row of the clickable list is selected, the <literal>Message</literal> is injected to the attribute of the stateful bean, and the subsequently <emphasis>outjected</emphasis> to the event context variable named <literal>message</literal>."
-msgstr ""
+msgstr "L'annotazione <literal>@Out</literal> espone direttamente alla pagina il valore selezionato. Ogni volta che una riga della lista viene selezionata, il <literal>Message</literal> viene iniettato nell'attributo del bean stateful, e in seguito viene fatta <emphasis>l'outjection</emphasis> nella variabile con contesto evento chiamata <literal>message</literal>."
#. Tag: para
#: Tutorial.xml:602
@@ -1596,7 +1596,7 @@
#: Tutorial.xml:660
#, no-c-format
msgid "The JSP page is a straightforward use of the JSF <literal><h:dataTable></literal> component. Again, nothing specific to Seam."
-msgstr ""
+msgstr "La pagina JSP è un semplice utilizzo del componente JSF <literal><h:dataTable></literal>. Ancora nulla di specifico di Seam."
#. Tag: title
#: Tutorial.xml:663
15 years, 3 months