/***************************************************************************
* Copyright (c) 2004 - 2008 Fabrizio Boco fabboco@users.sourceforge.net *
* *
* *
* This is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License (version 2.1) as published by the Free Software Foundation *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
/**
- $Header: /usr/local/cvslocalrepository/SeamWebAppGenerator/src/org/boco/seamwebappgen/seamGeneration/Attic/HTMLGenerator.java,v 1.1.2.30 2008/06/07 17:09:08 fab Exp $
- $Author: fab $
- $Revision: 1.1.2.30 $
- $Date: 2008/06/07 17:09:08 $
- $Log: HTMLGenerator.java,v $
- Revision 1.1.2.30 2008/06/07 17:09:08 fab
- Fix nella gestione dei menu Edit e Delete nelle popup
-
- Revision 1.1.2.29 2008/06/07 06:12:13 fab
- Fix gestione eventi ajax
-
- Revision 1.1.2.28 2008/06/06 17:04:49 fab
- Completata gestione eventi sui campi del form
-
- Revision 1.1.2.27 2008/06/06 06:56:11 fab
- Spostata generazione dei campi di tipo ListBox nella insertAttribute2Form per corretta gestione eventi e popup
-
- Revision 1.1.2.26 2008/06/05 17:16:12 fab
- Modifiche per
-
- - Ajax support on bean fields
- - disableOnCreateIf and disableOnEditIf for the relationship
- - listFormatOff added to @ShowInForm
-
- Revision 1.1.2.24 2008/06/02 13:34:30 fab
- Campi required non controllati nella delete
-
- Revision 1.1.2.23 2008/06/02 09:11:30 fab
- *** empty log message ***
-
- Revision 1.1.2.22 2008/05/29 19:32:43 fab
- Fix stili su campi con validazione
-
- Revision 1.1.2.21 2008/05/25 10:07:22 fab
- Rimossa annotazione @CRUDInSeparatePopUp
- Nuova implementation type CRUDPOPUP e relativa gestione
-
- Revision 1.1.2.20 2008/05/25 08:01:12 fab
- Fix vari nella gestione delle operazioni CRUD in popup
-
- Revision 1.1.2.19 2008/05/25 07:31:45 fab
- Fix vari nella gestione delle operazioni CRUD in popup
-
- Revision 1.1.2.18 2008/05/22 19:29:12 fab
- Implementazione 0876/C
-
- Revision 1.1.2.17 2008/05/22 05:43:14 fab
- Modificata gestione titolo delle pagine di azione sui risultati della ricerca
-
- Revision 1.1.2.16 2008/05/21 11:04:06 fab
- Order outjected dal manager
-
- Revision 1.1.2.15 2008/05/17 09:43:43 fab
- Sostituiti itemMenu con commandLink per supportare RichFaces 3.2.0.SR1
-
- Revision 1.1.2.14 2008/05/15 10:14:18 fab
- Generazione delle condizioni di ricerca - solo sui campi del bean
-
- Revision 1.1.2.13 2008/05/15 09:30:11 fab
- Gestione di azioni su tutti i bean risultato di una ricerca
-
- Revision 1.1.2.12 2008/05/12 12:56:01 fab
- Wrong List Box generation in beanInPopUp.xhtml
-
- Revision 1.1.2.11 2008/05/12 06:24:27 fab
- Fix NPE in form search generation
-
- Revision 1.1.2.10 2008/05/10 05:06:41 fab
- *** empty log message ***
-
- Revision 1.1.2.9 2008/05/10 04:59:43 fab
- Fix per corretta gestione delle operazioni CRUD in popup
-
- Revision 1.1.2.8 2008/05/07 16:36:58 fab
- Fix nella generazione dei form per CRUD in popup
-
- Revision 1.1.2.7 2008/05/05 14:29:54 fab
- Modifiche alla procedura di installazione
- Modifiche per gestione entity home
-
- Revision 1.1.2.6.2.3 2008/05/04 14:35:49 fab
- *** empty log message ***
-
- Revision 1.1.2.6.2.2 2008/05/04 13:43:55 fab
- *** empty log message ***
-
- Revision 1.1.2.6.2.1 2008/05/04 12:25:12 fab
- Semplificazione della gestione delle popup
-
- Revision 1.1.2.6 2008/04/25 08:26:15 fab
- Fix 0799/B
- Fix 0783/B
-
- Revision 1.1.2.5 2008/04/24 16:41:10 fab
- Fix 0789/B
-
- Revision 1.1.2.4 2008/04/24 11:11:52 fab
- Implementazione 0784/C
-
- Revision 1.1.2.3 2008/04/22 05:37:56 fab
- Aggiornamento indirizzo di posta
-
- Revision 1.1.2.2 2008/04/21 13:08:21 fab
- Fix 0599/C
-
- Revision 1.1.2.1 2008/04/19 13:12:39 fab
- Modifiche varie per rafactoring
-
- Revision 1.1.2.1 2008/04/19 11:18:33 fab
- Refactoring
-
- Revision 1.37.2.42 2008/04/19 10:07:03 fab
- Aggiornamento riferimenti licenza
-
- Revision 1.37.2.41 2008/04/13 13:53:45 fab
- *** empty log message ***
-
- Revision 1.37.2.40 2008/04/13 09:00:55 fab
- Implementazione 0182/C
-
- Revision 1.37.2.39 2008/04/10 18:24:35 fab
- Fix ricerca globale per attributi nella forma [relationship.]*attribute
-
- Revision 1.37.2.38 2008/04/07 20:35:42 fab
- Fix nella gestione dei campi nascosti delle pop up di tipo data
-
- Revision 1.37.2.37 2008/04/07 20:12:58 fab
- Fix generazione pop up relazioni :1
-
- Revision 1.37.2.36 2008/04/07 11:54:50 fab
- Fix nella gestione dei grouppi di attributi
-
- Revision 1.37.2.35 2008/04/05 14:27:47 fab
- Fix nella generazione dei titoli delle pop up
-
- Revision 1.37.2.34 2008/04/05 12:38:22 fab
- *** empty log message ***
-
- Revision 1.37.2.33 2008/04/02 20:59:50 fab
- *** empty log message ***
-
- Revision 1.37.2.32 2008/04/02 11:57:08 fab
- Implementazione 0663/C
-
- Revision 1.37.2.31 2008/04/01 16:02:51 fab
- Implementazione 0665/C
-
- Revision 1.37.2.30 2008/03/31 12:47:55 fab
- Modifiche per porting a RichFaces della ricerca
-
- Revision 1.37.2.29 2008/03/30 16:16:22 fab
- Fix generazione list pdf per le date
-
- Revision 1.37.2.28 2008/03/28 14:53:42 fab
- Fix local search - Compariva una scritta icon !
-
- Revision 1.37.2.27 2008-03-27 20:20:17 fab
- *** empty log message ***
-
- Revision 1.37.2.26 2008/03/27 16:47:12 fab
- Modificata generazione etichette ricerca locale
-
- Revision 1.37.2.25 2008/03/17 10:27:39 fab
- *** empty log message ***
-
- Revision 1.37.2.24 2008/03/14 07:01:33 fab
- *** empty log message ***
-
- Revision 1.37.2.23 2008/03/11 14:51:20 fab
- *** empty log message ***
-
- Revision 1.37.2.22 2008/03/10 19:34:54 fab
- *** empty log message ***
-
- Revision 1.37.2.21 2008/03/10 11:01:47 fab
- *** empty log message ***
-
- Revision 1.37.2.20 2008/03/09 18:38:54 fab
- *** empty log message ***
-
- Revision 1.37.2.19 2008/03/09 15:12:20 fab
- *** empty log message ***
-
- Revision 1.37.2.18 2008/03/07 11:01:02 fab
- *** empty log message ***
-
- Revision 1.37.2.17 2008/03/07 07:39:07 fab
- *** empty log message ***
-
- Revision 1.37.2.16 2008/03/06 20:50:45 fab
- *** empty log message ***
-
- Revision 1.37.2.15 2008/03/06 16:47:47 fab
- *** empty log message ***
-
- Revision 1.37.2.14 2008/03/06 13:38:29 fab
- *** empty log message ***
-
- Revision 1.37.2.13 2008/03/05 17:40:58 fab
- *** empty log message ***
-
- Revision 1.37.2.12 2008/03/04 13:05:48 fab
- *** empty log message ***
-
- Revision 1.37.2.11 2008/03/04 09:09:33 fab
- *** empty log message ***
-
- Revision 1.37.2.10 2008/03/04 08:45:23 fab
- *** empty log message ***
-
- Revision 1.37.2.9 2008/03/03 21:52:40 fab
- *** empty log message ***
-
- Revision 1.37.2.8 2008/02/27 21:39:18 fab
- *** empty log message ***
-
- Revision 1.37.2.7 2008/02/24 10:20:57 fab
- *** empty log message ***
-
- Revision 1.37.2.6 2008/02/23 16:45:30 fab
- *** empty log message ***
-
- Revision 1.37.2.5 2008/02/21 21:29:52 fab
- *** empty log message ***
-
- Revision 1.37.2.4 2008/02/21 21:04:05 fab
- *** empty log message ***
-
- Revision 1.37.2.3 2008/02/21 10:35:20 fab
- *** empty log message ***
-
- Revision 1.37.2.2 2008/02/20 21:31:06 fab
- *** empty log message ***
-
- Revision 1.37.2.1 2008/02/20 18:32:39 fab
- *** empty log message ***
-
- Revision 1.35.2.3 2008/02/10 18:08:07 fab
- *** empty log message ***
-
- Revision 1.35.2.2 2008/02/10 17:56:36 fab
- *** empty log message ***
-
- Revision 1.35.2.1 2008/02/07 10:42:21 fab
- *** empty log message ***
-
- Revision 1.36 2008/02/04 11:52:15 fab
- Fix per eliminare presenza di eventuale validatore custom sui campi nascosti utilizzati nelle popup
-
- Revision 1.35 2008/02/01 09:19:05 fab
- Fix per la corretta gestione delle relazioni :N implementate come ListBox in presenza di PopUp
-
- Revision 1.34 2008/02/01 08:24:18 fab
- Fix per la corretta gestione delle relazioni :N implementate come ListBox in presenza di PopUp
-
- Revision 1.33 2008/01/28 16:31:47 fab
- Implementazione 0544/C
-
- Revision 1.32 2008/01/27 18:58:51 fab
- Inserita gestione versione generatore
-
- Revision 1.31 2008/01/27 17:25:54 fab
- Modificata gestione locale per formattazione date, long e integer per supportare internazionalizzazione
-
- Revision 1.30 2008/01/22 11:20:25 fab
- Fix dimensione ListBox nella localsearch
-
- Revision 1.29 2008/01/20 15:25:22 fab
- *** empty log message ***
-
- Revision 1.28 2008/01/09 08:44:28 fab
- Fix gestione localsearch per bean con chiave a componenti multiple
-
- Revision 1.27 2008/01/08 13:43:58 fab
- Eliminazione etichette colonne liste su una sola riga
-
- Revision 1.26 2008/01/08 12:50:16 fab
- Eliminata stampa del valore null nelle list in pdf
-
- Revision 1.25 2008/01/08 11:34:18 fab
- Fix per evitare che nella stampa PDF dei bean compaia null nei campi vuoti
-
- Revision 1.24 2008/01/08 10:14:21 fab
- Fix generazione stampa PDF per relazioni implementate come PopUp
-
- Revision 1.23 2008/01/05 10:52:31 fab
- Riorganizzazione dei campi nelle local search
-
- Revision 1.22 2007/12/30 18:47:41 fab
- Fix nella generazione dei documenti PDF con campi FORMATTEDTEXTAREA
-
- Revision 1.21 2007/12/30 12:23:15 fab
- Inserimento HtmlEditor
- Fix generazione jar
-
- Revision 1.20 2007/12/28 11:12:53 fab
- Modifca per creare direttamente in una popup gli item di una relazione implementata come PopUp
-
- Revision 1.19 2007/12/23 13:20:13 fab
- Fix per la corretta gestione delle relazioni da e verso bean padre
- Fix per relazioni MASTER-DETAIL in cui nel form del DETAIL c'e' il riferimento al MASTER
-
- Revision 1.18 2007/12/21 11:07:04 fab
- Dopo merge per supporto jboss 4.2.2
-
- Revision 1.17.2.4 2007/12/21 11:01:38 bob
- Aggiunto id sui pulsanti di Selezione per le popup
-
- Revision 1.17.2.3 2007/12/14 17:39:20 fab
- *** empty log message ***
-
- Revision 1.17.2.2 2007/12/14 16:55:22 fab
- Fix gestione converter nelle pagine popup
-
- Revision 1.17.2.1 2007/12/10 10:23:30 fab
- Fix per supportare JBOSS 4.2.2.GA
-
- Revision 1.17 2007/12/06 09:36:23 fab
- Fix gestione attributi nella forma [relationships]*.Attribute nelle relazioni implementate come PopUp nel form
-
- Revision 1.16 2007/11/02 10:56:47 fab
- Aggiornamento della @ShowList
-
- Revision 1.15 2007/11/01 11:08:30 fab
- *** empty log message ***
-
- Revision 1.14 2007/10/31 07:05:47 fab
- Fix nei titoli delle colonne delle relazioni :N
-
- Revision 1.13 2007/10/30 17:19:11 fab
- Implementazione 0305/C
-
- Revision 1.12 2007/10/30 09:57:16 fab
- Implementazione 0303/C
-
- Revision 1.11 2007/10/30 09:08:20 fab
- Implementazione 0301/C
-
- Revision 1.10 2007/10/28 18:57:51 fab
- *** empty log message ***
-
- Revision 1.9 2007/10/26 10:20:50 fab
- Fix ed ottimizzazioni localSearch
-
- Revision 1.8 2007/10/25 09:54:25 fab
- Dopo merge TRINIDAD_1.2.2
-
- Revision 1.1.2.4 2007/10/24 06:51:07 fab
- Fix vari dal ramo head
-
- Revision 1.7 2007/10/05 15:41:32 bob
- Fix cella con relazioni 1:n
-
- Revision 1.6 2007/10/03 11:35:46 fab
- Implementazione 0141/C
-
- Opzione formatOff in @ShowInForm
-
- Revision 1.5 2007/10/03 08:13:23 fab
- Implementazione 0140/C
-
- Opzione formatOff in @ShowAttributeInList
-
- Revision 1.4 2007/10/02 06:23:40 fab
- Implementata 0090/C
-
- Revision 1.3 2007/10/02 06:00:51 fab
- Implementata la 0124/C anche per stampa in pdf
-
- Revision 1.2 2007/10/02 05:34:55 fab
- Implementata la 0124/C
- Aggiornata la documentazione
-
- Revision 1.1 2007/09/29 13:17:20 fab
- Nuova versione iniziale del 29/09/2007
-
- Revision 1.23.2.103 2007/09/26 08:02:38 fab
- Supporto per nuova annotazione IgnorePrintListForm e
- Supporto alla nuova opzione per @ShowList
-
- Revision 1.23.2.102 2007/09/20 14:16:26 fab
- Fix per eliminare path nel pagina risultato della ricerca
-
- Revision 1.23.2.101 2007/09/20 13:19:21 fab
- Fix per la corretta gestione di alwaysRendered
-
- Revision 1.23.2.100 2007/09/19 15:49:04 fab
- Fix generazione stampa form
-
- Revision 1.23.2.99 2007/09/19 13:37:55 fab
- Fix campi transient nella stampa
-
- Revision 1.23.2.98 2007/09/17 15:38:49 fab
- Inserita chiamata alla funzione isDetailOf per abilitare nelle liste la voce di menu relativa solo al MASTER di provenienza
-
- Revision 1.23.2.97 2007/09/13 15:40:08 fab
- Fix gestione allineamento colonne provenienti da relazioni in funzione del tipo di dato
-
- Revision 1.23.2.96 2007/09/13 15:35:59 fab
- Fix gestione allineamento colonne provenienti da relazioni in funzione del tipo di dato
-
- Revision 1.23.2.95 2007/09/13 10:41:37 bob
- Fix per label che si "espandono" quando il campo e' vuoto
-
- Revision 1.23.2.93 2007/09/10 09:17:10 fab
- Fix nella generazione del form stampabile
-
- Revision 1.23.2.92 2007/09/07 16:32:28 bob
- Rollback fix per dimensione campi dopo label...
-
- Revision 1.23.2.91 2007/09/07 11:39:03 bob
- Fix delle label che si "estendevano" quando i campi erano vuoti
- Sistemato stile dei box che raggruppano i campi
-
- Revision 1.23.2.90 2007/09/06 13:06:23 fab
- Fix gestione annotazione FormFieldsGroups
-
- Revision 1.23.2.89 2007/09/03 20:37:13 fab
- Refactoring dei comparatori in un package separato
- Ordinati i campi dei bean letti dalla classe
-
- Revision 1.23.2.88 2007/09/03 16:23:55 fab
- Nella annotazione @ShowRelationshipAttributesInForm inserite le informazioni per la visualizzazione condizionele:
-
- showOnCreateIf, showOnEditIf, ecc
-
- Revision 1.23.2.87 2007/09/03 13:35:52 fab
- Nella annotazione @ShowRelationshipAttributesInForm inserite le informazioni per la visualizzazione condizionele:
-
- showOnCreateIf, showOnEditIf, ecc
-
- Revision 1.23.2.86 2007/08/30 20:29:19 fab
- Introdotta gestione annotazione @FormFieldsGroups
-
- Revision 1.23.2.85 2007/08/29 16:39:14 fab
- Gestione degli attributi
-
- showOnEditIf
- showOnDeleteIf
- showOnCreateIf
- showOnDisplayIf
-
- per l'annotazione @Relationship
-
- Revision 1.23.2.84 2007/08/29 12:49:53 bob
- Tolte 'i', 'o' ed 'u' accentate
-
- Revision 1.23.2.83 2007/08/29 12:46:22 bob
- Tolta 'a' ed 'e' accentate
-
- Revision 1.23.2.82 2007/08/28 11:58:16 bob
- No wrap sugli header delle colonne delle tabelle
-
- Revision 1.23.2.81 2007/08/22 16:39:35 fab
- Fix nome etichette
-
- Revision 1.23.2.79 2007/08/21 17:06:57 fab
- Fix per la corretta generazione degli attributi di relazione da visualizzare nelle liste stampabili
-
- Revision 1.23.2.78 2007/08/02 14:16:16 fab
- Fix per @ShowRelationshipsAttributesInForm in ordine errato nel form
-
- Revision 1.23.2.77 2007/07/31 06:57:36 fab
- Fix per la generazione del form in pdf
-
- Revision 1.23.2.76 2007/07/25 14:26:23 fab
- Fix rendered campi Integer
-
- Revision 1.23.2.75 2007/07/25 09:16:24 fab
- *** empty log message ***
-
- Revision 1.23.2.73 2007/07/22 16:18:28 fab
- Eliminato validatore custom dalla relazioni 1:N popup
-
- Revision 1.23.2.72 2007/07/22 16:05:00 fab
- Fix vari per l'allineamento delle colonne delle tabelle e per la conversione dei tipi di dato
-
- Revision 1.23.2.71 2007/07/22 07:54:20 fab
- Fix nella generazione delle popup nel caso in cui il form del bean di partenza conteneva campi @ShowTransientInForm
-
- Revision 1.23.2.70 2007/07/20 18:41:21 fab
- Fix per SEAM 2
-
- Revision 1.23.2.69 2007/07/19 09:51:51 fab
- Modifiche per la gestione del form del bean (edit,create,delete,display) in una popup
-
- Revision 1.23.2.68 2007/07/17 21:01:18 fab
- Gestione di più file allegati nello stesso form
-
- Revision 1.23.2.67 2007/07/17 13:40:24 fab
- Fix gestione allegati in upload
-
- Revision 1.23.2.66 2007/07/14 15:08:17 fab
- Modifiche ad layout delle colonne per evitare wrapping delle icone
-
- Revision 1.23.2.65 2007/07/13 16:16:12 fab
- Inserita gestione validatorId nella @ShowInForm
-
- Revision 1.23.2.64 2007/07/10 16:12:34 fab
- Fix corretta gestione @ShowTransientInForm
-
- Revision 1.23.2.63 2007/07/07 21:01:22 fab
- Fix per gestire il referrer mancante nella chiamata delle popup da parte di ie
-
- Revision 1.23.2.62 2007/07/06 14:17:53 fab
- Pulizia commenti inutili
-
- Revision 1.23.2.61 2007/07/06 12:47:07 bob
- Spacer e stile etichetta delle tabelle nelle form
-
- Revision 1.23.2.59 2007/07/06 08:50:58 fab
- Eliminato stile xq dalle etichette
-
- Revision 1.23.2.58 2007/07/06 08:35:24 fab
- Fix generazione etichette per relazioni implementate come popup
-
- Revision 1.23.2.57 2007/07/03 06:47:38 bob
- - Aggiunta griglia nelle tabelle generate
-
- Revision 1.23.2.55 2007/06/23 11:44:04 fab
- *** empty log message ***
-
- Revision 1.23.2.54 2007/06/21 12:51:02 fab
- Sostituite i tag per le immagini di help
-
- Revision 1.23.2.53 2007/06/20 19:02:45 fab
- Modifiche layout grafico
-
- Revision 1.23.2.52 2007/06/19 17:24:26 fab
- Modifiche per interfaccia
-
- Revision 1.23.2.51 2007/06/16 12:25:10 fab
- Modifiche per supportare l'upload dei files con Trinidad - La versione esistente con Seam non funzionava
-
- Revision 1.23.2.50 2007/06/13 06:37:25 fab
- Inserita l'opzione SELECTITEMS per la PopUpEnabledActionType
-
- Revision 1.23.2.49 2007/06/12 21:21:16 fab
- Fix per i campi di sola visualizzazione
-
- Revision 1.23.2.48 2007/06/11 15:27:32 fab
- Fix vari
-
- Revision 1.23.2.47 2007/06/11 14:45:40 fab
- Fix nei campi nascosti delle popup
-
- Revision 1.23.2.46 2007/06/10 14:50:44 fab
- Fix vari
-
- Revision 1.23.2.45 2007/06/10 06:58:14 fab
- Fix su stile di campo nascosto popup
-
- Revision 1.23.2.44 2007/06/07 21:00:15 fab
- Modifiche per supportare:
-
- RelationshipImplementationType.LISTBOX_AND_FREETEXT
-
- Revision 1.23.2.43 2007/06/01 09:32:20 fab
- Nuova opzione OPTIONS anche per relazioni :1
-
- Revision 1.23.2.42 2007/06/01 06:24:59 fab
- Gestione del tipo di relazione RelationshipImplementationType.OPTIONS
-
- Revision 1.23.2.41 2007/05/30 11:43:43 fab
- Modificata la chiamata alle PopUp sostituendo a conversationId parentConversationId, altrimenti viene utlizzata la conversazione indicata
-
- Revision 1.23.2.40 2007/05/19 14:01:20 fab
- Eliminate delle righe commentate
-
- Revision 1.23.2.39 2007/05/19 09:33:29 dev
- Moltissime modifiche
-
- Revision 1.23.2.38 2007/04/30 16:06:59 dev
- Fix vari
-
- Revision 1.23.2.37 2007/04/24 09:01:24 dev
- Fix vari
-
- Revision 1.23.2.36 2007/04/22 12:32:35 dev
- Modifiche varie
- Supporto per la gestione dei file in upload/download
-
- Revision 1.23.2.35 2007/04/21 13:36:10 dev
- Modifiche varie alla generazione
- Modifiche per compatibilità con il nuovo jboss as 4.2.0.CR2
-
- Revision 1.23.2.34 2007/04/14 15:25:49 dev
- Inserito nuovamente il validatore PopUp con nuovo nome
-
- Revision 1.23.2.33 2007/04/11 13:06:03 dev
- Review sugli stili
-
- Revision 1.23.2.32 2007/04/07 11:03:12 dev
- *** empty log message ***
-
- Revision 1.23.2.31 2007/04/05 19:57:30 dev
- Supportate le condizioni onCreate, OnEdit, OnDelete, OnDisplay per la ShowInForm
-
- Revision 1.23.2.30 2007/04/02 16:05:30 dev
- Modificata tipologia listbox per localsearch di relazioni :1
- Inserita opzione seleziona
-
- Revision 1.23.2.29 2007/04/02 13:11:22 dev
- Modificata tipologia listbox per localsearch di relazioni :1
- Inserita opzione seleziona
-
- Revision 1.23.2.28 2007/04/02 12:01:24 dev
- Fix sul path delle icone per help sui campi
-
- Revision 1.23.2.27 2007/04/01 17:41:47 dev
- Fix nella generazione della list risultato della ricerca
-
- Revision 1.23.2.26 2007/03/31 18:06:45 dev
- Il riferimento ai campi del form (es operation) è stato reso relativo al form stesso
-
- Revision 1.23.2.25 2007/03/28 12:23:08 dev
- Fix per la @ShowRelationshipAttributesInForm
-
- Revision 1.23.2.24 2007/03/27 10:09:39 dev
- Modifiche per gestire liste mutiple in relazioni Master-Detail
-
- Revision 1.23.2.23 2007/03/24 17:26:00 dev
- Modifiche per generare più liste per il bean e gestione della sicurezza di ciascuna lista
-
- Revision 1.23.2.22 2007/03/24 00:42:01 dev
- Reingegnerizzazione della creazione del progetto
-
- Revision 1.23.2.21 2007/03/06 10:36:37 dev
- Fix per centrare i pulsanti della ricerca locale
-
- Revision 1.23.2.20 2007/03/06 10:03:45 dev
- Fix nella stampa del form
-
- Revision 1.23.2.19 2007/03/03 13:50:48 dev
- Fix vari
-
- Revision 1.23.2.18 2007/02/24 16:04:32 dev
- Modifiche per supportare le conditional validation
-
- Revision 1.23.2.17 2007/02/19 12:54:59 dev
- *** empty log message ***
-
- Revision 1.23.2.16 2007/02/16 18:15:05 dev
- Fix vari
-
- Revision 1.23.2.15 2007/02/13 15:23:42 dev
- Modifiche varie al layout delle pagine
-
- Revision 1.23.2.14 2007/02/13 10:45:30 dev
- Modifiche alla gestione delle ListBox
-
- Revision 1.23.2.13 2007/02/09 11:20:49 dev
- Modifiche per la gestione delle viste categorizzate
-
- Revision 1.23.2.12 2007/02/03 13:10:33 dev
- Fix Vari
-
- Revision 1.23.2.11 2007/02/02 10:57:33 dev
- Fix vari sulla generazione e l'uso delle etichette
-
- Revision 1.23.2.10 2007/02/01 21:57:53 dev
- Fix su stile
-
- Revision 1.23.2.9 2007/02/01 20:23:33 dev
- Inserita generazione stampa PDF per le review gestione degli stili
-
- Revision 1.23.2.8 2007/01/30 13:42:00 dev
- Modifica per supporto trinidad
-
- Revision 1.23.2.7 2007/01/28 11:00:44 dev
- Gestione delle date e dei checkbox con trinidad
-
- Revision 1.23.2.6 2007/01/27 17:33:30 dev
- Gestione liste di ricerca
-
- Revision 1.23.2.5 2007/01/27 10:23:07 dev
- Generazione della pagina di ricerca
-
- Revision 1.23.2.4 2007/01/26 21:50:48 dev
- Fix vari per la validazione delle PopUp
-
- Revision 1.23.2.3 2007/01/24 09:11:25 dev
- Fix per la localsearch
-
- Revision 1.23.2.2 2007/01/23 07:31:49 dev
- *** empty log message ***
-
- Revision 1.23.2.1 2007/01/20 09:11:06 dev
- Tante modifiche che non sono descrivibili
-
- Revision 1.22 2007/01/10 16:13:55 dev
- Modifica per operation injected, per isolare operation tra un bean e l'altro è diventato @beanOperation
-
- Revision 1.21 2007/01/07 16:53:26 dev
- Modifiche Dicembre 2006
-
- Revision 1.20 2007/01/07 14:35:08 dev
- Modifiche Dicembre 2006
-
- Revision 1.19 2007/01/03 10:36:53 dev
- I Bean sono nella CONVERSATION
- Spostati i BeanManager nella SESSION
- Fix per la ricerca
-
- Revision 1.18 2007/01/02 16:05:28 dev
- Fix per la gestione delle popup
-
- Revision 1.17 2006/12/28 18:32:30 dev
- Modifiche per gestione della search
-
- Revision 1.16 2006/12/23 23:05:39 dev
- Fix per supportare correttamente la localSearch nella conversazione
-
- Revision 1.15 2006/12/10 16:40:05 dev
- Reingegnerizzazione del generatore per funzionare con le conversazioni anzichè la sessione
-
- Revision 1.14 2006/12/04 16:14:42 dev
- Rinominate le funzioni
-
- MultipleSelectionListBox2Form(Bean, Relationship, boolean)
- SingleSelectionListBox2Form(Bean, Relationship, boolean)
- SingleSelectionPopUp2Form(Bean, Relationship)
- MultipleSelectionPopUp2Form(Bean, Relationship)
-
- in
-
- insertMultipleSelectionListBox2Form(Bean, Relationship, boolean)
- insertSingleSelectionListBox2Form(Bean, Relationship, boolean)
- insertSingleSelectionPopUp2Form(Bean, Relationship)
- inserttMultipleSelectionPopUp2Form(Bean, Relationship)
-
- Fix nella insertSingleSelectionListBox2Form
-
- Revision 1.13 2006/12/03 19:12:39 dev
- Fix per supportare bean ereditati
-
- Revision 1.12 2006/11/28 09:36:02 dev
- Modifica per gestione validazione relazioni PopUp required
-
- Revision 1.11 2006/11/27 21:49:23 dev
- Modifiche per supportare gli attributi nella forma
-
- [relazione]*.attributo
-
- come attributi di selezione nelle PopUp
-
- Revision 1.10 2006/11/27 21:46:38 dev
- Modifiche per supportare gli attributi nella forma
-
- [relazione]*.attributo
-
- come attributi di selezione nelle PopUp
-
- Revision 1.9 2006/11/27 20:30:27 dev
- *** empty log message ***
-
- Revision 1.8 2006/11/26 11:41:48 dev
- Fix per la gestione delle relazioni required di tipo PopUp
-
- Revision 1.7 2006/11/25 21:38:47 dev
- Inserita ricerca locale nelle PopUp
- Fix sui campi nascosti e javascript nella generazione delle PopUp
-
- Revision 1.6 2006/11/24 22:25:47 dev
- Fix vari nella generazione delle pagine di PopUp
-
- Revision 1.5 2006/11/19 11:30:09 dev
- Modifica per attributi di ricerca locale derivanti da relazioni :N
-
- Revision 1.4 2006/11/12 12:23:53 dev
- Fix per chiamare le liste delle popup con l'opzione noMasterReference
- Fix per aggiungere nel form del bean il nome della relazione in corrispondenza alle relazioni implementate come popup
-
- Revision 1.3 2006/11/01 11:07:38 dev
- Modifica per supportare dataScroller
-
- Revision 1.2 2006/10/23 12:14:44 dev
- Fix per generare correttamente gli attributi della lista quando sono nella forma
- [relationship.]*attribute
-
- Revision 1.1 2006/10/23 08:25:32 dev
- Prima versione separata dal generatore struts
-
- Revision 1.27 2006/10/23 06:37:53 dev
- Modifiche per supportare il Calendar nel Form per i campi Date
-
- Revision 1.26 2006/10/14 10:14:47 dev
- Modificata l'annotazione LocalSearchOnRelationship e modifiche conseguenti
-
- Revision 1.25 2006/10/14 06:46:43 dev
- Fix per le localSearch con attributi di relazione
-
- Revision 1.24 2006/10/08 07:28:29 dev
- Fix per includere nel form del bean tutti i beanManager correlati nelle chiamata ajax/remoting
-
- Revision 1.23 2006/10/05 14:29:30 dev
- Cleaning & Formatting
-
- Revision 1.22 2006/10/05 09:47:36 dev
- Gestione delle azioni opzionali nelle popup
-
- Revision 1.21 2006/10/05 09:20:03 dev
- Fix sul nome delle etichette application
-
- Revision 1.20 2006/10/01 15:03:16 dev
- Supporto per local search
-
- Revision 1.19 2006/10/01 14:13:13 dev
- Inizio supporto local search
-
- Revision 1.18 2006/09/28 18:35:09 dev
- Modifica per supportare il menu JSF anche nelle azioni dei singoli elementi della lista
-
- Revision 1.17 2006/09/28 17:49:21 dev
- Modifica per supportare il menu JSF
-
- Revision 1.16 2006/09/16 16:41:48 dev
- Generazione delle relazioni Master-Detail
-
- Revision 1.15 2006/09/03 15:49:16 dev
- Generazione delle stringhe di messaggi
- Fix nella lista
-
- Revision 1.14 2006/09/03 14:29:58 dev
- Modifiche per le relazioni MASTER_DETAIL
-
- Revision 1.13 2006/08/30 17:40:48 dev
- Fix nella creazione della dataTable relativa alle relazione implementate come PopUp
-
- Revision 1.12 2006/08/30 13:33:06 dev
- Completata la generazione delle PopUp con l'aggiornamento della pages.xml
-
- Revision 1.11 2006/08/29 14:04:25 dev
- Manager con PopUp relazione :1
- Fix al Manager per la gestione delle azioni sui singoli item della PopUp
-
- Revision 1.10 2006/08/28 06:45:13 dev
- Completata generazione pagina HTML PopUp
-
- Revision 1.9 2006/08/25 10:10:37 dev
- Modifiche per la gestione delle PopUp
-
- Revision 1.8 2006/07/28 19:25:34 dev
- Supporto per relazioni :n come ListBox anche nella list
-
- Revision 1.7 2006/07/27 13:12:18 dev
- Supporto per relazioni :n come ListBox
-
- Revision 1.6 2006/07/27 07:17:36 dev
- Supporto per le relazioni :1 nelle list
-
- Revision 1.5 2006/07/26 14:58:55 dev
- Gestita reuired / not-required per relazioni :1 implementate come ListBox
-
- Revision 1.4 2006/07/26 11:46:07 dev
- Gestione relazioni :1 con ListBox
-
- Revision 1.3 2006/07/13 09:55:49 bob
- Aggiunta gestione delle pop-up senza passaggio di parametri nella URL
-
- Revision 1.2 2006/07/03 13:59:18 dev
- Fix numerazione metodi per ordinamento
-
- Revision 1.1 2006/07/02 16:34:28 dev
- Generazione List
-
- Revision 1.2 2006/07/02 07:52:36 dev
- Generazione del form con
- Boolean
- Date
- String
- Long
-
- Revision 1.1 2006/06/30 20:45:58 dev
- Avvio scrittura generazione form
-
**/
package org.boco.seamwebappgen.seamGeneration;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Properties;
import java.util.Vector;
import javax.naming.NamingException;
import org.boco.seamwebappgen.annotations.AttributeImplementationType;
import org.boco.seamwebappgen.comparators.CodeChunkComparator;
import org.boco.seamwebappgen.gui.Messages;
import org.boco.seamwebappgen.info.Attribute;
import org.boco.seamwebappgen.info.Bean;
import org.boco.seamwebappgen.info.FormFieldsGroup;
import org.boco.seamwebappgen.info.InfoReader;
import org.boco.seamwebappgen.info.Relationship;
import org.boco.seamwebappgen.info.SearchAttribute;
import org.boco.seamwebappgen.info.ShowAttribute;
import org.boco.seamwebappgen.info.ShowList;
import org.boco.seamwebappgen.utils.CodeChunk;
import org.boco.seamwebappgen.utils.CodeChunkArray;
import org.boco.seamwebappgen.utils.CustomCodeType;
import org.boco.seamwebappgen.utils.Utils;
/**
* Generatore delle strutture HTML
*
* @author Fabrizio Boco
*/
public class HTMLGenerator
{
/**
* Genera la pagina di gestione del bean
*
* Se inPopUp == true viene utilizzato un template semplificato per le operazioni sul bean in una popup
* @throws Exception
*
*/
public static void generateFormPage(String sourceDir, String targetDir, Bean bean, boolean inPopUp) throws Exception
{
String template;
String sourceForm;
String targetForm;
String rows = "";
String javaScript = "";
String updatePopUpRelationships = "";
String relatedManagers = "";
String usesUpload = "";
String javascriptHtmlEditor = "";
String textAreaIds = "";
String printButton = "";
String hiddenAttributes = "";
String dynamicMenus = "";
InfoReader infoReader = new InfoReader(sourceDir);
if (!inPopUp)
{
template = "." + File.separator + "templates" + File.separator + "Seam_Form.xhtml";
sourceForm = sourceDir + ".." + File.separator + "html" + File.separator + bean.getName() + ".xhtml";
targetForm = targetDir + "html" + File.separator + bean.getName() + ".xhtml";
}
else
{
template = "." + File.separator + "templates" + File.separator + "Seam_FormInPopUp.xhtml";
sourceForm = sourceDir + ".." + File.separator + "html" + File.separator + bean.getName() + "InPopUp.xhtml";
targetForm = targetDir + "html" + File.separator + bean.getName() + "InPopUp.xhtml";
}
Vector<CodeChunk> codeChunks = new Vector<CodeChunk>();
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceForm, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceForm, CustomCodeType.JSP);
/** Predispone la lista di tutti gli attributi da inserire nel form **/
/** I campi Transient sono gestiti in questa sezione **/
for (int i = 0; i < bean.getAttributes().size(); i++)
{
Attribute attribute = bean.getAttributes().get(i);
if (!attribute.isKey() && (attribute.getImplementationType() != AttributeImplementationType.HIDEINFORM))
{
CodeChunk codeChunk = new CodeChunk(attribute.getOrderInForm());
codeChunk.addHtmlCode("\t<tr><td width=\"100%\">\r\n");
codeChunk.addHtmlCode("\t\t<rich:panel rendered=\"#{");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
if (!attribute.getOnCreateIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnCreateIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
if (!attribute.getOnEditIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnEditIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
if (!attribute.getOnDisplayIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
if (!attribute.getOnDeleteIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode("}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");
codeChunk.addHtmlCode("\t\t\t<tr>\r\n");
codeChunk.addHtmlCode("\t\t\t<td class=\"formFieldLabel\" >\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:outputLabel for=\"" + attribute.getName() + "\" value=\"#{msgs.form_" + bean.getName() + attribute.SeamLabel() + "}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
codeChunk.addHtmlCode("\t\t\t<td width=\"1%\">\r\n");
if (attribute.isRequired())
codeChunk.addHtmlCode("\t\t\t\t<h:outputText value=\"*\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" style=\"color: red; font-weight: bold;\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
if (attribute.getImplementationType() == AttributeImplementationType.TEXTAREA || attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
{
if (attribute.getType().equals("java.lang.String"))
{
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true));
codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
if (!attribute.getOnDisplayIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
if (!attribute.getOnDeleteIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode("}\" ");
if (attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
{
if (!textAreaIds.equals(""))
textAreaIds += ",";
textAreaIds += "form:" + attribute.getName() + "";
codeChunk.addHtmlCode(" escape=\"false\" ");
}
codeChunk.addHtmlCode("/>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
}
if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
{
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true));
/**
codeChunk.addHtmlCode("\t\t\t\t<h:selectOneMenu id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" styleClass=\"formField\" ");
codeChunk.addHtmlCode(" required=\"#{" + attribute.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!=\'DELETE\'}\"");
codeChunk.addHtmlCode(" rendered=\"#{");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
if (!attribute.getOnCreateIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnCreateIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
if (!attribute.getOnEditIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnEditIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode("}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<f:selectItem itemValue=\"\" itemLabel=\"#{msgs.Application_noSelectionLabel}\" />\r\n");
for (String option : attribute.getLabels())
{
codeChunk.addHtmlCode("\t\t\t\t\t<f:selectItem itemValue=\"" + option + "\" itemLabel=\"" + option + "\"/>\r\n");
}
if (!attribute.getAjaxEvent().equals(""))
{
codeChunk.addHtmlCode("\t\t\t\t\t"+addAjaxSupport(attribute.getAjaxEvent(), attribute.getIdsToRerenderOnAjaxEvent())+"\r\n");
}
codeChunk.addHtmlCode("\t\t\t\t</h:selectOneMenu>\r\n");
**/
codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
if (!attribute.getOnDisplayIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
if (!attribute.getOnDeleteIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode("}\" ");
codeChunk.addHtmlCode("/>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
if (attribute.getImplementationType() == AttributeImplementationType.TEXT)
{
if (attribute.getType().equals("java.lang.Boolean"))
{
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
if (attribute.getType().equals("java.lang.String"))
{
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
codeChunk.addHtmlCode("}\" ");
codeChunk.addHtmlCode("/>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
if (attribute.getType().equals("java.util.Date"))
{
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
codeChunk.addHtmlCode("}\" ");
codeChunk.addHtmlCode(">\r\n");
if (!attribute.isFormFormatOff())
codeChunk.addHtmlCode("\t\t\t\t\t<s:convertDateTime pattern=\"#{msgs.Application_DateFormat}\"/>\r\n");
codeChunk.addHtmlCode("\t\t\t\t</h:outputText>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
if (attribute.getType().equals("java.lang.Double"))
{
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
codeChunk.addHtmlCode("}\" ");
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t</h:outputText>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
if (attribute.getType().equals("java.lang.Long"))
{
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
codeChunk.addHtmlCode("}\" ");
codeChunk.addHtmlCode(">\r\n");
if (!attribute.isFormFormatOff())
codeChunk.addHtmlCode("\t\t\t\t<f:converter converterId=\"LongConverter\"/>\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t</h:outputText>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
if (attribute.getType().equals("java.lang.Integer"))
{
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:outputText id=\"" + attribute.getName() + "Display\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" rendered=\"#{");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode(Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
codeChunk.addHtmlCode("}\" ");
codeChunk.addHtmlCode(">\r\n");
if (!attribute.isFormFormatOff())
codeChunk.addHtmlCode("\t\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t</h:outputText>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
if (attribute.getType().contains("UploadedFile") || attribute.getType().contains("org.boco.seamUtility.upload.UploadedFile"))
{
/**
* Gestione degli upload / download dal form
*/
usesUpload = "enctype=\"multipart/form-data\"";
if (bean.getRelationship(Utils.makeGet(bean.getName() + "Upload")) == null)
{
// Piu' allegati
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:dataTable var=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Uploads}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:column>\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<h:commandButton action=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.downloadFile(facesContext)}\" image=\"img/download.png\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null) and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm!=null) and ((" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'))}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.fileName}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm!=null}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<h:outputLabel for=\"delete" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"Rimuovi\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<h:selectBooleanCheckbox for=\"delete" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.checkDelete}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<h:outputLabel for=\"update" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"Sostituisci\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<h:selectBooleanCheckbox for=\"update" + Utils.makeFirstLetterLowerCase(attribute.getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + Utils.makeFirstLetterLowerCase(attribute.getName()) + "Fm.checkUpdate}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t</h:column>\r\n");
codeChunk.addHtmlCode("\t\t\t\t</h:dataTable>\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
else
{
// Un solo allegato
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true) + "\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:commandButton action=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm.downloadFile(facesContext)}\" image=\"img/download.png\" rendered=\"#{");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null) and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm!=null) and ((" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
if (!attribute.getOnDisplayIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
if (!attribute.getOnDeleteIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
codeChunk.addHtmlCode("))");
codeChunk.addHtmlCode("}\" ");
codeChunk.addHtmlCode("/>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm.fileName}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm!=null}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:outputLabel for=\"delete" + attribute.getName() + "\" value=\"Rimuovere\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:selectBooleanCheckbox for=\"delete" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload." + attribute.getName() + "Fm.checkDelete}\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(bean.getName()) + "Upload!=null and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
}
}
/** Campi di sola visualizzazione * */
if (attribute.getImplementationType() == AttributeImplementationType.READONLY)
{
if (attribute.getType().equals("java.lang.String"))
{
codeChunk.addHtmlCode("\t<td>\r\n");
codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" />\r\n");
codeChunk.addHtmlCode("\t</td>\r\n");
}
if (attribute.getType().equals("java.util.Date"))
{
codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");
codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
}
if (attribute.getType().equals("java.lang.Integer"))
{
codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");
codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
}
if (attribute.getType().equals("java.lang.Long"))
{
codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");
codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
}
if (attribute.getType().equals("java.lang.Double"))
{
codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");
codeChunk.addHtmlCode("\t\t<tr:outputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + attribute.SeamField() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
codeChunk.addHtmlCode("\t\t</tr:outputText>\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
}
}
if (attribute.isHelp())
{
codeChunk.addHtmlCode("\t\t\t<td width=\"1%\"><h:graphicImage styleClass=\"imageLink\" url=\"img/info.gif\" onclick=\"help('help/form_" + bean.getName() + "_" + attribute.getName() + ".html');\" /></td>\r\n");
}
else
{
codeChunk.addHtmlCode("\t\t\t<td width=\"1%\"></td>\r\n");
}
codeChunk.addHtmlCode("\t\t\t</tr>\r\n");
codeChunk.addHtmlCode("\t\t\t</table>\r\n");
codeChunk.addHtmlCode("\t\t</rich:panel>\r\n");
codeChunk.addHtmlCode("\t</td></tr>\r\n");
codeChunks.add(codeChunk);
}
}
// Inserisce gli attributi provenienti da relazioni che debbono essere
// solo visualizzati
for (int i = 0; i < bean.getShowInFormAttributes().size(); i++)
{
ShowAttribute attribute = bean.getShowInFormAttributes().get(i);
CodeChunk codeChunk = new CodeChunk(attribute.getOrderInForm());
if (attribute.getRelationship() != null && attribute.getRelationship().isToMany())
{
codeChunk.addHtmlCode("\r\n@ShowRelationshipAttributesInForm - Relazione :N non supportata - " + attribute.getRelationship().getName() + "\r\n");
}
else
{
codeChunk.addHtmlCode("\r\n\t<tr><td width=\"100%\">\r\n");
if (!attribute.getOnCreateIf().equals("") || !attribute.getOnEditIf().equals("") || !attribute.getOnDisplayIf().equals("") || !attribute.getOnDeleteIf().equals(""))
{
codeChunk.addHtmlCode("\t\t<rich:panel width=\"100%\" rendered=\"#{");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
if (!attribute.getOnCreateIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnCreateIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
if (!attribute.getOnEditIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnEditIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
if (!attribute.getOnDisplayIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDisplayIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode(" or ");
codeChunk.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
if (!attribute.getOnDeleteIf().equals(""))
codeChunk.addHtmlCode(" and " + attribute.getOnDeleteIf());
codeChunk.addHtmlCode(")");
codeChunk.addHtmlCode("}\" >\r\n");
}
else
{
codeChunk.addHtmlCode("\t<rich:panel>\r\n");
}
codeChunk.addHtmlCode("\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");
codeChunk.addHtmlCode("\t\t<tr>\r\n");
codeChunk.addHtmlCode("\t\t<td class=\"formFieldLabel\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<h:outputLabel value=\"#{msgs.form_" + bean.getName() + "_" + attribute.getQualifiedName().replace(".", "_") + "}\" />\r\n");
codeChunk.addHtmlCode("\t\t</td>\r\n");
codeChunk.addHtmlCode("\t\t<td width=\"1%\"></td>\r\n");
codeChunk.addHtmlCode("\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getQualifiedName() + "}\" />\r\n");
codeChunk.addHtmlCode("\t\t</td>\r\n");
codeChunk.addHtmlCode("\t\t</tr>\r\n");
codeChunk.addHtmlCode("\t\t</table>\r\n");
codeChunk.addHtmlCode("\t\t</rich:panel>\r\n");
codeChunk.addHtmlCode("\t</td></tr>\r\n");
}
codeChunks.add(codeChunk);
}
// Inserisce gli attributi provenienti da relazioni
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship rel = bean.getRelationships().get(i);
if (rel.isUsed() && !rel.isMasterDetail())
{
CodeChunk codeChunk = null;
//if ( infoReader.BeanCrudInPopUp(rel.getToBeanName()) )
if (!rel.isListBox() && rel.isCRUD())
{
dynamicMenus += "<a4j:region>\r\n";
dynamicMenus += "<rich:contextMenu attached=\"false\" id=\"menu" + rel.getName() + "\" submitMode=\"ajax\" >\r\n";
dynamicMenus += "\t<rich:menuItem ajaxSingle=\"true\" value=\"#{msgs.list_" + rel.getToBeanName() + "_display}\" actionListener=\"#{" + rel.getToBeanName() + "Manager.popupMenuSelectItem}\" requestDelay=\"0\" oncomplete=\"openCrudPopUp_" + rel.getName() + "('Display');\">\r\n";
dynamicMenus += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
dynamicMenus += "\t</rich:menuItem>\r\n\r\n";
if (rel.getPopUpEdit())
{
dynamicMenus += "\t<rich:menuItem ajaxSingle=\"true\" value=\"#{msgs.list_" + rel.getToBeanName() + "_edit}\" actionListener=\"#{" + rel.getToBeanName() + "Manager.popupMenuSelectItem}\" requestDelay=\"0\" oncomplete=\"openCrudPopUp_" + rel.getName() + "('Edit');\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT')}\" >\r\n";
dynamicMenus += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
dynamicMenus += "\t</rich:menuItem>\r\n\r\n";
}
if (rel.getPopUpDelete())
{
dynamicMenus += "\t<rich:menuItem ajaxSingle=\"true\" value=\"#{msgs.list_" + rel.getToBeanName() + "_delete}\" actionListener=\"#{" + rel.getToBeanName() + "Manager.popupMenuSelectItem}\" requestDelay=\"0\" oncomplete=\"openCrudPopUp_" + rel.getName() + "('Delete');\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT')}\" >\r\n";
dynamicMenus += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
dynamicMenus += "\t</rich:menuItem>\r\n\r\n";
}
dynamicMenus += "</rich:contextMenu>\r\n";
dynamicMenus += "</a4j:region>\r\n";
}
if (!rel.isToMany())
{
// Relazione :1
if (rel.isListBox())
{
// Relazione :1 implementata come ListBox
codeChunk = insertSingleSelectionListBox2Form(sourceDir, bean, rel, true, false);
}
else
{
// Relazione :1 implementata come PopUp
codeChunk = insertSingleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
if (rel.isRequired())
updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
else
updatePopUpRelationships += "";
}
}
else
{
// Relazione :N
if (rel.isListBox())
{
// Relazione :N implementata come ListBox
codeChunk = insertMultipleSelectionListBox2Form(bean, rel, true, false);
}
else
{
// Relazione :N implementata come PopUp
codeChunk = insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
if (rel.isRequired())
updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
else
updatePopUpRelationships += "";
}
}
codeChunk.setOrder(rel.getOrderInForm());
codeChunks.add(codeChunk);
}
/** Relazioni master-detail in cui nel detail viene inserito anche una popup per la gestione del master **/
if (rel.isUsed() && rel.isMasterDetail() && rel.getOrderInForm() != 0)
{
CodeChunk codeChunk = null;
if (!rel.isToMany())
{
// Relazione :1 implementata come PopUp
codeChunk = insertSingleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
if (rel.isRequired())
updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
else
updatePopUpRelationships += "";
}
else
{
// Relazione :N implementata come PopUp
codeChunk = insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp);
if (rel.isRequired())
updatePopUpRelationships += "\tupdatePopUpRelationships(\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\");\r\n";
else
updatePopUpRelationships += "";
}
codeChunk.setOrder(rel.getOrderInForm());
codeChunks.add(codeChunk);
}
}
/** Predispone i Manager necessari per le chiamate remoting * */
relatedManagers += bean.getName() + "Manager";
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship rel = bean.getRelationships().get(i);
if (rel.isUsed())
{
relatedManagers += "&" + rel.getToBeanName() + "Manager";
}
}
/** Ordinamento dei chunck **/
CodeChunk chunks[] = codeChunks.toArray(new CodeChunk[0]);
Arrays.sort(chunks, new CodeChunkComparator());
// for (int i = 0; i < chunks.length; i++)
// {
// javaScript += chunks[i].getJavascriptCode();
// rows += chunks[i].getHtmlCode();
// }
Vector<CodeChunk> chunkVector = new Vector<CodeChunk>(java.util.Arrays.asList(chunks));
/** Generazione dei grouppi di attributi **/
for (int i = 0; i < bean.getFormFieldsGroups().size(); i++)
{
FormFieldsGroup group = bean.getFormFieldsGroups().get(i);
CodeChunk start = new CodeChunk(group.getFromFieldOrder());
start.addHtmlCode("\r\n\r\n<!-- START GROUP: " + group.getTitle() + " -->\r\n");
start.addHtmlCode("<rich:panel header=\"" + group.getTitle() + "\" rendered=\"#{");
start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
if (!group.getShowOnCreateIf().equals(""))
start.addHtmlCode(" and " + group.getShowOnCreateIf());
start.addHtmlCode(")");
start.addHtmlCode(" or ");
start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
if (!group.getShowOnEditIf().equals(""))
start.addHtmlCode(" and " + group.getShowOnEditIf());
start.addHtmlCode(")");
start.addHtmlCode(" or ");
start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
if (!group.getShowOnDisplayIf().equals(""))
start.addHtmlCode(" and " + group.getShowOnDisplayIf());
start.addHtmlCode(")");
start.addHtmlCode(" or ");
start.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
if (!group.getShowOnDeleteIf().equals(""))
start.addHtmlCode(" and " + group.getShowOnDeleteIf());
start.addHtmlCode(")");
start.addHtmlCode("}\" >\r\n\r\n");
start.addHtmlCode("<table width=\"100%\">\r\n");
int idx = getChunkIndex(chunkVector, start);
chunkVector.add(idx, start);
CodeChunk end = new CodeChunk(group.getToFieldOrder());
end.addHtmlCode("</table>\r\n");
end.addHtmlCode("\r\n\r\n</rich:panel>\r\n");
//end.addHtmlCode("<tr:spacer height=\"25\" />\r\n");
end.addHtmlCode("<!-- END GROUP: " + group.getTitle() + " -->\r\n\r\n");
idx = getChunkIndex(chunkVector, end);
chunkVector.add(idx + 1, end);
}
/** Finalmente scrive i chunk nel tag che viene sostituito nel template **/
for (int i = 0; i < chunkVector.size(); i++)
{
javaScript += chunkVector.get(i).getJavascriptCode();
rows += chunkVector.get(i).getHtmlCode();
}
/** Gestione dei campi FORMATTEDTEXTAREA **/
if (!textAreaIds.equals(""))
{
String HtmlEditorJavascriptTemplate = "." + File.separator + "templates" + File.separator + "HtmlEditorJavascript.js";
HashMap<String, String> tags = new HashMap<String, String>();
tags.put("@TextAreaIds", textAreaIds);
javascriptHtmlEditor = Utils.SeamReplaceTag2String(tags, null, null, HtmlEditorJavascriptTemplate);
}
if (bean.getPrintMenuConditionInForm().equals(""))
printButton = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/" + bean.getName() + "Print.seam\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='CREATE'}\" style=\"text-decoration: none; color: black\" />";
else
printButton = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/" + bean.getName() + "Print.seam\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='CREATE' and " + bean.getPrintMenuConditionInForm() + "}\" style=\"text-decoration: none; color: black\" />";
/** Gestione campi nascosti per CRUDInSeparatePopup **/
if (inPopUp)
{
Vector<Relationship> relationships2ThisBean = infoReader.getAllRelationship2ThisBean(bean.getName());
for (int r = 0; r < relationships2ThisBean.size(); r++)
{
Relationship rel = relationships2ThisBean.get(r);
Bean fromBean = infoReader.getBean(rel.getFromBeanName());
String tmp = generatePopUpJavascriptFunctionsInPopup(fromBean).replace("startup", "loadHiddenFields").replace("\tdocument.forms[\"form\"].elements[\"form:", "\tdocument.forms[\"form\"].elements[\"form:" + rel.getFromBeanName());
// tmp += "\r\n"+generatePopUpJavascriptFunctionsInPopup(fromBean).replace("startup", "loadHiddenFields");
if (javaScript.contains("loadHiddenFields"))
{
tmp = tmp.replace("function loadHiddenFields()", "");
tmp = tmp.replace("{", "");
javaScript = javaScript.replace("}", "\r\n" + tmp);
}
else
{
javaScript += tmp;
}
for (int i = 0; i < fromBean.getAttributes().size(); i++)
{
Attribute attr = fromBean.getAttributes().get(i);
if (!attr.isKey() && (attr.getImplementationType() != AttributeImplementationType.HIDEINFORM) && (attr.getImplementationType() != AttributeImplementationType.READONLY))
{
String tmp1 = insertAttribute2Form(attr, fromBean.getName(), false).replace("id=\"", "id=\"" + rel.getFromBeanName()) + "\r\n";
if (!hiddenAttributes.contains(tmp1))
hiddenAttributes += tmp1;
}
}
for (int i = 0; i < fromBean.getRelationships().size(); i++)
{
Relationship relationship = fromBean.getRelationships().get(i);
if (relationship.isUsed() && relationship.isListBox())
{
if (relationship.isToMany())
{
String tmp1 = insertMultipleSelectionListBox2Form(fromBean, relationship, false, false).getHtmlCode().replace("id=\"", "id=\"" + rel.getFromBeanName());
tmp1 = tmp1.replace(fromBean.getName() + "Manager.getCallingBeanName()", bean.getName() + "Manager.getCallingBeanName()");
if (!hiddenAttributes.contains(tmp1))
hiddenAttributes += tmp1;
}
else
{
String tmp1 = insertSingleSelectionListBox2Form(sourceDir, fromBean, relationship, false, false).getHtmlCode().replace("id=\"", "id=\"" + rel.getFromBeanName());
tmp1 = tmp1.replace(fromBean.getName() + "Manager.getCallingBeanName()", bean.getName() + "Manager.getCallingBeanName()");
if (!hiddenAttributes.contains(tmp1))
hiddenAttributes += tmp1;
}
}
}
}
}
HashMap<String, String> tags = new HashMap<String, String>();
tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));
tags.put("@PrintButton", printButton);
tags.put("@UpdatePopUpRelationships", updatePopUpRelationships);
tags.put("@Javascript", javaScript);
tags.put("@HtmlEditor", javascriptHtmlEditor);
tags.put("@RelatedManagers", relatedManagers);
tags.put("@DynamicMenus", dynamicMenus);
tags.put("@Bean", bean.getName());
tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
tags.put("@UsesUpload", usesUpload);
tags.put("@Rows", rows);
tags.put("@HiddenAttributes", hiddenAttributes);
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetForm);
}
/**
* Restituisce il codice da inserire in una pagina xthml relativo ad un
* attributo di un bean
*/
private static String insertAttribute2Form(Attribute attribute, String beanName, boolean visible)
{
return insertAttribute2Form(attribute, beanName, visible, false);
}
/**
* Restituisce il codice da inserire in una pagina xthml relativo ad un
* attributo di un bean
*/
private static String insertAttribute2Form(Attribute attribute, String beanName, boolean visible, boolean alwaysRendered)
{
String ret = "";
if (attribute.getType().equals("java.lang.Boolean"))
{
ret += "<h:selectBooleanCheckbox id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" ";
if (visible)
{
ret += " disabled=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(beanName) + "Operation=='DELETE'}\" >";
}
else
{
ret += " style=\"display:none;\" >";
}
if (!attribute.getValidatorId().equals(""))
{
ret += "\t\t\t\t\t<f:validator validatorId=\"" + attribute.getValidatorId() + "\" />\r\n";
}
if (!attribute.getAjaxEvent().equals(""))
ret += "\t\t\t\t\t" + addAjaxSupport(attribute.getAjaxEvent(), attribute.getIdsToRerenderOnAjaxEvent()) + "\r\n";
ret += "\t\t\t\t</h:selectBooleanCheckbox>";
return ret;
}
if (attribute.getType().equals("java.lang.String"))
{
if (attribute.getImplementationType() == AttributeImplementationType.TEXT)
ret += "<h:inputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" ";
if (attribute.getImplementationType() == AttributeImplementationType.TEXTAREA || attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
ret += "<h:inputTextarea columns=\"" + attribute.getColumns() + "\" rows=\"" + attribute.getRows() + "\" id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" ";
if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
{
ret += "<h:selectOneMenu id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + attribute.getName() + "}\" ";
}
if (visible)
{
ret += " required=\"#{" + attribute.isRequired() + " and " + Utils.makeFirstLetterLowerCase(beanName) + "Operation!='DELETE'}\" ";
if (!alwaysRendered)
{
ret += " rendered=\"#{";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='CREATE'";
ret += " or ";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='EDIT'";
ret += "}\" ";
}
ret += " styleClass=\"formField\" >\r\n";
}
else
ret += " style=\"display:none;\" >\r\n";
if (!attribute.getValidatorId().equals(""))
{
ret += "\t\t\t\t\t<f:validator validatorId=\"" + attribute.getValidatorId() + "\" />\r\n";
}
if (!attribute.getAjaxEvent().equals("") && visible)
ret += "\t\t\t\t\t" + addAjaxSupport(attribute.getAjaxEvent(), attribute.getIdsToRerenderOnAjaxEvent()) + "\r\n";
if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
{
ret += "\t\t\t\t\t<f:selectItem itemValue=\"\" itemLabel=\"#{msgs.Application_noSelectionLabel}\" />\r\n";
for (String option : attribute.getLabels())
{
ret += "\t\t\t\t\t<f:selectItem itemValue=\"" + option + "\" itemLabel=\"" + option + "\"/>\r\n";
}
}
if (attribute.getImplementationType() == AttributeImplementationType.TEXT)
ret += "\t\t\t\t</h:inputText>\r\n";
if (attribute.getImplementationType() == AttributeImplementationType.TEXTAREA || attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
ret += "\t\t\t\t</h:inputTextarea>\r\n";
if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
ret += "\t\t\t\t</h:selectOneMenu>\r\n";
return ret;
}
if (attribute.getType().equals("java.util.Date"))
{
if (visible)
{
ret += "\t\t<h:inputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" required=\"#{" + attribute.isRequired() + " and " + Utils.makeFirstLetterLowerCase(beanName) + "Operation!='DELETE'}\" ";
if (!alwaysRendered)
{
ret += " rendered=\"#{";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='CREATE'";
ret += " or ";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='EDIT'";
ret += "}\" ";
}
ret += " styleClass=\"formField\">\r\n";
if (!attribute.getValidatorId().equals(""))
{
ret += ">\r\n";
ret += "\t\t\t<f:validator validatorId=\"" + attribute.getValidatorId() + "\" />\r\n";
ret += "\t\t\t\t\t" + addAjaxSupport(attribute.getAjaxEvent(), attribute.getIdsToRerenderOnAjaxEvent()) + "\r\n";
}
if (!attribute.isFormFormatOff())
{
ret += "\t\t\t\t\t<s:convertDateTime pattern=\"#{msgs.Application_DateFormat}\"/>\r\n";
}
ret += "\t\t\t\t</h:inputText>\r\n";
ret += "\t\t\t\t<s:selectDate for=\"" + attribute.getName() + "\" dateFormat=\"#{msgs.Application_DateFormat}\" rendered=\"#{";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='CREATE'";
ret += " or ";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='EDIT'";
ret += "}\" ";
ret += " >\r\n";
ret += "\t\t\t\t\t<img src=\"img/datepicker.gif\"/>\r\n";
ret += "\t\t\t\t</s:selectDate>";
}
else
{
ret += "\t\t\t\t\t<h:inputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" ";
ret += " style=\"display:none;\"";
ret += " >\r\n";
ret += "\t\t\t\t\t\t<f:converter converterId=\"DateDummyConverter\" />\r\n";
ret += "\t\t\t\t\t</h:inputText>\r\n";
}
return ret;
}
if (attribute.getType().equals("java.lang.Double"))
{
ret += "<h:inputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" ";
if (visible)
{
if (!alwaysRendered)
{
ret += " required=\"#{" + attribute.isRequired() + " and " + Utils.makeFirstLetterLowerCase(beanName) + "Operation!='DELETE'}\" ";
ret += " rendered=\"#{";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='CREATE'";
ret += " or ";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='EDIT'";
ret += "}\" ";
}
}
else
ret += " style=\"display:none;\"";
ret += " styleClass=\"formField\" >\r\n";
if (!attribute.getValidatorId().equals(""))
{
ret += " styleClass=\"formField\" >\r\n";
ret += "\t\t\t<f:validator validatorId=\"" + attribute.getValidatorId() + "\" />\r\n";
}
if (!attribute.isFormFormatOff())
{
if (visible)
{
ret += "\t\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n";
ret += "\t\t\t\t\t" + addAjaxSupport(attribute.getAjaxEvent(), attribute.getIdsToRerenderOnAjaxEvent(), attribute.getName()) + "\r\n";
}
else
ret += "\t\t\t\t\t<f:converter converterId=\"DoubleDummyConverter\" />\r\n";
}
ret += "\t\t\t\t</h:inputText>";
return ret;
}
if (attribute.getType().equals("java.lang.Long"))
{
ret += "<h:inputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" ";
if (visible)
{
ret += " required=\"#{" + attribute.isRequired() + " and " + Utils.makeFirstLetterLowerCase(beanName) + "Operation!='DELETE'}\" ";
if (!alwaysRendered)
{
ret += " rendered=\"#{";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='CREATE'";
ret += " or ";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='EDIT'";
ret += "}\" ";
}
}
else
ret += " style=\"display:none;\"";
ret += " styleClass=\"formField\" >\r\n";
if (!attribute.getValidatorId().equals(""))
{
ret += ">\r\n";
ret += "\t\t\t<f:validator validatorId=\"" + attribute.getValidatorId() + "\" />\r\n";
}
if (!attribute.isFormFormatOff())
{
if (visible)
{
ret += "\t\t\t\t\t<f:converter converterId=\"LongConverter\"/>\r\n";
//ret += "\t\t\t\t\t<a4j:support event=\"onchange\" reRender=\"" + attribute.getName() + "\" limitToList=\"true\" ajaxSingle=\"true\" />\r\n";
ret += "\t\t\t\t\t" + addAjaxSupport(attribute.getAjaxEvent(), attribute.getIdsToRerenderOnAjaxEvent(), attribute.getName()) + "\r\n";
}
else
ret += "\t\t\t\t\t<f:converter converterId=\"LongDummyConverter\"/>\r\n";
}
ret += "\t\t\t\t\t</h:inputText>\r\n";
return ret;
}
if (attribute.getType().equals("java.lang.Integer"))
{
ret += "<h:inputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" ";
if (visible)
{
ret += " required=\"#{" + attribute.isRequired() + " and " + Utils.makeFirstLetterLowerCase(beanName) + "Operation!='DELETE'}\" ";
if (!alwaysRendered)
{
ret += " rendered=\"#{";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='CREATE'";
ret += " or ";
ret += Utils.makeFirstLetterLowerCase(beanName) + "Operation=='EDIT'";
ret += "}\" ";
}
}
else
ret += " style=\"display:none;\"";
ret += " styleClass=\"formField\" >\r\n";
if (!attribute.getValidatorId().equals(""))
{
ret += ">\r\n";
ret += "\t\t\t<f:validator validatorId=\"" + attribute.getValidatorId() + "\" />\r\n";
}
if (!attribute.isFormFormatOff())
{
if (visible)
{
ret += "\t\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n";
//ret += "\t\t\t\t\t<a4j:support event=\"onchange\" reRender=\"" + attribute.getName() + "\" limitToList=\"true\" ajaxSingle=\"true\" />\r\n";
ret += "\t\t\t\t\t" + addAjaxSupport(attribute.getAjaxEvent(), attribute.getIdsToRerenderOnAjaxEvent(), attribute.getName()) + "\r\n";
}
else
ret += "\t\t\t\t\t<f:converter converterId=\"IntegerDummyConverter\" />\r\n";
}
ret += "\t\t\t\t</h:inputText>";
return ret;
}
if (attribute.getType().contains("UploadedFile") || attribute.getType().contains("org.apache.myfaces.trinidad.model.UploadedFile"))
{
if (visible)
{
// ret += "<tr:inputFile id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + attribute.getName() + "}\" ";
ret += "<s:fileUpload data=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + attribute.getName() + ".inputStream}\" contentType=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + attribute.getName() + ".contentType}\" fileName=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + attribute.getName() + ".filename}\" fileSize=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + attribute.getName() + ".length}\" ";
ret += " required=\"#{" + attribute.isRequired() + " and " + Utils.makeFirstLetterLowerCase(beanName) + "Operation!='DELETE'}\" ";
ret += "rendered=\"#{(" + Utils.makeFirstLetterLowerCase(beanName) + "Operation=='CREATE'";
if (!attribute.getOnCreateIf().equals(""))
ret += " and " + attribute.getOnCreateIf();
ret += ")";
ret += " or ";
ret += "(" + Utils.makeFirstLetterLowerCase(beanName) + "Operation=='EDIT'";
if (!attribute.getOnEditIf().equals(""))
ret += " and " + attribute.getOnEditIf();
ret += ")";
ret += "}\" ";
ret += " styleClass=\"formUploadField\" />\r\n";
}
else
{
ret += "<h:inputText id=\"" + attribute.getName() + "\" value=\"\" style=\"display:none;\" />";
}
return ret;
}
return "**** TIPO NON SUPPORTATO *****";
}
// private static CodeChunk insertSingleSelectionListBox2Form(Bean bean, Relationship rel, boolean visible)
// {
// return insertSingleSelectionListBox2Form(bean, rel, visible, false);
// }
/**
* Genera un list box a selezione singola
*/
private static CodeChunk insertSingleSelectionListBox2Form(String sourceDir, Bean bean, Relationship rel, boolean visible, boolean alwaysRendered)
{
CodeChunk ret = new CodeChunk(0);
String disabledCondition = "";
if (!visible)
{
if (rel.isOptions())
ret.addHtmlCode("\t\t<tr:selectOneRadio id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" style=\"display:none;\" ");
else
ret.addHtmlCode("\t\t<h:selectOneMenu id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" style=\"display:none;\" ");
if (!alwaysRendered)
{
ret.addHtmlCode(" rendered=\"#{" + bean.getName() + "Manager.getCallingBeanName().contains('" + bean.getName() + "')}\" ");
}
ret.addHtmlCode(" >\r\n");
if (rel.isOptions() && !rel.isRequired())
ret.addHtmlCode("\t\t\t<f:selectItem itemLabel=\"Nessuno\"/>\r\n");
ret.addHtmlCode("\t\t\t<s:selectItems value=\"#{" + rel.getToBeanName() + "Manager.getSelectionItems(true," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + rel.getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" ");
ret.addHtmlCode("label=\"");
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
if (i > 0)
ret.addHtmlCode(" - ");
ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
}
ret.addHtmlCode("\"");
ret.addHtmlCode(" noSelectionLabel=\"Selezionare...\" hideNoSelectionLabel=\"true\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:convertEntity />\r\n");
if (rel.isOptions())
ret.addHtmlCode("\t\t</tr:selectOneRadio>\r\n");
else
ret.addHtmlCode("\t\t</h:selectOneMenu>\r\n");
return ret;
}
ret.addHtmlCode("\r\n");
ret.addHtmlCode("\t<tr><td width=\"100%\">\r\n");
ret.addHtmlCode("\t\t<rich:panel rendered=\"#{");
/** Gestione della visibilita': showOnEditIf ... **/
if (alwaysRendered)
{
ret.addHtmlCode("true");
}
else
{
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
if (!rel.getShowOnCreateIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnCreateIf());
ret.addHtmlCode(")");
ret.addHtmlCode(" or ");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
if (!rel.getShowOnEditIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnEditIf());
ret.addHtmlCode(")");
ret.addHtmlCode(" or ");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
if (!rel.getShowOnDisplayIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnDisplayIf());
ret.addHtmlCode(")");
ret.addHtmlCode(" or ");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
if (!rel.getShowOnDeleteIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnDeleteIf());
ret.addHtmlCode(")");
}
if (!rel.getDisableOnCreateIf().equals(""))
{
disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' and (" + rel.getDisableOnCreateIf() + "))";
}
if (!rel.getDisableOnEditIf().equals(""))
{
if (!disabledCondition.equals(""))
disabledCondition += " or ";
disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT' and (" + rel.getDisableOnEditIf() + "))";
}
if (!disabledCondition.equals(""))
disabledCondition = " disabled=\"#{" + disabledCondition + "}\" ";
ret.addHtmlCode("}\"" + disabledCondition + ">\r\n");
ret.addHtmlCode("\t\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");
ret.addHtmlCode("\t\t\t<tr>\r\n");
ret.addHtmlCode("\t\t\t<td class=\"formFieldLabel\">\r\n");
ret.addHtmlCode("\t\t\t\t<h:outputLabel for=\"" + rel.getName() + "\" value=\"#{msgs.form_" + rel.ToSeamLabel() + "}\" />\r\n");
ret.addHtmlCode("\t\t\t</td>\r\n");
ret.addHtmlCode("\t\t\t<td width=\"1%\">\r\n");
if (rel.isRequired())
ret.addHtmlCode("\t\t\t\t<h:outputText value=\"*\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" style=\"color: red; font-weight: bold;\" />\r\n");
ret.addHtmlCode("\t\t\t</td>\r\n");
ret.addHtmlCode("\t\t\t<td>\r\n");
if (!rel.getAjaxEvent().equals(""))
{
ret.addHtmlCode("<a4j:region>\r\n");
}
if (rel.isOptions())
ret.addHtmlCode("\t\t\t\t<h:selectOneRadio required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" ");
else
ret.addHtmlCode("\t\t\t\t<h:selectOneMenu required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" id=\"" + rel.getName() + "\" styleClass=\"formField\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" ");
if (!alwaysRendered)
{
ret.addHtmlCode(" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DISPLAY' and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" ");
}
// Inserisce gli eventuali eventi presenti
Vector<String> events = rel.getEvents();
Vector<String> eventFunctions = rel.getEventFunctions();
for (int i = 0; i < events.size(); i++)
{
ret.addHtmlCode(events.get(i) + "=" + "\"" + eventFunctions.get(i) + "\"");
}
if (rel.isFreeText())
{
// ret.addHtmlCode(" autoSubmit=\"true\" ");
}
ret.addHtmlCode(" >\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:selectItems value=\"#{" + rel.getToBeanName() + "Manager.getSelectionItems(true," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + rel.getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" ");
ret.addHtmlCode("label=\"");
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
if (i > 0)
ret.addHtmlCode(" - ");
ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
}
ret.addHtmlCode("\"");
if (rel.isOptions())
{
if (rel.isRequired())
ret.addHtmlCode(" noSelectionLabel=\"#{msgs.Application_None}\" hideNoSelectionLabel=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" />\r\n");
else
ret.addHtmlCode(" noSelectionLabel=\"#{msgs.Application_None}\" />\r\n");
}
else
{
ret.addHtmlCode(" noSelectionLabel=\"#{msgs.Application_noSelectionLabel}\" hideNoSelectionLabel=\"false\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t\t<s:convertEntity />\r\n");
if (!rel.getAjaxEvent().equals(""))
{
// String ids = "";
//
// for (int i = 0; i < rel.getIdsToRerenderOnAjaxEvent().size(); i++)
// {
// if (i > 0)
// ids += ",";
//
// ids += rel.getIdsToRerenderOnAjaxEvent().get(i);
// }
//
// ret.addHtmlCode("\t\t\t\t\t<a4j:support event=\"" + rel.getAjaxEvent() + "\" reRender=\"" + ids + "\" limitToList=\"true\" />\r\n");
//
ret.addHtmlCode("\t\t\t\t\t" + addAjaxSupport(rel.getAjaxEvent(), rel.getIdsToRerenderOnAjaxEvent()) + "\r\n");
}
if (rel.isFreeText())
{
ret.addHtmlCode("\t\t\t\t\t<a4j:support event=\"onchange\" reRender=\"" + rel.getName() + "_Text\" limitToList=\"true\" ajaxSingle=\"true\" />\r\n");
}
if (rel.isOptions())
ret.addHtmlCode("\t\t\t\t</h:selectOneRadio>\r\n");
else
ret.addHtmlCode("\t\t\t\t</h:selectOneMenu>\r\n");
if (rel.isFreeText())
{
// Aggiunge il campo di testo per l'inserimento di una opzione
// aggiuntiva
ret.addHtmlCode("\t\t<!-- FREE TEXT FIELD -->\r\n");
ret.addHtmlCode("\t\t<h:inputText id=\"" + rel.getName() + "_Text\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + rel.getName() + Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(0).getName()) + "}\" ");
ret.addHtmlCode(" required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" ");
ret.addHtmlCode(" disabled=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".");
Properties prop = new Properties();
try
{
prop.load(new FileInputStream(sourceDir + ".." + File.separator + "html" + File.separator + "WEB-INF" + File.separator + "classes" + File.separator + "messages.properties"));
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
ret.addHtmlCode(Utils.makeFirstLetterLowerCase(rel.getRelatedAttributes().get(0).getName()) + "!='" + prop.get("Application_other") + "'}\" ");
ret.addHtmlCode(" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DISPLAY' and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" />\r\n");
// Aggiunge il campo di testo per la visualizzazione dell'opzione
// aggiuntiva
ret.addHtmlCode("\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + rel.getName() + Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(0).getName()) + "}\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + rel.getName() + Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(0).getName()) + "!=null)}\" />\r\n");
ret.addHtmlCode("\t\t<h:outputText value=\"\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + rel.getName() + Utils.makeFirstLetterUpperCase(rel.getRelatedAttributes().get(0).getName()) + "==null)}\" />\r\n");
ret.addHtmlCode("\t\t<!-- FREE TEXT FIELD -->\r\n");
}
if (!rel.getAjaxEvent().equals(""))
{
ret.addHtmlCode("</a4j:region>\r\n");
}
if (!alwaysRendered)
{
ret.addHtmlCode("\t\t\t\t<h:outputText value=\"");
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
if (i > 0)
ret.addHtmlCode(" - ");
ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
}
ret.addHtmlCode("\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "!=null)}\" />\r\n");
ret.addHtmlCode("\t\t\t\t<h:outputText value=\"\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "==null)}\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t<br />\r\n");
ret.addHtmlCode("\t\t\t\t<h:message for=\"" + rel.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
ret.addHtmlCode("\t\t\t</td>\r\n");
if (rel.isHelp())
{
ret.addHtmlCode("\t\t\t<td width=\"1%\"><h:graphicImage styleClass=\"imageLink\" url=\"img/info.gif\" onclick=\"help('help/form_" + bean.getName() + "_" + rel.getName() + ".html');\" /></td>\r\n");
}
else
{
ret.addHtmlCode("\t\t\t<td width=\"1%\"></td>\r\n");
}
ret.addHtmlCode("\t\t\t</tr>\r\n");
ret.addHtmlCode("\t\t\t</table>\r\n");
ret.addHtmlCode("\t\t</rich:panel>\r\n");
ret.addHtmlCode("\t</td></tr>\r\n");
return ret;
}
// private static CodeChunk insertMultipleSelectionListBox2Form(Bean bean, Relationship rel, boolean visible)
// {
// return insertMultipleSelectionListBox2Form(bean, rel, visible, false);
// }
/**
* Genera un list box a selezione multipla
*/
private static CodeChunk insertMultipleSelectionListBox2Form(Bean bean, Relationship rel, boolean visible, boolean alwaysRendered)
{
CodeChunk ret = new CodeChunk(0);
String disabledCondition = "";
if (!visible)
{
if (rel.isOptions())
ret.addHtmlCode("\t\t<h:selectManyCheckbox id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" styleClass=\"formField\" ");
else
ret.addHtmlCode("\t\t<h:selectManyListbox id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" styleClass=\"formField\" ");
ret.addHtmlCode(" style=\"display:none;\" ");
if (!alwaysRendered)
{
ret.addHtmlCode(" rendered=\"#{" + bean.getName() + "Manager.getCallingBeanName().contains('" + bean.getName() + "')}\" ");
}
ret.addHtmlCode(" >\r\n");
ret.addHtmlCode("\t\t\t<s:selectItems value=\"#{" + rel.getToBeanName() + "Manager.getSelectionItems(true," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + rel.getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" ");
ret.addHtmlCode("label=\"");
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
if (i > 0)
ret.addHtmlCode(" - ");
ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
}
ret.addHtmlCode("\"");
// ret.addHtmlCode(" noSelectionLabel=\"Selezionare...\" hideNoSelectionLabel=\"" + rel.isRequired() + "\"");
ret.addHtmlCode("/>\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:convertEntity />\r\n");
if (rel.isOptions())
ret.addHtmlCode("\t\t</h:selectManyCheckbox>\r\n");
else
ret.addHtmlCode("\t\t</h:selectManyListbox>\r\n");
return ret;
}
ret.addHtmlCode("\r\n");
ret.addHtmlCode("\t<tr><td width=\"100%\">\r\n");
ret.addHtmlCode("\t\t<rich:panel rendered=\"#{");
/** Gestione della visibilita': showOnEditIf ... **/
if (alwaysRendered)
{
ret.addHtmlCode("true");
}
else
{
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
if (!rel.getShowOnCreateIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnCreateIf());
ret.addHtmlCode(")");
ret.addHtmlCode(" or ");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
if (!rel.getShowOnEditIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnEditIf());
ret.addHtmlCode(")");
ret.addHtmlCode(" or ");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
if (!rel.getShowOnDisplayIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnDisplayIf());
ret.addHtmlCode(")");
ret.addHtmlCode(" or ");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
if (!rel.getShowOnDeleteIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnDeleteIf());
ret.addHtmlCode(")");
}
if (!rel.getDisableOnCreateIf().equals(""))
{
disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' and (" + rel.getDisableOnCreateIf() + "))";
}
if (!rel.getDisableOnEditIf().equals(""))
{
if (!disabledCondition.equals(""))
disabledCondition += " or ";
disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT' and (" + rel.getDisableOnEditIf() + "))";
}
if (!disabledCondition.equals(""))
disabledCondition = " disabled=\"#{" + disabledCondition + "}\" ";
ret.addHtmlCode("}\"" + disabledCondition + ">\r\n");
ret.addHtmlCode("\t\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");
ret.addHtmlCode("\t\t\t<tr>\r\n");
ret.addHtmlCode("\t\t\t<td class=\"formFieldLabel\">\r\n");
ret.addHtmlCode("\t\t\t\t<h:outputLabel for=\"" + rel.getName() + "\" value=\"#{msgs.form_" + rel.ToSeamLabel() + "}\" />\r\n");
ret.addHtmlCode("\t\t\t</td>\r\n");
ret.addHtmlCode("\t\t\t<td width=\"1%\">\r\n");
if (rel.isRequired())
ret.addHtmlCode("\t\t\t\t<h:outputText value=\"*\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" style=\"color: red; font-weight: bold;\" />\r\n");
ret.addHtmlCode("\t\t\t</td>\r\n");
ret.addHtmlCode("\t\t\t<td>\r\n");
if (!rel.getAjaxEvent().equals(""))
{
ret.addHtmlCode("<a4j:region>\r\n");
}
if (rel.isOptions())
ret.addHtmlCode("\t\t\t\t<h:selectManyCheckbox required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" styleClass=\"formField\" ");
else
ret.addHtmlCode("\t\t\t\t<h:selectManyListbox required=\"#{" + rel.isRequired() + " and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" id=\"" + rel.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" styleClass=\"formField\"");
if (!alwaysRendered)
ret.addHtmlCode(" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DISPLAY' and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" ");
// Inserisce gli eventuali eventi presenti
Vector<String> events = rel.getEvents();
Vector<String> eventFunctions = rel.getEventFunctions();
for (int i = 0; i < events.size(); i++)
{
ret.addHtmlCode(events.get(i) + "=" + "\"" + eventFunctions.get(i) + "\"");
}
ret.addHtmlCode(" >\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:selectItems value=\"#{" + rel.getToBeanName() + "Manager.getSelectionItems(true," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + rel.getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" ");
ret.addHtmlCode("label=\"");
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
if (i > 0)
ret.addHtmlCode(" - ");
ret.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}");
}
ret.addHtmlCode("\"");
//ret.addHtmlCode(" noSelectionLabel=\"Selezionare...\" hideNoSelectionLabel=\""+rel.isRequired()+"\" />\r\n");
ret.addHtmlCode(" />\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:convertEntity />\r\n");
if (!rel.getAjaxEvent().equals(""))
{
// String ids = "";
//
// for (int i = 0; i < rel.getIdsToRerenderOnAjaxEvent().size(); i++)
// {
// if (i > 0)
// ids += ",";
//
// ids += rel.getIdsToRerenderOnAjaxEvent().get(i);
// }
//
// ret.addHtmlCode("\t\t\t\t\t<a4j:support event=\"" + rel.getAjaxEvent() + "\" reRender=\"" + ids + "\" limitToList=\"true\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t" + addAjaxSupport(rel.getAjaxEvent(), rel.getIdsToRerenderOnAjaxEvent()) + "\r\n");
}
if (rel.isOptions())
ret.addHtmlCode("\t\t\t\t</h:selectManyCheckbox>\r\n");
else
ret.addHtmlCode("\t\t\t\t</h:selectManyListbox>\r\n");
if (!rel.getAjaxEvent().equals(""))
{
ret.addHtmlCode("</a4j:region>\r\n");
}
if (!alwaysRendered)
{
ret.addHtmlCode("\t\t\t\t<rich:dataTable var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "!=null)}\" >\r\n");
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
if (i > 0)
{
ret.addHtmlCode("\t\t\t\t\t<rich:column>\r\n");
ret.addHtmlCode("\t\t\t\t\t\t<tr:outputText value=\"-\"/>\r\n");
ret.addHtmlCode("\t\t\t\t\t</rich:column>\r\n");
}
ret.addHtmlCode("\t\t\t\t\t<rich:column");
if (rel.getRelatedAttributes().get(i).getType().contains("Double") || rel.getRelatedAttributes().get(i).getType().contains("Integer") || rel.getRelatedAttributes().get(i).getType().contains("Long"))
{
ret.addHtmlCode(" align=\"right\" ");
}
if (rel.getRelatedAttributes().get(i).getType().contains("String"))
{
ret.addHtmlCode(" align=\"left\" ");
}
if (rel.getRelatedAttributes().get(i).getType().contains("Date") || rel.getRelatedAttributes().get(i).getType().contains("Boolean"))
{
ret.addHtmlCode(" align=\"center\" ");
}
ret.addHtmlCode(">\r\n");
ret.addHtmlCode("\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + rel.getRelatedAttributes().get(i).getName() + "}\"/>\r\n");
ret.addHtmlCode("\t\t\t\t\t</rich:column>\r\n");
}
ret.addHtmlCode("\t\t\t\t</rich:dataTable>\r\n");
//ret.addHtmlCode("\t\t<h:outputText value=\"\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE') and (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "==null)}\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t<br />\r\n");
ret.addHtmlCode("\t\t\t\t<h:message for=\"" + rel.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
ret.addHtmlCode("\t\t\t</td>\r\n");
if (rel.isHelp())
{
ret.addHtmlCode("\t\t\t<td width=\"1%\"><h:graphicImage styleClass=\"imageLink\" url=\"img/info.gif\" onclick=\"help('help/form_" + bean.getName() + "_" + rel.getName() + ".html');\" /></td>\r\n");
}
else
{
ret.addHtmlCode("\t\t\t<td width=\"1%\"></td>\r\n");
}
ret.addHtmlCode("\t\t\t</tr>\r\n");
ret.addHtmlCode("\t\t\t</table>\r\n");
ret.addHtmlCode("\t\t</rich:panel>\r\n");
ret.addHtmlCode("\t</td></tr>\r\n");
return ret;
}
/**
* Genera una riga per attivare la pop-up a selezione singola
*/
private static CodeChunk insertSingleSelectionPopUp2Form(String sourceDir, Bean bean, Relationship rel, boolean inPopUp)
{
return insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp, false);
}
private static CodeChunk insertSingleSelectionPopUp2Form(String sourceDir, Bean bean, Relationship rel, boolean inPopUp, boolean alwaysRendered)
{
return insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp, alwaysRendered);
}
/**
* Genera una riga per attivare la pop-up a selezione multipla
*/
private static CodeChunk insertMultipleSelectionPopUp2Form(String sourceDir, Bean bean, Relationship rel, boolean inPopUp)
{
return insertMultipleSelectionPopUp2Form(sourceDir, bean, rel, inPopUp, false);
}
private static CodeChunk insertMultipleSelectionPopUp2Form(String sourceDir, Bean bean, Relationship rel, boolean inPopUp, boolean alwaysRendered)
{
CodeChunk ret = new CodeChunk(0);
String disabledCondition = "";
if (!rel.isListBox() && !rel.isCRUD())
{
ret.addJavascriptCode("function openPopUp_" + rel.getName() + "()");
ret.JavascriptNewLine();
ret.addJavascriptCode("{");
ret.JavascriptNewLine();
if (inPopUp)
ret.addJavascriptCode("\twindow.open(\"popup/" + bean.getName() + rel.getName() + "PopUp.seam?callingBean=" + bean.getName() + "InPopUp&callingConversationId=\"+document.forms[\"form\"].elements['form:parentConversationId'].value+\"&conversationIsLongRunning=true\",\"" + rel.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");");
else
ret.addJavascriptCode("\twindow.open(\"popup/" + bean.getName() + rel.getName() + "PopUp.seam?callingBean=" + bean.getName() + "&callingConversationId=\"+document.forms[\"form\"].elements['form:parentConversationId'].value+\"&conversationIsLongRunning=true\",\"" + rel.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");");
ret.JavascriptNewLine();
ret.addJavascriptCode("}");
ret.JavascriptNewLine();
}
ret.addHtmlCode("\r\n<tr><td width=\"100%\">\r\n");
ret.addHtmlCode("\t<rich:panel");
/** Gestione della visibilita': showOnEditIf ... **/
if (!alwaysRendered)
{
ret.addHtmlCode(" rendered=\"#{");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE'");
if (!rel.getShowOnCreateIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnCreateIf());
ret.addHtmlCode(")");
ret.addHtmlCode(" or ");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'");
if (!rel.getShowOnEditIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnEditIf());
ret.addHtmlCode(")");
ret.addHtmlCode(" or ");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DISPLAY'");
if (!rel.getShowOnDisplayIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnDisplayIf());
ret.addHtmlCode(")");
ret.addHtmlCode(" or ");
ret.addHtmlCode("(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='DELETE'");
if (!rel.getShowOnDeleteIf().equals(""))
ret.addHtmlCode(" and " + rel.getShowOnDeleteIf());
ret.addHtmlCode(")");
ret.addHtmlCode("}\"");
}
ret.addHtmlCode(">\r\n");
ret.addHtmlCode("\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");
ret.addHtmlCode("\t\t\t<tr>\r\n");
ret.addHtmlCode("\t\t\t\t<td class=\"formFieldLabel\"><h:outputLabel for=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(rel.getName()) + "\" value=\"#{msgs.form_" + rel.ToSeamLabel() + "}\" /></td>\r\n");
ret.addHtmlCode("\t\t\t\t<td>\r\n");
if (!rel.isListBox() && rel.isCRUD())
{
ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initCreateInPopUp}\" rendered=\"false\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initDisplayInPopUp}\" rendered=\"false\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initEditInPopUp}\" rendered=\"false\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t<s:link action=\"#{" + rel.getToBeanName() + "Manager.initDeleteInPopUp}\" rendered=\"false\" />\r\n");
if (rel.getPopUpCreate())
{
// Inserisce il pulsante per la creazione della relazione
// Prima deve essere costrutita la condizione per la disabilitazione
if (!rel.getDisableOnCreateIf().equals(""))
{
disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' and (" + rel.getDisableOnCreateIf() + "))";
}
if (!rel.getDisableOnEditIf().equals(""))
{
if (!disabledCondition.equals(""))
disabledCondition += " or ";
disabledCondition += "(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT' and (" + rel.getDisableOnEditIf() + "))";
}
if (!disabledCondition.equals(""))
disabledCondition = "disabled=\"#{" + disabledCondition + "}\"";
ret.addHtmlCode("\t\t\t\t\t<a4j:commandButton id=\"popup_New" + rel.getToBeanName() + "\" value=\"#{msgs.list_" + rel.getToBeanName() + "_new}\" onclick=\"openCrudPopUp_" + rel.getName() + "('Create');\" styleClass=\"formButton\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='SEARCH')}\" " + disabledCondition + " />\r\n");
}
ret.addJavascriptCode("function openCrudPopUp_" + rel.getName() + "(operation)\r\n");
ret.addJavascriptCode("{\r\n");
ret.addJavascriptCode("\twindow.open(\"" + bean.getName() + ".seam?conversationId=\"+document.forms[\"form\"].elements['form:parentConversationId'].value+\"&conversationIsLongRunning=true&actionMethod=" + bean.getName() + ".xhtml:" + rel.getToBeanName() + "Manager.init\"+operation+\"InPopUp&callingBean=" + bean.getName() + "&relationship=" + rel.getName() + "\",\"" + rel.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");\r\n");
ret.addJavascriptCode("}\r\n");
}
if (rel.isRequired())
{
ret.addHtmlCode("\t\t\t\t\t<h:outputText value=\"*\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE' or " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT'}\" style=\"color: red; font-weight: bold;\" />\r\n");
}
if (!rel.isCRUD())
ret.addHtmlCode("\t\t\t\t\t<a4j:commandButton id=\"popup_" + rel.getName() + "\" value=\"#{msgs.Application_buttonSelect}\" onclick=\"openPopUp_" + rel.getName() + "();\" styleClass=\"formButton\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='SEARCH')}\" />\r\n");
if (rel.isRequired())
{
ret.addHtmlCode("\t\t\t\t\t<h:inputText id=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(rel.getName()) + "\" value=\"\" required=\"#{true and " + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DELETE'}\" style=\"display:none;\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation!='DISPLAY'}\" " + disabledCondition + " />\r\n");
ret.addHtmlCode("\t\t\t\t\t<h:message for=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(rel.getName()) + "\" errorClass=\"rich-messages-label\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t</td>\r\n");
ret.addHtmlCode("\t\t\t</tr>\r\n");
ret.addHtmlCode("\t\t\t<tr>\r\n");
ret.addHtmlCode("\t\t\t\t<td colspan=\"2\">\r\n");
ret.addHtmlCode("\t\t\t\t\t<rich:dataTable id=\"tab_" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + rel.getName() + "\" var=\"" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" width=\"100%\"\r\n");
if (!rel.isListBox() && rel.isCRUD())
{
ret.addHtmlCode("\t\t\t\t\tcolumnClasses=\"dataColumnCenterAlignment," + listColumnClasses(rel.getRelatedAttributes(), false) + "\"\r\n");
ret.addHtmlCode("\t\t\t\t\t>\r\n");
ret.addHtmlCode("<!-- POPUP MENU COLUMN -->\r\n");
ret.addHtmlCode("\t<rich:column width=\"1%\">\r\n");
ret.addHtmlCode("\t\t<f:facet name=\"header\"> </f:facet>\r\n");
ret.addHtmlCode("\t\t<h:panelGroup>\r\n");
ret.addHtmlCode("\t\t\t<h:graphicImage url=\"img/action.gif\" id=\"pic\" >\r\n");
ret.addHtmlCode("\t\t\t\t<rich:componentControl event=\"onclick\" for=\"menu" + rel.getName() + "\" operation=\"show\">\r\n");
ret.addHtmlCode("\t\t\t\t\t<f:param value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".id}\" name=\"selectedBean\"/>\r\n");
ret.addHtmlCode("\t\t\t\t</rich:componentControl>\r\n");
ret.addHtmlCode("\t\t\t</h:graphicImage>\r\n");
ret.addHtmlCode("\t\t</h:panelGroup>\r\n");
ret.addHtmlCode("\t</rich:column>\r\n");
ret.addHtmlCode("<!-- POPUP MENU COLUMN -->\r\n");
}
else
{
ret.addHtmlCode("\t\t\t\t\tcolumnClasses=\"" + listColumnClasses(rel.getRelatedAttributes(), false) + "\"\r\n");
ret.addHtmlCode("\t\t\t\t\t>\r\n");
}
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
ShowAttribute attr = rel.getRelatedAttributes().get(i);
ret.addHtmlCode("\t\t\t\t\t\t<rich:column");
ret.addHtmlCode(">\r\n");
ret.addHtmlCode("\t\t\t\t\t\t\t<f:facet name=\"header\">\r\n");
ret.addHtmlCode("\t\t\t\t\t\t\t\t<h:outputText value=\"#{msgs.form_" + bean.getName() + "_" + rel.getName());
for (int k = 0; k < attr.getRelationships().size(); k++)
{
ret.addHtmlCode("_");
ret.addHtmlCode(attr.getRelationships().get(k).getName());
}
ret.addHtmlCode("_" + attr.getName() + "");
ret.addHtmlCode("}\" />\r\n");
ret.addHtmlCode("\t\t\t\t\t\t\t</f:facet>\r\n");
if (attr.getRelationships().size() == 0)
{
ret.addHtmlCode("\t\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + "." + attr.getName() + "}\"");
if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
ret.addHtmlCode(" escape=\"false\"");
ret.addHtmlCode(" >\r\n");
if (attr.getType().equals("java.util.Date"))
{
ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
}
if (attr.getType().equals("java.lang.Double") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t\t\t\t</h:outputText >\r\n");
}
else
{
/**
*
* Attributo nella forma
*
* [relationship.]*Atribute
*
*/
if (!attribute2N(attr))
{
ret.addHtmlCode("\t\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".");
for (int k = 0; k < attr.getRelationships().size(); k++)
{
if (k > 0)
ret.addHtmlCode(".");
ret.addHtmlCode(Utils.makeMethod2Field(attr.getRelationships().get(k).getName()));
}
ret.addHtmlCode("." + attr.getName());
ret.addHtmlCode("}\"");
if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
ret.addHtmlCode(" escape=\"false\"");
ret.addHtmlCode(" >\r\n");
if (attr.getType().equals("java.util.Date"))
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"#{msgs.Application_DateFormat}\" />\r\n");
}
if (attr.getType().equals("java.lang.Double") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t\t\t</h:outputText>\r\n");
}
else
{
ret.addHtmlCode("\t\t\t\t<rich:dataTable verticalGridVisible=\"false\" horizontalGridVisible=\"true\" var=\"" + Utils.makeMethod2Field(attr.getRelationship().getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ".");
for (int k = 0; k < attr.getRelationships().size(); k++)
{
if (k > 0)
ret.addHtmlCode(".");
ret.addHtmlCode(Utils.makeMethod2Field(attr.getRelationships().get(k).getName()));
}
ret.addHtmlCode("}\" >\r\n");
ret.addHtmlCode("\t\t\t\t\t<rich:column");
if (attr.getType().contains("Double") || attr.getType().contains("Integer") || attr.getType().contains("Long"))
{
ret.addHtmlCode(" align=\"right\" ");
}
if (attr.getType().contains("String"))
{
ret.addHtmlCode(" align=\"left\" ");
}
if (attr.getType().contains("Date") || attr.getType().contains("Boolean"))
{
ret.addHtmlCode(" align=\"center\" ");
}
// Celle senza bordi
ret.addHtmlCode(" style=\"background-color: transparent; border-left-style: none; border-right-style: none;\" >\r\n");
ret.addHtmlCode("\t\t\t\t\t\t<h:outputText value=\"#{" + Utils.makeMethod2Field(attr.getRelationship().getName()) + attr.SeamField() + "}\"");
if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
ret.addHtmlCode(" escape=\"false\"");
ret.addHtmlCode(" >\r\n");
if (attr.getType().equals("java.util.Date"))
{
ret.addHtmlCode("\t\t\t\t\t\t\t<f:converter converterId=\"#{msgs.Application_DateFormat}\" />\r\n");
}
if (attr.getType().equals("java.lang.Double"))
{
//ret.addHtmlCode("\t\t\t\t\t\t\t<f:convertNumber groupingUsed=\"true\" minFractionDigits=\"2\" maxFractionDigits=\"2\" locale=\"IT_it\" />\r\n");
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n");
}
if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
{
ret.addHtmlCode("\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
}
ret.addHtmlCode("\t\t\t\t\t\t</h:outputText>\r\n");
ret.addHtmlCode("\t\t\t\t\t</rich:column>\r\n");
ret.addHtmlCode("\t\t\t\t</rich:dataTable>\r\n");
}
}
ret.addHtmlCode("\t\t\t\t\t\t</rich:column>\r\n");
}
ret.addHtmlCode("\t\t\t\t\t</rich:dataTable>\r\n");
ret.addHtmlCode("\t\t\t\t</td>\r\n");
ret.addHtmlCode("\t\t\t\t</tr>\r\n");
ret.addHtmlCode("\t\t\t</table>\r\n");
ret.addHtmlCode("\t\t</rich:panel>\r\n");
ret.addHtmlCode("\t</td></tr>\r\n");
return ret;
}
public static void generateListPages(String sourceDir, String targetDir, String basePackage, Bean bean) throws Exception
{
Vector<ShowList> showList = bean.getLists();
for (ShowList list : showList)
{
generateListPage(sourceDir, targetDir, basePackage, bean, list);
}
}
/**
* Genera la pagina lista
*
* @throws Exception
*/
public static void generateListPage(String sourceDir, String targetDir, String basePackage, Bean bean, ShowList listInfo) throws Exception
{
String template = "." + File.separator + "templates" + File.separator + "Seam_FormList.xhtml";
String sourceFile = sourceDir + ".." + File.separator + "html" + File.separator + "list" + File.separator + bean.getName() + "List.xhtml";
String targetFile = targetDir + "html" + File.separator + "list" + File.separator + listInfo.getName() + "List.xhtml";
String createButtons = "";
String columnClasses = "";
String columnWidths = "";
String rows = "";
String javaScript = "";
String masterButton = "";
String detailButton = "";
String selectionButton = "";
String searchButton = "";
CodeChunk localSearch;
String path = "";
String details = "";
String printButton = "";
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JSP);
InfoReader infoReader = new InfoReader(sourceDir);
/**
* Predisposizione delle informazion relative alle relazioni MASTER-DETAIL
* non categorizzate
*/
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship rel = bean.getRelationships().get(i);
if (rel.isUsed())
{
if (rel.isMasterDetail() && !rel.isFromMaster())
{
// Il bean e' un Detail in una relazione MASTER-DETAIL
// Predispone l'indicazione del Master (PATH) se questo bean e' un Detail
path = "<h:outputText value=\"#{" + bean.getName() + "Manager.path}\" styleClass=\"listPath\" />\r\n";
// Inserisce il bottone di selezione del Master
if (rel.isGoToMasterMenuItem())
{
masterButton += "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + rel.getToBeanName() + "}\" action=\"/list/" + rel.getToBeanName() + "List.seam?masterReference=true\" rendered=\"#{" + bean.getName() + "Manager.isDetailOf('" + rel.getToBeanName() + "')}\" style=\"text-decoration: none; color: black\" />\r\n";
}
else
masterButton = "";
}
if (rel.isMasterDetail() && rel.isFromMaster())
{
// Il bean e' un Master in una relazione MASTER-DETAIL
// Predispone i links a tutte le liste del bean DETAIL
detailButton += "\t<rich:menuSeparator />\r\n";
Vector<ShowList> lists = infoReader.getLists(rel.getToBeanName());
for (int j = 0; j < lists.size(); j++)
{
// detailButton += "\t\t\t<tr:commandLink immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + lists.get(j).getName() + "}\" action=\"#{@BeanManager.goTo" + lists.get(j).getName() + "}\" style=\"white-space: nowrap;\" />\r\n";
detailButton += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + lists.get(j).getName() + "}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" action=\"#{@BeanManager.goTo" + lists.get(j).getName() + "}\" style=\"white-space: nowrap;\" >\r\n";
detailButton += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
detailButton += "\t</rich:menuItem>\r\n";
}
}
}
}
/**
* Predisposizione delle informazioni relative alle relazioni
* MASTER-DETAIL categorizzate *
*/
details += generateDetails(bean, sourceDir);
// Prepara la lista dei campi
columnClasses = listColumnClasses(bean.getShowAttributes(), true); // Stile delle colonne
columnWidths = listColumnWidths(bean.getShowAttributes(), true); // Dimensioni delle colonne
rows = listColumns(bean.getName(), bean.getShowAttributes()); // Colonne della tabella
/** Bottone per la ricerca locale **/
if (bean.getSearchAttributes().size() > 1)
{
selectionButton += "\r\n\taddMenuBarItem(new menuBarItem(\"<bean:message key=\"list." + bean.getName() + ".button.search\"/>\", \"\", \"\", \"\", \"code:doSubmit('<bean:message key=\"list." + bean.getName() + ".button.search\"/>');\"));\r\n";
}
/** Ricerca locale * */
localSearch = localSearch(bean);
javaScript += localSearch.getJavascriptCode();
// Voce menu per ricerca
if (bean.getSearchAttributes().size() > 1)
{
searchButton += "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_search}\" action=\"#{" + bean.getName() + "Manager.initSearch}\" style=\"text-decoration: none; color: black\" />\r\n";
}
// Menu creazione bean
Vector<String> derivedBeans = infoReader.getDerivedBeans(bean.getName());
if (derivedBeans.size() == 0)
{
if (listInfo.getNewMenuCondition().equals(""))
createButtons = "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_new}\" action=\"#{" + bean.getName() + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />\r\n";
else
createButtons = "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_new}\" action=\"#{" + bean.getName() + "Manager.initCreate}\" rendered=\"#{" + listInfo.getNewMenuCondition() + "}\" style=\"text-decoration: none; color: black\" />\r\n";
}
else
{
// Nel caso questo sia un bean padre, vengono inseriti solo i menu per
// la creazione dei bean derivati
for (String derivedBean : derivedBeans)
{
createButtons += "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + derivedBean + "_new}\" action=\"#{" + derivedBean + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />\r\n";
}
}
/** Gestione dell'opzione di stampa **/
if (listInfo.getPrintMenuInListCondition().equals(""))
printButton = "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/list/" + bean.getName() + "PrintList.seam?masterReference=true\" style=\"text-decoration: none; color: black\" />\r\n";
else
printButton = "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.Application_print}\" action=\"/list/" + bean.getName() + "PrintList.seam?masterReference=true\" rendered=\"#{" + listInfo.getPrintMenuInListCondition() + "}\" style=\"text-decoration: none; color: black\" />\r\n";
HashMap<String, String> tags = new HashMap<String, String>();
tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));
tags.put("@Javascript", javaScript);
tags.put("@SearchButton", searchButton);
tags.put("@Path", path);
tags.put("@Title", listInfo.getName());
tags.put("@CreateButtons", createButtons);
tags.put("@ColumnClasses", columnClasses);
tags.put("@ColumnWidths", columnWidths);
tags.put("@MasterButton", masterButton);
tags.put("@DetailButton", detailButton);
tags.put("@PrintButton", printButton);
tags.put("@Bean", bean.getName());
tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
tags.put("@LocalSearch", localSearch.getHtmlCode());
tags.put("@Rows", rows);
tags.put("@Details", details);
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
}
private static String generateDetails(Bean masterBean, String sourceDir) throws Exception
{
String ret = "";
String rows = "";
String template = "." + File.separator + "templates" + File.separator + "Seam_DetailTable.xhtml";
if (masterBean.hasCategorizedRelationship())
{
ret += "\t\t<tr:panelGroupLayout layout=\"vertical\">\r\n";
for (int i = 0; i < masterBean.getRelationships().size(); i++)
{
Relationship rel = masterBean.getRelationships().get(i);
if (rel.isUsed() && rel.isMasterDetail() && rel.isFromMaster() && rel.isCategorized())
{
HashMap<String, String> tags = new HashMap<String, String>();
InfoReader infoReader = new InfoReader(sourceDir);
Bean detailBean = infoReader.getBean(rel.getToBeanName());
rows = rows = listColumns(detailBean.getName(), detailBean.getShowAttributes());
tags.put("@bean", Utils.makeFirstLetterLowerCase(detailBean.getName()));
tags.put("@Bean", detailBean.getName());
tags.put("@masterBean", Utils.makeFirstLetterLowerCase(masterBean.getName()));
tags.put("@Relationship", Utils.makeFirstLetterLowerCase(masterBean.getName()) + "." + Utils.makeMethod2Field(rel.getName()));
tags.put("@Rows", rows);
Bean targetBean = infoReader.getBean(rel.getToBeanName());
String details = generateDetails(targetBean, sourceDir);
tags.put("@Details", details);
ret += Utils.SeamReplaceTag2String(tags, null, null, template);
}
}
ret += "\t\t</tr:panelGroupLayout>\r\n";
}
return ret;
}
/**
* Genera la pagina lista stampabile in PDF
*/
public static void generateListPagePrint(String sourceDir, String targetDir, String basePackage, Bean bean) throws FileNotFoundException, IOException
{
String template = "." + File.separator + "templates" + File.separator + "Seam_PrintFormList.xhtml";
String sourceFile = sourceDir + ".." + File.separator + "html" + File.separator + "list" + File.separator + bean.getName() + "PrintList.xhtml";
String targetFile = targetDir + "html" + File.separator + "list" + File.separator + bean.getName() + "PrintList.xhtml";
String path = "";
String columnClasses = "";
String rows = "";
String titles = "";
Vector<Relationship> rels = bean.getRelationships();
for (Relationship rel : rels)
{
if (rel.isMasterDetail() && !rel.isFromMaster())
{
// Deve essere mostrato il path
path = "<p:font size=\"9\" color=\"red\"><p:paragraph spacingAfter=\"15\">#{" + bean.getName() + "Manager.path}</p:paragraph></p:font>";
break;
}
}
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JSP);
// Prepara la lista dei campi
// columnClasses = listColumnClasses(bean.getShowAttributes());
// Stile delle colonne
titles = listColumnsTitlesPrint(bean.getName(), bean.getShowAttributes());
// Colonne della tabella
rows = listColumnsPrint(bean.getName(), bean.getShowAttributes());
HashMap<String, String> tags = new HashMap<String, String>();
tags.put("@Path", path);
tags.put("@ColumnClasses", columnClasses);
tags.put("@Columns", String.valueOf(bean.getShowAttributes().size() - 1));
tags.put("@Bean", bean.getName());
tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
tags.put("@Titles", titles);
tags.put("@Rows", rows);
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
}
/**
* Genera il form del bean stampabile in PDF
*/
public static void generateFormPagePrint(String sourceDir, String targetDir, String basePackage, Bean bean) throws FileNotFoundException, IOException
{
String template = "." + File.separator + "templates" + File.separator + "Seam_PrintForm.xhtml";
String sourceForm = sourceDir + ".." + File.separator + "html" + File.separator + bean.getName() + ".xhtml";
String targetForm = targetDir + "html" + File.separator + bean.getName() + "Print.xhtml";
String rows = "";
Vector<CodeChunk> codeChunks = new Vector<CodeChunk>();
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceForm, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceForm, CustomCodeType.JSP);
/** Predispone la lista di tutti gli attributi da inserire nel form **/
/** I campi Transient sono gestiti in questa sezione **/
for (int i = 0; i < bean.getAttributes().size(); i++)
{
Attribute attribute = bean.getAttributes().get(i);
if (!attribute.isKey() && (attribute.getImplementationType() != AttributeImplementationType.HIDEINFORM))
{
CodeChunk codeChunk = new CodeChunk(attribute.getOrderInForm());
codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\" verticalAlignment=\"middle\" ");
if (!attribute.getOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">");
codeChunk.addHtmlCode("#{msgs.form_" + bean.getName() + "_" + attribute.getName() + "}</p:cell>\r\n");
if (attribute.getImplementationType() == AttributeImplementationType.TEXTAREA)
{
if (attribute.getType().equals("java.lang.String"))
{
codeChunk.addHtmlCode("\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");
if (!attribute.getOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}</p:cell>\r\n");
}
}
if (attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
{
if (attribute.getType().equals("java.lang.String"))
{
codeChunk.addHtmlCode("\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");
if (!attribute.getOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"Html2PdfConverter\" />\r\n");
codeChunk.addHtmlCode("\t\t</p:text>\r\n");
codeChunk.addHtmlCode("\t</p:cell>\r\n");
}
}
if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
{
codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\" verticalAlignment=\"middle\">LIST BOX</p:cell>\r\n");
}
if (attribute.getImplementationType() == AttributeImplementationType.TEXT || attribute.getImplementationType() == AttributeImplementationType.READONLY)
{
if (attribute.getType().equals("java.lang.Boolean"))
{
codeChunk.addHtmlCode("\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");
if (!attribute.getOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}</p:cell>\r\n");
}
if (attribute.getType().equals("java.lang.String"))
{
codeChunk.addHtmlCode("\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");
if (!attribute.getOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}</p:cell>\r\n");
}
if (attribute.getType().equals("java.util.Date"))
{
codeChunk.addHtmlCode("\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");
if (!attribute.getOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:convertDateTime type=\"date\" pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
codeChunk.addHtmlCode("\t\t</p:text>\r\n");
codeChunk.addHtmlCode("\t</p:cell>\r\n");
}
if (attribute.getType().equals("java.lang.Double"))
{
codeChunk.addHtmlCode("\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");
if (!attribute.getOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n");
codeChunk.addHtmlCode("\t\t</p:text>\r\n");
codeChunk.addHtmlCode("\t</p:cell>\r\n");
}
if (attribute.getType().equals("java.lang.Long"))
{
codeChunk.addHtmlCode("\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");
if (!attribute.getOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"LongConverter\"/>\r\n");
codeChunk.addHtmlCode("\t\t</p:text>\r\n");
codeChunk.addHtmlCode("\t</p:cell>\r\n");
}
if (attribute.getType().equals("java.lang.Integer"))
{
codeChunk.addHtmlCode("\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ");
if (!attribute.getOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + attribute.getOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t<p:text value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getName() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n");
codeChunk.addHtmlCode("\t\t</p:text>\r\n");
codeChunk.addHtmlCode("\t</p:cell>\r\n");
}
}
codeChunks.add(codeChunk);
}
}
// Inserisce gli attributi provenienti da relazioni che debbono essere
// solo visualizzati
for (int i = 0; i < bean.getShowInFormAttributes().size(); i++)
{
ShowAttribute attribute = bean.getShowInFormAttributes().get(i);
CodeChunk codeChunk = new CodeChunk(attribute.getOrderInForm());
codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\" verticalAlignment=\"middle\">#{msgs.form_" + bean.getName() + "_" + attribute.getQualifiedName().replace(".", "_") + "}</p:cell>\r\n");
codeChunk.addHtmlCode("\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\">#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + attribute.getQualifiedName() + "}</p:cell>\r\n");
codeChunks.add(codeChunk);
}
// Inserisce gli attributi provenienti da relazioni
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship rel = bean.getRelationships().get(i);
if (rel.isUsed() && !rel.isMasterDetail())
{
CodeChunk codeChunk = new CodeChunk(0);
if (!rel.isListBox())
{
codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\" verticalAlignment=\"middle\" colspan=\"2\" ");
if (!rel.getShowOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + rel.getShowOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">#{msgs.form_" + bean.getName() + "_" + rel.getName() + "}</p:cell>\r\n");
}
else
{
codeChunk.addHtmlCode("\t<p:cell grayFill=\".7\" horizontalAlignment=\"left\" verticalAlignment=\"middle\" colspan=\"2\" ");
if (!rel.getShowOnDisplayIf().equals(""))
{
codeChunk.addHtmlCode("rendered=\"#{" + rel.getShowOnDisplayIf() + "}\"");
}
codeChunk.addHtmlCode(">#{msgs.form_" + bean.getName() + "_" + rel.getName() + "}</p:cell>\r\n");
}
codeChunk.addHtmlCode(relationshipPrint(bean.getName(), rel));
codeChunk.setOrder(rel.getOrderInForm());
codeChunks.add(codeChunk);
}
}
CodeChunk chunks[] = codeChunks.toArray(new CodeChunk[0]);
Arrays.sort(chunks, new CodeChunkComparator());
for (int i = 0; i < chunks.length; i++)
{
rows += chunks[i].getHtmlCode();
}
HashMap<String, String> tags = new HashMap<String, String>();
tags.put("@Bean", bean.getName());
tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
tags.put("@Rows", rows);
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetForm);
}
/**
* Definisce per ciascuna delle colonne la dimensione della relativa colonna nella lista
*
*
* **/
private static String listColumnWidths(Vector<ShowAttribute> showAttributes, boolean commandColumn)
{
String ret = "";
if (commandColumn)
{
ret = "1%,"; // La prima colonna e' quella che contiene l'icona con le azioni
}
int idx = 1;
for (int i = 0; i < showAttributes.size(); i++)
{
ShowAttribute attribute = showAttributes.get(i);
if (!attribute.isKey())
{
if (i > 0)
ret += ",";
ret += attribute.getWidth();
}
}
return ret;
}
/**
* Definisce per ciascuna delle colonne la classe da utilizzare
* per allineare a destra, a sinistra o al centro il contenuto
*
* **/
private static String listColumnClasses(Vector<ShowAttribute> showAttributes, boolean commandColumn)
{
String columnClasses = "";
if (commandColumn)
{
columnClasses = "dataColumnCenterAlignment,"; // La prima colonna e' quella che contiene l'icona con le azioni
}
// Campi da visualizzare del bean
int idx = 1;
for (int i = 0; i < showAttributes.size(); i++)
{
ShowAttribute attribute = showAttributes.get(i);
if (!attribute.isKey())
{
if (i > 0)
columnClasses += ",";
if (!attribute.belongsToRelationship())
{
// Attributi del bean
if (attribute.getIconValues().size() == 0)
{
if (attribute.getType().equals("java.lang.String"))
{
columnClasses += "dataColumnLeftAlignment";
}
if (attribute.getType().equals("java.lang.Boolean"))
{
columnClasses += "dataColumnCenterAlignment";
}
if (attribute.getType().equals("java.util.Date"))
{
columnClasses += "dataColumnCenterAlignment";
}
if (attribute.getType().equals("java.lang.Double"))
{
columnClasses += "dataColumnRightAlignment";
}
if (attribute.getType().equals("java.lang.Long"))
{
columnClasses += "dataColumnRightAlignment";
}
if (attribute.getType().equals("java.lang.Integer"))
{
columnClasses += "dataColumnRightAlignment";
}
}
else
{
columnClasses += "dataColumnCenterAlignment";
}
idx += 2;
}
else
{
// Attributi dei bean collegati da relazioni
if (attribute.getRelationship().isToMany())
{
if (attribute.getType().equals("java.lang.String"))
{
columnClasses += "dataColumnLeftAlignment";
}
if (attribute.getType().equals("java.lang.Boolean"))
{
columnClasses += "dataColumnCenterAlignment";
}
if (attribute.getType().equals("java.util.Date"))
{
columnClasses += "dataColumnCenterAlignment";
}
if (attribute.getType().equals("java.lang.Double"))
{
columnClasses += "dataColumnRightAlignment";
}
if (attribute.getType().equals("java.lang.Long"))
{
columnClasses += "dataColumnRightAlignment";
}
if (attribute.getType().equals("java.lang.Integer"))
{
columnClasses += "dataColumnRightAlignment";
}
}
else
{
if (attribute.getType().equals("java.lang.String"))
{
columnClasses += "dataColumnLeftAlignment";
}
if (attribute.getType().equals("java.lang.Boolean"))
{
columnClasses += "dataColumnCenterAlignment";
}
if (attribute.getType().equals("java.util.Date"))
{
columnClasses += "dataColumnCenterAlignment";
}
if (attribute.getType().equals("java.lang.Double"))
{
columnClasses += "dataColumnRightAlignment";
}
if (attribute.getType().equals("java.lang.Long"))
{
columnClasses += "dataColumnRightAlignment";
}
if (attribute.getType().equals("java.lang.Integer"))
{
columnClasses += "dataColumnRightAlignment";
}
idx += 2;
}
}
}
}
return columnClasses;
}
/**
* Costruice le colonne della tabella da visualizzare
*/
private static String listColumns(String beanName, Vector<ShowAttribute> showAttributes)
{
String rows = "";
// Campi da visualizzare del bean
int idx = 1;
for (int i = 0; i < showAttributes.size(); i++)
{
ShowAttribute attribute = showAttributes.get(i);
if (!attribute.isKey())
{
rows += "<rich:column";
// /** Gestione allineamento colonne in funzione del tipo di dato **/
//
// if (attribute.getType().contains("Double") || attribute.getType().contains("Integer") || attribute.getType().contains("Long"))
// {
// rows += " align=\"right\" ";
// }
//
// if (attribute.getType().contains("String"))
// {
// rows += " align=\"left\" ";
// }
//
// if (attribute.getType().contains("Date") || attribute.getType().contains("Boolean"))
// {
// rows += " align=\"center\" ";
// }
//
rows += ">\r\n";
if (!attribute.belongsToRelationship())
{
// Attributi del bean
rows += "\t<f:facet name=\"header\">\r\n";
rows += "\t\t<h:panelGroup style=\"white-space: nowrap;\">\r\n";
rows += "\t\t\t<h:outputText value=\"#{msgs.list_" + beanName + attribute.SeamLabel() + "}\" />\r\n";
rows += "\t\t\t<a4j:region>\r\n";
rows += "\t\t\t<a4j:commandButton action=\"#{" + beanName + "Manager.orderBy" + (i + 1) + "A}\" image=\"../img/asc.gif\" rendered=\"#{order!=" + (idx) + "}\" ajaxSingle=\"true\" reRender=\"" + Utils.makeFirstLetterLowerCase(beanName) + "\"/>\r\n";
rows += "\t\t\t<a4j:commandButton action=\"#{" + beanName + "Manager.orderBy" + (i + 1) + "A}\" image=\"../img/asc_selected.gif\" rendered=\"#{order==" + (idx) + "}\" ajaxSingle=\"true\" reRender=\"" + Utils.makeFirstLetterLowerCase(beanName) + "\"/>\r\n";
rows += "\t\t\t<a4j:commandButton action=\"#{" + beanName + "Manager.orderBy" + (i + 1) + "D}\" image=\"../img/desc.gif\" rendered=\"#{order!=" + (idx + 1) + "}\" ajaxSingle=\"true\" reRender=\"" + Utils.makeFirstLetterLowerCase(beanName) + "\"/>\r\n";
rows += "\t\t\t<a4j:commandButton action=\"#{" + beanName + "Manager.orderBy" + (i + 1) + "D}\" image=\"../img/desc_selected.gif\" rendered=\"#{order==" + (idx + 1) + "}\" ajaxSingle=\"true\" reRender=\"" + Utils.makeFirstLetterLowerCase(beanName) + "\"/>\r\n";
rows += "\t\t\t<a4j:status><f:facet name=\"start\"><h:graphicImage value=\"../img/spinner.gif\"/></f:facet></a4j:status>\r\n";
rows += "\t\t\t</a4j:region>\r\n";
rows += "\t\t</h:panelGroup>\r\n";
rows += "\t</f:facet>\r\n";
if (attribute.getIconValues().size() == 0)
{
if (!attribute.isTrans())
{
rows += "\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\"";
if (attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
rows += " escape=\"false\" ";
rows += " >\r\n";
}
else
{
if (attribute.getTransientParameters().equals(""))
{
rows += "\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" >\r\n";
}
else
{
rows += "\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + Utils.makeGet(attribute.getName()) + "(" + attribute.getTransientParameters() + ")}\" >\r\n";
}
}
if (attribute.getType().equals("java.util.Date") && !attribute.isListFormatOff())
{
rows += "\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n";
}
if (attribute.getType().equals("java.lang.Double") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"DoubleConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Long") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"LongConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Integer") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"IntegerConverter\" />\r\n";
}
rows += "\t</h:outputText>\r\n";
}
else
{
Vector<String> values = attribute.getIconValues();
for (int k = 0; k < values.size(); k++)
{
rows += "\t<h:graphicImage url=\"../img/" + attribute.getIcons().get(k) + "\" rendered=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "==" + values.get(k) + "}\" />\r\n";
}
}
idx += 2;
rows += "</rich:column>\r\n\r\n";
}
else
{
// Attributi dei bean collegati da relazioni
if (attribute.getRelationship().isToMany())
{
// rows += "<rich:column>\r\n";
rows += "\t<f:facet name=\"header\" style=\"white-space: nowrap;\">\r\n";
rows += "\t\t\t<h:outputText value=\"#{msgs.list_" + beanName;
rows += "_" + attribute.getRelationships().get(0).getName();
//rows += attribute.SeamLabel() + "}\" styleClass = \"noWrap\" />\r\n";
rows += attribute.SeamLabel() + "}\" />\r\n";
rows += "\t</f:facet>\r\n";
// Celle senza bordi
rows += "\t<rich:dataTable verticalGridVisible=\"false\" horizontalGridVisible=\"true\" var=\"" + Utils.makeMethod2Field(attribute.getRelationship().getName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + Utils.makeMethod2Field(attribute.getRelationship().getName()) + "}\" >\r\n";
rows += "\t\t\t<rich:column";
// if (attribute.getType().contains("Double") || attribute.getType().contains("Integer") || attribute.getType().contains("Long"))
// {
// rows += " align=\"right\" ";
// }
//
// if (attribute.getType().contains("String"))
// {
// rows += " align=\"left\" ";
// }
//
// if (attribute.getType().contains("Date") || attribute.getType().contains("Boolean"))
// {
// rows += " align=\"center\" ";
// }
// Celle senza bordi
//rows += ">\r\n";
rows += " style=\"background-color: transparent; border-left-style: none; border-right-style: none;\" >\r\n";
rows += "\t\t\t<h:outputText value=\"#{" + Utils.makeMethod2Field(attribute.getRelationship().getName()) + attribute.SeamField() + "}\" >\r\n";
if (attribute.getType().equals("java.util.Date"))
{
rows += "\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n";
}
if (attribute.getType().equals("java.lang.Double") && !attribute.isListFormatOff())
{
rows += "\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Long") && !attribute.isListFormatOff())
{
rows += "\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Integer") && !attribute.isListFormatOff())
{
rows += "\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n";
}
rows += "\t\t\t</h:outputText>\r\n";
rows += "\t\t</rich:column>\r\n";
rows += "\t</rich:dataTable>\r\n";
rows += "</rich:column>\r\n\r\n";
}
else
{
rows += "\t<f:facet name=\"header\">\r\n";
rows += "\t\t<h:panelGroup style=\"white-space: nowrap;\">\r\n";
rows += "\t\t\t<h:outputText value=\"#{msgs.list_" + beanName;
rows += "_" + attribute.getRelationships().get(0).getName();
rows += attribute.SeamLabel() + "}\" />\r\n";
rows += "\t\t\t<a4j:region>\r\n";
rows += "\t\t\t<a4j:commandButton action=\"#{" + beanName + "Manager.orderBy" + (i + 1) + "A}\" image=\"../img/asc.gif\" rendered=\"#{order!=" + (idx) + "}\" ajaxSingle=\"true\" reRender=\"" + Utils.makeFirstLetterLowerCase(beanName) + "\"/>\r\n";
rows += "\t\t\t<a4j:commandButton action=\"#{" + beanName + "Manager.orderBy" + (i + 1) + "A}\" image=\"../img/asc_selected.gif\" rendered=\"#{order==" + (idx) + "}\" ajaxSingle=\"true\" reRender=\"" + Utils.makeFirstLetterLowerCase(beanName) + "\"/>\r\n";
rows += "\t\t\t<a4j:commandButton action=\"#{" + beanName + "Manager.orderBy" + (i + 1) + "D}\" image=\"../img/desc.gif\" rendered=\"#{order!=" + (idx + 1) + "}\" ajaxSingle=\"true\" reRender=\"" + Utils.makeFirstLetterLowerCase(beanName) + "\"/>\r\n";
rows += "\t\t\t<a4j:commandButton action=\"#{" + beanName + "Manager.orderBy" + (i + 1) + "D}\" image=\"../img/desc_selected.gif\" rendered=\"#{order==" + (idx + 1) + "}\" ajaxSingle=\"true\" reRender=\"" + Utils.makeFirstLetterLowerCase(beanName) + "\"/>\r\n";
rows += "\t\t\t<a4j:status><f:facet name=\"start\"><h:graphicImage value=\"../img/spinner.gif\"/></f:facet></a4j:status>\r\n";
rows += "\t\t\t</a4j:region>\r\n";
rows += "\t\t</h:panelGroup>\r\n";
rows += "\t</f:facet>\r\n";
rows += "\t<h:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(beanName);
for (int k = 0; k < attribute.getRelationships().size(); k++)
rows += "." + Utils.makeMethod2Field(attribute.getRelationships().get(k).getName());
rows += "." + attribute.getName() + "}\" >\r\n";
if (attribute.getType().equals("java.util.Date") && !attribute.isListFormatOff())
{
rows += "\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n";
}
if (attribute.getType().equals("java.lang.Double") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"DoubleConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Long") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"LongConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Integer") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"IntegerConverter\" />\r\n";
}
rows += "\t</h:outputText>\r\n";
idx += 2;
rows += "</rich:column>\r\n\r\n";
}
}
}
}
return rows;
}
/**
* Costruice i titoli delle colonne per la lista da stampare
*/
private static String listColumnsTitlesPrint(String beanName, Vector<ShowAttribute> showAttributes)
{
String titles = "";
// Campi da visualizzare del bean
for (int i = 0; i < showAttributes.size(); i++)
{
ShowAttribute attribute = showAttributes.get(i);
if (!attribute.isKey())
{
if (!attribute.belongsToRelationship())
{
// Attributi del bean
titles += "<p:cell grayFill=\".7\" verticalAlignment=\"middle\"><p:paragraph alignment=\"center\">";
titles += "#{msgs.list_" + beanName + attribute.SeamLabel() + "}";
titles += "</p:paragraph></p:cell>\r\n";
}
else
{
// Attributi dei bean collegati da relazioni
titles += "<p:cell grayFill=\".7\" verticalAlignment=\"middle\"><p:paragraph alignment=\"center\">";
titles += "#{msgs.list_" + beanName + "_" + attribute.getRelationships().get(0).getName() + attribute.SeamLabel() + "}";
titles += "</p:paragraph></p:cell>\r\n";
}
}
}
return titles;
}
/**
* Costruice le colonne della tabella da visualizzare per la lista da
* stampare
*/
private static String listColumnsPrint(String beanName, Vector<ShowAttribute> showAttributes)
{
String rows = "";
// Campi da visualizzare del bean
for (int i = 0; i < showAttributes.size(); i++)
{
ShowAttribute attribute = showAttributes.get(i);
if (!attribute.isKey())
{
if (!attribute.belongsToRelationship())
{
// Attributi del bean
rows += "<p:cell verticalAlignment=\"middle\" horizontalAlignment=\"";
if (attribute.getType().equals("java.util.Date") || attribute.getType().equals("java.lang.Boolean"))
rows += "center";
else
{
if (attribute.getType().equals("java.lang.String"))
rows += "left";
else
rows += "right";
}
rows += "\">";
rows += "<p:paragraph><p:text ";
if (!attribute.isTrans())
{
rows += "value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" >\r\n";
}
else
{
if (attribute.getTransientParameters().equals(""))
{
rows += "value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + attribute.SeamField() + "}\" >\r\n";
}
else
{
rows += "value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + Utils.makeGet(attribute.getName()) + "(" + attribute.getTransientParameters() + ")}\" >\r\n";
}
}
if (attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
{
rows += "\t\t<f:converter converterId=\"Html2PdfConverter\" />\r\n";
}
if (attribute.getType().equals("java.util.Date") && !attribute.isListFormatOff())
{
rows += "\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n";
}
if (attribute.getType().equals("java.lang.Double") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"DoubleConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Long") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"LongConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Integer") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"IntegerConverter\" />\r\n";
}
rows += "</p:text>";
rows += "</p:paragraph></p:cell>\r\n";
}
else
{
// Attributi dei bean collegati da relazioni
if (attribute.getRelationship().isToMany())
{
rows += "<p:cell verticalAlignment=\"middle\"><p:paragraph>\r\n";
rows += "\t<ui:repeat value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + Utils.makeMethod2Field(attribute.getRelationship().getName()) + "}\" var=\"" + Utils.makeMethod2Field(attribute.getRelationship().getName()) + "\">\r\n";
rows += "\t\t<p:paragraph><p:text ";
rows += "value=\"#{" + Utils.makeMethod2Field(attribute.getRelationship().getName()) + attribute.SeamField() + "}\" >\r\n";
if (attribute.getType().equals("java.util.Date") && !attribute.isListFormatOff())
{
rows += "\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n";
}
if (attribute.getType().equals("java.lang.Double") && !attribute.isListFormatOff())
{
rows += "\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Long") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"LongConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Integer") && !attribute.isListFormatOff())
{
//rows += "\t\t\t<f:convertNumber integerOnly=\"true\" groupingUsed=\"true\" locale=\"IT_it\" />\r\n";
rows += "\t\t<f:converter converterId=\"IntegerConverter\" />\r\n";
}
rows += "\t\t</p:text></p:paragraph>\r\n";
rows += "\t</ui:repeat>\r\n";
rows += "</p:paragraph></p:cell>\r\n";
}
else
{
rows += "<p:cell verticalAlignment=\"middle\"><p:paragraph><p:text ";
rows += "value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + Utils.makeMethod2Field(attribute.getRelationships().get(0).getName()) + attribute.SeamField() + "}\" >\r\n";
if (attribute.getType().equals("java.util.Date"))
{
rows += "\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n";
}
if (attribute.getType().equals("java.lang.Double") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"DoubleConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Long") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"LongConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Integer") && !attribute.isListFormatOff())
{
rows += "\t\t<f:converter converterId=\"IntegerConverter\" />\r\n";
}
rows += "</p:text>";
rows += "</p:paragraph></p:cell>\r\n";
}
}
}
}
return rows;
}
/**
* Inserisce i campi delle relazioni nel form del bean da stampare
*/
private static String relationshipPrint(String beanName, Relationship rel)
{
String rows = "";
Vector<ShowAttribute> relatedAttributes = rel.getRelatedAttributes();
if (!rel.isListBox() || (rel.isListBox() && rel.isToMany()))
{
/** Implementazione come POPUP o come ListBox a valori multipli **/
// Tabella con i dettagli
rows += "\t\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" colspan=\"2\" ";
if (!rel.getShowOnDisplayIf().equals(""))
{
rows += "rendered=\"#{" + rel.getShowOnDisplayIf() + "}\"";
}
rows += " >\r\n";
rows += "\t\t<p:table columns=\"" + rel.getRelatedAttributes().size() + "\" headerRows=\"1\" widthPercentage=\"100\">\r\n";
// Scrive i titoli
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
ShowAttribute attr = rel.getRelatedAttributes().get(i);
rows += "\t\t\t<p:cell grayFill=\".7\" verticalAlignment=\"middle\"><p:paragraph>";
rows += "<p:text value=\"#{msgs.form_" + beanName + "_" + rel.getName();
for (int k = 0; k < attr.getRelationships().size(); k++)
{
rows += "_";
rows += attr.getRelationships().get(k).getName();
}
rows += "_" + attr.getName();
rows += "}\" /></p:paragraph></p:cell>\r\n";
}
// Scrive le righe
if (rel.isToMany())
rows += "\t\t\t<ui:repeat value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" var=\"" + Utils.makeMethod2SingularField(rel.getName()) + "\">\r\n";
else
rows += "\t\t\t<ui:repeat value=\"#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + Utils.makeMethod2Field(rel.getName()) + "}\" var=\"" + Utils.makeMethod2Field(rel.getName()) + "\">\r\n";
for (int i = 0; i < rel.getRelatedAttributes().size(); i++)
{
ShowAttribute attr = rel.getRelatedAttributes().get(i);
if (attr.getRelationships().size() == 0)
{
if (rel.isToMany())
rows += "\t\t\t\t<p:cell verticalAlignment=\"middle\"><p:paragraph><p:text value=\"#{" + Utils.makeMethod2SingularField(rel.getName()) + "." + attr.getName() + "}\" >";
else
rows += "\t\t\t\t<p:cell verticalAlignment=\"middle\"><p:paragraph><p:text value=\"#{" + Utils.makeMethod2Field(rel.getName()) + "." + attr.getName() + "}\" >";
if (attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
{
rows += "\t\t<f:converter converterId=\"Html2PdfConverter\" />\r\n";
}
if (attr.getType().equals("java.util.Date"))
{
rows += "\r\n\t\t\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n";
}
if (attr.getType().equals("java.lang.Double") && !attr.isListFormatOff())
{
rows += "\r\n\t\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n\t\t\t\t";
}
if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
{
rows += "\r\n\t\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n\t\t\t\t";
}
if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
{
rows += "\r\n\t\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n\t\t\t\t";
}
rows += "</p:text>";
rows += "</p:paragraph></p:cell>\r\n";
}
else
{
rows += "\t\t\t\t<p:cell verticalAlignment=\"middle\" ";
if (!rel.getShowOnDisplayIf().equals(""))
{
rows += "rendered=\"#{" + rel.getShowOnDisplayIf() + "}\"";
}
rows += ">";
if (rel.isToMany())
rows += "<p:paragraph><p:text value=\"#{" + Utils.makeMethod2SingularField(rel.getName()) + ".";
else
rows += "<p:paragraph><p:text value=\"#{" + Utils.makeMethod2Field(rel.getName()) + ".";
for (int k = 0; k < attr.getRelationships().size(); k++)
{
if (k > 0)
rows += ".";
rows += Utils.makeMethod2Field(attr.getRelationships().get(k).getName());
}
rows += "." + attr.getName() + "}\" >";
// System.out.println(attr.getName()+" --- "+attr.getType());
if (attr.getType().equals("java.util.Date") && !attr.isListFormatOff())
{
rows += "\r\n\t\t\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\r\n\t\t\t\t";
}
if (attr.getType().equals("java.lang.Double") && !attr.isListFormatOff())
{
rows += "\r\n\t\t\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n\t\t\t\t";
}
if (attr.getType().equals("java.lang.Long") && !attr.isListFormatOff())
{
rows += "\r\n\t\t\t\t\t<f:converter converterId=\"LongConverter\" />\r\n\t\t\t\t";
}
if (attr.getType().equals("java.lang.Integer") && !attr.isListFormatOff())
{
rows += "\r\n\t\t\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n\t\t\t\t";
}
rows += "</p:text>";
rows += "</p:paragraph></p:cell>\r\n";
}
}
rows += "\t\t\t</ui:repeat>\r\n";
rows += "\t\t</p:table>\r\n";
rows += "\t\t</p:cell>\r\n";
}
else
{
/** Implementazione come LISTBOX **/
rows += "\t<p:cell horizontalAlignment=\"justify\" verticalAlignment=\"middle\" ";
if (!rel.getShowOnDisplayIf().equals(""))
{
rows += "rendered=\"#{" + rel.getShowOnDisplayIf() + "}\"";
}
rows += ">";
for (ShowAttribute attribute : relatedAttributes)
{
if (!attribute.getType().equals("java.lang.String"))
rows += "<p:text>";
rows += "#{" + Utils.makeFirstLetterLowerCase(beanName) + "." + Utils.makeMethod2Field(rel.getName()) + "." + attribute.getName() + "} ";
if (attribute.getType().equals("java.util.Date") && !attribute.isListFormatOff())
{
rows += "\t\t\t<f:convertDateTime pattern=\"#{msgs.Application_DateFormat}\" />\t\t\t";
}
if (attribute.getType().equals("java.lang.Double") && !attribute.isListFormatOff())
{
rows += "\t\t\t<f:converter converterId=\"DoubleConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Long") && !attribute.isListFormatOff())
{
rows += "\t\t\t<f:converter converterId=\"LongConverter\" />\r\n";
}
if (attribute.getType().equals("java.lang.Integer") && !attribute.isListFormatOff())
{
rows += "\t\t\t<f:converter converterId=\"IntegerConverter\" />\r\n";
}
if (!attribute.getType().equals("java.lang.String"))
rows += "</p:text>";
}
rows += "\t</p:cell>\r\n";
}
return rows;
}
/**
* Genera l'area per la ricerca locale nella pagina list del bean
*/
private static CodeChunk localSearch(Bean bean) throws IOException
{
Vector<CodeChunk> codeChunks = new Vector<CodeChunk>();
CodeChunk ret = new CodeChunk(0);
Vector<SearchAttribute> localSearchAttributes = bean.getLocalSearchAttributes();
if (localSearchAttributes.size() == 0)
return ret;
ret.addHtmlCode("<!-- Local Search -->\r\n");
ret.addHtmlCode("<h:form>\r\n");
ret.addHtmlCode("\t<h:panelGroup layout=\"block\" style=\"width:100%;text-align:right;\">\r\n");
ret.addHtmlCode("\t<rich:toggleControl for=\"localSearch\" >\r\n");
ret.addHtmlCode("\t\t<a4j:commandButton id=\"localSearchPic\" image=\"../img/search.gif\" action=\"#{" + bean.getName() + "Manager.startLocalSearch()}\" />\r\n");
ret.addHtmlCode("\t</rich:toggleControl>\r\n");
ret.addHtmlCode("\t</h:panelGroup>\r\n");
ret.addHtmlCode("\t<rich:togglePanel id=\"localSearch\" switchType=\"client\" stateOrder=\"closed,opened\" >\r\n");
ret.addHtmlCode("\t\t<f:facet name=\"closed\">\r\n");
ret.addHtmlCode("\t\t\t<rich:spacer height=\"1\" />\r\n");
ret.addHtmlCode("\t\t</f:facet>\r\n");
ret.addHtmlCode("\t\t<f:facet name=\"opened\">\r\n");
ret.addHtmlCode("\t\t\t<rich:panel>\r\n");
ret.addHtmlCode("\t\t\t<rich:panel>\r\n");
ret.addHtmlCode("\t\t\t\t<h:panelGrid columns=\"" + java.lang.Math.min(6, 2 * localSearchAttributes.size()) + "\" width=\"100%\" >\r\n");
CodeChunk chunks[] = codeChunks.toArray(new CodeChunk[0]);
/** Inserimento dei campi * */
codeChunks.clear();
for (int i = 0; i < localSearchAttributes.size(); i++)
{
SearchAttribute attr = localSearchAttributes.get(i);
CodeChunk chunk = new CodeChunk(attr.getOrderInForm());
if (attr.belongsToRelationship())
{
if (attr.getRelationship().isToMany())
{
// Attributo di ricerca appartiene ad una relazione :N
chunk.HtmlNewLine();
chunk.addHtmlCode("\t\t\t\t\t<h:outputLabel value=\"#{msgs.localSearch_" + bean.getName() + "_" + attr.getRelationship().getName() + "_" + attr.getName() + "}\" styleClass=\"formFieldLabel\" />\r\n");
chunk.addHtmlCode("\t\t\t\t\t<h:selectManyListbox value=\"#{" + bean.getName() + "Manager." + attr.getRelationship().getFromBeanName() + "Manager.localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "}\" ");
// Inserisce gli eventuali eventi presenti
Vector<String> events = attr.getEvents();
Vector<String> eventFunctions = attr.getEventFunctions();
for (int k = 0; k < events.size(); k++)
{
chunk.addHtmlCode(events.get(k) + "=" + "\"" + eventFunctions.get(k) + "\"");
}
chunk.addHtmlCode(" styleClass=\"formField\" >");
chunk.addHtmlCode("\t\t\t\t\t\t<s:selectItems value=\"#{" + attr.getRelationship().getToBeanName() + "Manager.getSelectionItems(false," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + attr.getRelationship().getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(attr.getRelationship().getToBeanName()) + "\" ");
chunk.addHtmlCode("label=\"");
for (int k = 0; k < attr.getRelationship().getRelatedAttributes().size(); k++)
{
if (k > 0)
chunk.addHtmlCode(" - ");
chunk.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(attr.getRelationship().getToBeanName()) + "." + attr.getRelationship().getRelatedAttributes().get(k).getName() + "}");
}
chunk.addHtmlCode("\"");
chunk.addHtmlCode("/>\r\n");
chunk.addHtmlCode("\t\t\t\t\t</h:selectManyListbox>\r\n");
}
else
{
// Attributo di ricerca appartiene ad una relazione :1
chunk.HtmlNewLine();
chunk.addHtmlCode("\t\t\t\t\t<h:outputLabel value=\"#{msgs.localSearch_" + bean.getName() + "_" + attr.getRelationship().getName() + "_" + attr.getName() + "}\" styleClass=\"formFieldLabel\" />\r\n");
chunk.addHtmlCode("\t\t\t\t\t<h:selectOneMenu value=\"#{" + bean.getName() + "Manager.localSearch" + attr.getRelationship().getName() + Utils.makeFirstLetterUpperCase(attr.getName()) + "}\" ");
// Inserisce gli eventuali eventi presenti
Vector<String> events = attr.getEvents();
Vector<String> eventFunctions = attr.getEventFunctions();
for (int k = 0; k < events.size(); k++)
{
chunk.addHtmlCode(events.get(k) + "=" + "\"" + eventFunctions.get(k) + "\"");
}
chunk.addHtmlCode(" styleClass=\"formField\" >\r\n");
chunk.addHtmlCode("\t\t\t\t\t\t<s:selectItems value=\"#{" + attr.getRelationship().getToBeanName() + "Manager.getSelectionItems(false," + Utils.makeFirstLetterLowerCase(bean.getName()) + ",'" + attr.getRelationship().getName() + "')}\" var=\"" + Utils.makeFirstLetterLowerCase(attr.getRelationship().getToBeanName()) + "\" ");
chunk.addHtmlCode("label=\"");
for (int k = 0; k < attr.getRelationship().getRelatedAttributes().size(); k++)
{
ShowAttribute relatedAttribute = attr.getRelationship().getRelatedAttributes().get(k);
if (relatedAttribute.getRelationships().size() == 0)
{
if (k > 0)
chunk.addHtmlCode(" - ");
chunk.addHtmlCode("#{" + Utils.makeFirstLetterLowerCase(attr.getRelationship().getToBeanName()) + "." + relatedAttribute.getName() + "}");
}
else
{
/** Debbono essere gestiti gli attributi provenienti da relazioni **/
}
}
chunk.addHtmlCode("\"");
chunk.addHtmlCode(" noSelectionLabel=\"#{msgs.Application_noSelectionLabel}\" hideNoSelectionLabel=\"false\" />\r\n");
//chunk.addHtmlCode(" />\r\n");
chunk.addHtmlCode("\t\t\t\t\t\t<s:convertEntity />\r\n");
chunk.addHtmlCode("\t\t\t\t\t</h:selectOneMenu>\r\n");
}
}
else
{
if (attr.getImplementationType() == AttributeImplementationType.TEXT || attr.getImplementationType() == AttributeImplementationType.TEXTAREA || attr.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
{
chunk.HtmlNewLine();
chunk.addHtmlCode("\t\t\t\t\t<h:outputLabel value=\"#{msgs.localSearch_" + bean.getName() + "_" + attr.getName() + "}\" styleClass=\"formFieldLabel\" />\r\n");
chunk.addHtmlCode("\t\t\t\t\t<h:inputText style=\"width:100%;\" value=\"#{" + bean.getName() + "Manager.localSearch" + Utils.makeFirstLetterUpperCase(attr.getName()) + "}\" styleClass=\"formField\" />");
chunk.HtmlNewLine();
}
else
chunk.addHtmlCode("TIPO DI DATO NON SUPPORTATO");
}
// chunk.addHtmlCode("\t\t\t\t</td>\r\n");
codeChunks.add(chunk);
}
chunks = codeChunks.toArray(new CodeChunk[0]);
Arrays.sort(chunks, new CodeChunkComparator());
for (int i = 0; i < chunks.length; i++)
{
// if (java.lang.Math.IEEEremainder(i, 3) == 0)
// {
// if (i > 0)
// ret.addHtmlCode("\t\t\t</tr>\r\n");
// ret.addHtmlCode("\t\t\t<tr>\r\n");
// }
ret.addHtmlCode(chunks[i].getHtmlCode());
}
ret.addHtmlCode("\t\t\t\t</h:panelGrid>\r\n");
ret.addHtmlCode("\t\t\t</rich:panel>\r\n");
ret.addHtmlCode("\t\t\t<rich:spacer height=\"5\" />\r\n");
ret.addHtmlCode("\t\t\t<h:panelGrid columns=\"2\" border=\"0\" width=\"100%\" columnClasses=\"dataColumnRightAlignment,dataColumnLeftAlignment\"> \r\n");
ret.addHtmlCode("\t\t\t\t<h:commandButton styleClass=\"formButton\" value=\"#{msgs.Application_buttonLocalSearch}\" action=\"#{" + bean.getName() + "Manager.resetList()}\" />\r\n");
ret.addHtmlCode("\t\t\t\t<h:commandButton styleClass=\"formButton\" value=\"#{msgs.Application_buttonResetLocalSearch}\" action=\"#{" + bean.getName() + "Manager.stopLocalSearch()}\" />\r\n");
ret.addHtmlCode("\t\t\t</h:panelGrid>\r\n");
ret.addHtmlCode("\t\t\t</rich:panel>\r\n");
ret.addHtmlCode("\t\t</f:facet>\r\n");
ret.addHtmlCode("\t</rich:togglePanel>\r\n");
ret.addHtmlCode("</h:form>\r\n");
return ret;
}
/**
* Genera la pagina di gestione del bean
*/
public static void generateFormPageSearch(String sourceDir, String targetDir, Bean bean) throws FileNotFoundException, IOException, Exception
{
String template = "." + File.separator + "templates" + File.separator + "Seam_SearchForm.xhtml";
String sourceForm = sourceDir + File.separator + ".." + File.separator + "html" + File.separator + "search" + File.separator + bean.getName() + "Search.xhtml";
String targetForm = targetDir + File.separator + "html" + File.separator + "search" + File.separator + bean.getName() + "Search.xhtml";
String fields = "";
String javaScript = "";
String relatedManagers = "";
// Vector<CodeChunk> codeChunks = new Vector<CodeChunk>();
CodeChunkArray codeChunks = new CodeChunkArray();
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceForm, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceForm, CustomCodeType.JSP);
// Prepara la lista dei campi
for (int i = 0; i < bean.getSearchAttributes().size(); i++)
{
SearchAttribute attribute = bean.getSearchAttributes().get(i);
/**
* I campi della ricerca non sono mai required
*/
attribute.setRequired(false);
CodeChunk codeChunk = new CodeChunk(attribute.getOrderInForm());
if (!attribute.isKey())
{
if (!attribute.belongsToRelationship())
{
codeChunk.addHtmlCode("\t<tr><td width=\"100%\">\r\n");
codeChunk.addHtmlCode("\t\t<rich:panel>\r\n");
codeChunk.addHtmlCode("\t\t\t<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\r\n");
codeChunk.addHtmlCode("\t\t\t<tr>\r\n");
codeChunk.addHtmlCode("\t\t\t<td class=\"formFieldLabel\" >\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:outputLabel for=\"" + attribute.getName() + "\" value=\"#{msgs.form_" + bean.getName() + attribute.SeamLabel() + "}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
if (attribute.getType().equals("java.lang.Boolean"))
{
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\nBOOLEAN NON SUPPORTATO\r\n");
codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
}
if (attribute.getType().equals("java.util.Date"))
{
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\nDATE NON SUPPORTATO\r\n");
codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
}
if (attribute.getImplementationType() == AttributeImplementationType.TEXTAREA)
{
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\">\r\n");
codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\nTEXT AREA NON SUPPORTATO\r\n");
codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
}
if (attribute.getImplementationType() == AttributeImplementationType.FORMATTEDTEXTAREA)
{
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\">\r\n");
codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\nFORMATTEDTEXT AREA NON SUPPORTATO\r\n");
codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
}
if (attribute.getImplementationType() == AttributeImplementationType.LISTBOX)
{
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\r\n<trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\nLIST BOX NON SUPPORTATO\r\n");
codeChunk.addHtmlCode("\r\n</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\r\n</trh:rowLayout>\r\n");
}
if (attribute.getImplementationType() == AttributeImplementationType.TEXT)
{
codeChunk.addHtmlCode("\t\t\t<td>\r\n");
codeChunk.addHtmlCode("\t\t\t\t" + insertAttribute2Form(attribute, bean.getName(), true, true) + "\r\n");
codeChunk.addHtmlCode("\t\t\t\t<br />\r\n");
codeChunk.addHtmlCode("\t\t\t\t<h:message for=\"" + attribute.getName() + "\" errorClass=\"rich-messages-label\" />\r\n");
codeChunk.addHtmlCode("\t\t\t</td>\r\n");
}
codeChunk.addHtmlCode("\t\t\t</tr>\r\n");
codeChunk.addHtmlCode("\t\t\t</table>\r\n");
codeChunk.addHtmlCode("\t\t</rich:panel>\r\n");
codeChunk.addHtmlCode("\t</td></tr>\r\n");
codeChunks.add(codeChunk);
}
else
{
// Attributo di ricerca appartenente ad una relazione
Relationship firstRelationship = attribute.getRelationship();
/**
* I campi della ricerca non sono mai required
*/
firstRelationship.setRequired(false);
if (attribute.getRelationships().size() == 1)
{
// L'attributo e' nella forma relazione.attributo
if (firstRelationship.isIgnoreImplementation())
{
// Gli attributi debbono essere inseriti come Text
if (attribute.getType().equals("java.util.Date"))
{
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" ><tr:outputLabel value=\"#{msgs.form_" + bean.getName() + "_search" + attribute.SeamLabel() + "}\" /></trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat>\r\n");
if (firstRelationship.isToMany())
{
/** Relazione :N **/
String singularRelationshipName = Utils.makeMethod2SingularField(firstRelationship.getName());
codeChunk.addHtmlCode("\t\t<rich:dataTable id=\"tab_" + singularRelationshipName + "_" + attribute.getName() + "\" var=\"" + singularRelationshipName + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(firstRelationship.getName()) + "}\" width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<rich:column");
if (attribute.getType().contains("Double") || attribute.getType().contains("Integer") || attribute.getType().contains("Long"))
{
codeChunk.addHtmlCode(" align=\"right\" ");
}
if (attribute.getType().contains("String"))
{
codeChunk.addHtmlCode(" align=\"left\" ");
}
if (attribute.getType().contains("Date") || attribute.getType().contains("Boolean"))
{
codeChunk.addHtmlCode(" align=\"center\" ");
}
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t\t\t<f:facet name=\"header\">\r\n");
codeChunk.addHtmlCode("\t\t\t\t</f:facet>\r\n");
codeChunk.addHtmlCode("\t\t\t\t<tr:inputDate id=\"" + attribute.getName() + "\" value=\"#{" + singularRelationshipName + "." + attribute.getName() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<f:convertDateTime type=\"date\" pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t</tr:inputDate>\r\n");
codeChunk.addHtmlCode("\t\t\t</rich:column>\r\n");
codeChunk.addHtmlCode("\t\t</rich:dataTable>\r\n");
}
else
{
/** Relazione :1 **/
if (attribute.getType().equals("java.util.Date"))
{
codeChunk.addHtmlCode("\t\t<tr:inputDate id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(attribute.getRelationship().getName()) + "." + attribute.getName() + "}\" >\r\n");
codeChunk.addHtmlCode("\t\t\t<f:convertDateTime type=\"date\" pattern=\"#{msgs.Application_DateFormat}\" />\r\n");
codeChunk.addHtmlCode("\t\t</tr:inputDate>\r\n");
}
else
codeChunk.addHtmlCode("\t\t\t\tTipo non supportato nella ricerca\r\n");
}
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
}
else
{
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" ><tr:outputLabel value=\"#{msgs.form_" + bean.getName() + "_search" + attribute.SeamLabel() + "}\" /></trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t\t<h:inputText id=\"" + attribute.getName() + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(firstRelationship.getName()) + attribute.SeamField() + "}\" />\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
}
}
else
{
if (firstRelationship.isListBox())
{
// Gli attributi debbono essere inseriti come listbox
if (firstRelationship.isToMany())
{
codeChunk = insertMultipleSelectionListBox2Form(bean, firstRelationship, true, true);
}
else
{
codeChunk = insertSingleSelectionListBox2Form(sourceDir, bean, firstRelationship, true, true);
}
}
else
{
// Gli attributi debbono essere inseriti come popup
if (firstRelationship.isToMany())
{
codeChunk.addJavascriptCode("function openPopUp_" + firstRelationship.getName() + "()");
codeChunk.JavascriptNewLine();
codeChunk.addJavascriptCode("{");
codeChunk.JavascriptNewLine();
codeChunk.addJavascriptCode("\twindow.open(\"popup/" + bean.getName() + firstRelationship.getName() + "PopUp.seam?parentConversationId=\"+document.forms[\"form\"].elements['parentConversationId'].value+\"&conversationIsLongRunning=true\",\"" + firstRelationship.getToBeanName() + "Window\",\"resizable=yes,menubar=no,width=850,height=550,scrollbars=yes\");");
codeChunk.JavascriptNewLine();
codeChunk.addJavascriptCode("}");
codeChunk.JavascriptNewLine();
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" >\r\n");
codeChunk.addHtmlCode("\t\t<tr:outputLabel for=\"" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + Utils.makeFirstLetterLowerCase(firstRelationship.getName()) + "\" value=\"#{msgs.form_search_" + firstRelationship.ToSeamLabel() + "}\" />\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat><trh:tableLayout><trh:rowLayout width=\"100%\" ><trh:cellFormat>\r\n");
// BOB: Genera id sui pulsanti di selezione
codeChunk.addHtmlCode("\t\t<tr:goLink id=\"popup_" + firstRelationship.getName() + "\" value=\"Seleziona\" onclick=\"openPopUp_" + firstRelationship.getName() + "();\" styleClass=\"button\" rendered=\"#{(" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='CREATE') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='EDIT') or (" + Utils.makeFirstLetterLowerCase(bean.getName()) + "Operation=='SEARCH')}\" />\r\n");
codeChunk.addHtmlCode("\t\t</trh:cellFormat><trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t\t</trh:cellFormat></trh:rowLayout></trh:tableLayout>\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat columnSpan=\"2\">\r\n");
codeChunk.addHtmlCode("\t\t<rich:dataTable id=\"tab_" + Utils.makeFirstLetterLowerCase(bean.getName()) + "_" + firstRelationship.getName() + "\" var=\"" + Utils.makeFirstLetterLowerCase(firstRelationship.getToBeanName()) + "\" value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()) + "." + Utils.makeMethod2Field(firstRelationship.getName()) + "}\" width=\"100%\" rowBandingInterval=\"1\" verticalGridVisible=\"true\" horizontalGridVisible=\"false\" >\r\n");
for (int m = 0; m < firstRelationship.getRelatedAttributes().size(); m++)
{
ShowAttribute attr = firstRelationship.getRelatedAttributes().get(m);
codeChunk.addHtmlCode("\t\t\t<rich:column");
if (attr.getType().contains("Double") || attr.getType().contains("Integer") || attr.getType().contains("Long"))
{
codeChunk.addHtmlCode(" align=\"right\" ");
}
if (attr.getType().contains("String"))
{
codeChunk.addHtmlCode(" align=\"left\" ");
}
if (attr.getType().contains("Date") || attr.getType().contains("Boolean"))
{
codeChunk.addHtmlCode(" align=\"center\" ");
}
codeChunk.addHtmlCode(">\r\n");
codeChunk.addHtmlCode("\t\t\t\t<f:facet name=\"header\">\r\n");
codeChunk.addHtmlCode("\t\t\t\t\t<h:outputText value=\"#{msgs.form_" + bean.getName());
for (int k = 0; k < attr.getRelationships().size(); k++)
{
codeChunk.addHtmlCode("_");
codeChunk.addHtmlCode(attr.getRelationships().get(k).getName());
}
codeChunk.addHtmlCode("_" + attr.getName() + "");
codeChunk.addHtmlCode("}\" />\r\n");
codeChunk.addHtmlCode("\t\t\t\t</f:facet>\r\n");
if (attr.getRelationships().size() == 0)
{
codeChunk.addHtmlCode("\t\t\t\t<tr:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(firstRelationship.getToBeanName()) + "." + attr.getName() + "}\" />\r\n");
}
else
{
codeChunk.addHtmlCode("\t\t\t\t<tr:outputText value=\"#{" + Utils.makeFirstLetterLowerCase(firstRelationship.getToBeanName()) + ".");
for (int k = 1; k < attr.getRelationships().size(); k++)
{
if (k > 1)
codeChunk.addHtmlCode(".");
codeChunk.addHtmlCode(Utils.makeMethod2Field(attr.getRelationships().get(k).getName()));
}
codeChunk.addHtmlCode("." + attr.getName());
codeChunk.addHtmlCode("}\" />\r\n");
}
codeChunk.addHtmlCode("\t\t\t</rich:column>\r\n");
}
codeChunk.addHtmlCode("\t\t</rich:dataTable>\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
}
else
{
codeChunk = insertSingleSelectionPopUp2Form(sourceDir, bean, firstRelationship, false, true);
}
}
}
}
else
{
// Attributo nella forma [relazione.]*Attributo
if (attribute.getRelationships().get(0).isIgnoreImplementation())
{
// Gli attributi debbono essere inseriti come Text
codeChunk.addHtmlCode("\r\n<trh:rowLayout width=\"100%\" >\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat styleClass=\"formFieldLabel\" >");
codeChunk.addHtmlCode("<tr:outputLabel value=\"#{msgs.form_" + bean.getName());
codeChunk.addHtmlCode("_" + attribute.getRelationships().get(0).getName());
codeChunk.addHtmlCode(attribute.SeamLabel() + "}\" /></trh:cellFormat>\r\n");
codeChunk.addHtmlCode("\t<trh:cellFormat >\r\n");
codeChunk.addHtmlCode("\t\t<tr:inputText value=\"#{" + Utils.makeFirstLetterLowerCase(bean.getName()));
for (Relationship rel : attribute.getRelationships())
{
codeChunk.addHtmlCode("." + Utils.makeMethod2Field(rel.getName()));
}
codeChunk.addHtmlCode("." + attribute.getName() + "}\" />\r\n");
codeChunk.addHtmlCode("\t</trh:cellFormat>\r\n");
codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
codeChunk.setOrder(attribute.getOrderInForm());
}
else
{
// codeChunk.setOrder(attribute.getOrderInForm());
// codeChunk.addHtmlCode("\r\n<trh:rowLayout>\r\n");
// codeChunk.addHtmlCode("\t<trh:cellFormat>NON SO
// !</trh:cellFormat>\r\n");
// codeChunk.addHtmlCode("\t\t<trh:cellFormat>NON SO
// !</trh:cellFormat>\r\n");
// codeChunk.addHtmlCode("</trh:rowLayout>\r\n");
}
}
// System.out.println(codeChunks.getHtmlCode());
// System.out.println(codeChunk.getHtmlCode());
if (!codeChunks.getHtmlCode().contains(codeChunk.getHtmlCode()))
{
codeChunk.setOrder(attribute.getOrderInForm());
codeChunks.add(codeChunk);
}
}
}
}
/** Predispone i Manager necessari per le chiamate remoting * */
relatedManagers += bean.getName() + "Manager";
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship rel = bean.getRelationships().get(i);
if (rel.isUsed())
{
relatedManagers += "&" + rel.getToBeanName() + "Manager";
}
}
CodeChunk chunks[] = codeChunks.toArray(new CodeChunk[0]);
Arrays.sort(chunks, new CodeChunkComparator());
for (int i = 0; i < chunks.length; i++)
{
javaScript += chunks[i].getJavascriptCode().replaceAll(bean.getName() + "2", "../" + bean.getName() + "2").replaceAll("popup/", "../popup/");
// int start = chunks[i].getHtmlCode().indexOf("rendered=");
// int end = chunks[i].getHtmlCode().indexOf("}",start);
//
// String renderedCondition = chunks[i].getHtmlCode().substring(start, end+2);
//
// fields += chunks[i].getHtmlCode().replace(renderedCondition, "").replaceAll(Utils.makeFirstLetterLowerCase(bean.getName())+".", Utils.makeFirstLetterLowerCase(bean.getName())+"Search.");
fields += chunks[i].getHtmlCode().replace(Utils.makeFirstLetterLowerCase(bean.getName()) + ".", Utils.makeFirstLetterLowerCase(bean.getName()) + "Search.");
}
HashMap<String, String> tags = new HashMap<String, String>();
tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));
tags.put("@Javascript", javaScript);
tags.put("@RelatedManagers", relatedManagers);
tags.put("@Bean", bean.getName());
tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
tags.put("@Rows", fields);
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetForm);
}
/**
* Genera la pagina lista risultato della ricerca
* @throws Exception
*/
public static void generateListPageSearch(String sourceDir, String targetDir, String basePackage, Bean bean) throws Exception
{
String template = "." + File.separator + "templates" + File.separator + "Seam_SearchFormList.xhtml";
String sourceFile = sourceDir + ".." + File.separator + "html" + File.separator + "search" + File.separator + bean.getName() + "SearchList.xhtml";
String targetFile = targetDir + "html" + File.separator + "search" + File.separator + bean.getName() + "SearchList.xhtml";
String columnClasses = "";
String rows = "";
String javaScript = "";
String masterButton = "";
String detailButton = "";
String selectionButton = "";
String searchButton = "";
CodeChunk localSearch;
String actions = "";
String createButtons = "";
String columnWidths = "1%";
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JSP);
// Predispone il link ai bean detail
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship rel = bean.getRelationships().get(i);
if (rel.isMasterDetail() && rel.isFromMaster())
{
detailButton += "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + rel.getToBeanName() + "}\" action=\"#{@BeanManager.goTo" + rel.getToBeanName() + "}\" style=\"text-decoration: none; color: black\" />\r\n";
}
}
// Prepara la lista dei campi
columnClasses = listColumnClasses(bean.getShowAttributes(), true); // Stile delle colonne
rows = listColumns(bean.getName(), bean.getShowAttributes()); // Colonne della tabella
if (bean.getSearchActions().size() > 0 || bean.getSearchImmediateActions().size() > 0)
{
String selectionColumn = "";
selectionColumn += "<!-- SELECTION COLUMN -->\r\n";
selectionColumn += "<rich:column>\r\n";
selectionColumn += "\t<f:facet name=\"header\"> </f:facet>\r\n";
selectionColumn += "\t<h:selectBooleanCheckbox id=\"selections\" value=\"#{selections[" + Utils.makeFirstLetterLowerCase(bean.getName()) + "]}\" />\r\n";
selectionColumn += "</rich:column>\r\n\r\n";
rows = selectionColumn + rows;
columnWidths += ",1%";
for (int i = 0; i < bean.getSearchActionLabels().size(); i++)
{
actions += "\t\t<h:commandLink immediate=\"true\" value=\"" + bean.getSearchActionLabels().get(i) + "\" action=\"#{" + bean.getName() + "Manager.init" + Utils.makeFirstLetterUpperCase(bean.getSearchActions().get(i)) + "}\" style=\"text-decoration: none; color: black\" />\r\n";
generateSearchActionPage(sourceDir, targetDir, bean, bean.getSearchActions().get(i), bean.getSearchActionLabels().get(i));
}
for (int i = 0; i < bean.getSearchImmediateActionLabels().size(); i++)
{
actions += "\t\t<h:commandLink immediate=\"true\" value=\"" + bean.getSearchImmediateActionLabels().get(i) + "\" action=\"#{" + bean.getName() + "Manager." + bean.getSearchImmediateActions().get(i) + "}\" style=\"text-decoration: none; color: black\" />\r\n";
}
}
// Predispone i bottoni di navigazione
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship rel = bean.getRelationships().get(i);
if (rel.isMasterDetail() && rel.isFromMaster() && !rel.isCategorized())
{
// Inserisce il bottone di selezione del dettaglio se la vista
// non e' categorizzata
}
if (rel.isMasterDetail() && rel.isFromMaster() && rel.isCategorized())
{
// Inserisce il di creazione del dettaglio se la vista e'
// categorizzata
}
if (rel.isMasterDetail() && !rel.isFromMaster())
{
// Inserisce il bottone di selezione del master
masterButton = "\t\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + rel.getFromBeanName() + "_" + rel.getToBeanName() + "}\" action=\"/list/" + rel.getToBeanName() + "List.seam\" style=\"text-decoration: none; color: black\" />\r\n";
}
}
// Bottone per la ricerca locale
if (bean.getSearchAttributes().size() > 1)
{
selectionButton += "\r\n\taddMenuBarItem(new menuBarItem(\"<bean:message key=\"list." + bean.getName() + ".button.search\"/>\", \"\", \"\", \"\", \"code:doSubmit('<bean:message key=\"list." + bean.getName() + ".button.search\"/>');\"));\r\n";
}
// javaScript += "function startup()\r\n";
// javaScript += "{\r\n";
// javaScript += "}\r\n";
/** Ricarca locale * */
localSearch = localSearch(bean);
javaScript += localSearch.getJavascriptCode();
// Voce menu per ricerca
if (bean.getSearchAttributes().size() > 1)
{
searchButton += "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_search}\" action=\"#{" + bean.getName() + "Manager.initSearch}\" style=\"text-decoration: none; color: black\" />\r\n";
}
// /** Opzione Nuovo **/
// if (bean.getNewMenuOptionConditionOnListSearch().equals(""))
// newMenuOptionCondition = "";
// else
// newMenuOptionCondition = "rendered=\"#{" + bean.getNewMenuOptionConditionOnListSearch() + "}\"";
// Menu creazione bean
InfoReader infoReader = new InfoReader(sourceDir);
Vector<String> derivedBeans = infoReader.getDerivedBeans(bean.getName());
if (derivedBeans.size() == 0)
{
if (bean.getNewMenuOptionConditionOnListSearch().equals(""))
createButtons = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_new}\" action=\"#{" + bean.getName() + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />\r\n";
else
createButtons = "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + bean.getName() + "_new}\" action=\"#{" + bean.getName() + "Manager.initCreate}\" rendered=\"#{" + bean.getNewMenuOptionConditionOnListSearch() + "}\" style=\"text-decoration: none; color: black\" />\r\n";
}
else
{
// Nel caso questo sia un bean padre, vengono inseriti solo i menu per
// la creazione dei bean derivati
for (String derivedBean : derivedBeans)
{
createButtons += "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + derivedBean + "_new}\" action=\"#{" + derivedBean + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />\r\n";
}
}
HashMap<String, String> tags = new HashMap<String, String>();
tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));
tags.put("@CreateButtons", createButtons);
tags.put("@Javascript", javaScript);
tags.put("@SearchButton", searchButton);
tags.put("@ColumnClasses", columnClasses);
tags.put("@MasterButton", masterButton);
tags.put("@DetailButton", detailButton);
tags.put("@Actions", actions);
tags.put("@Bean", bean.getName());
tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
tags.put("@LocalSearch", localSearch.getHtmlCode());
tags.put("@ColumnWidths", columnWidths);
tags.put("@Rows", rows);
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
}
/**
* Genera il form da chiamare prima di una azione sui bean nel risultato di una azione
*/
public static void generateSearchActionPage(String sourceDir, String targetDir, Bean bean, String action, String actionLabel) throws FileNotFoundException, IOException, Exception
{
String template = "." + File.separator + "templates" + File.separator + "Seam_SearchAction.xhtml";
String sourceForm = sourceDir + File.separator + ".." + File.separator + "html" + File.separator + "search" + File.separator + bean.getName() + Utils.makeFirstLetterUpperCase(action) + ".xhtml";
String targetForm = targetDir + File.separator + "html" + File.separator + "search" + File.separator + bean.getName() + Utils.makeFirstLetterUpperCase(action) + ".xhtml";
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceForm, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceForm, CustomCodeType.JSP);
HashMap<String, String> tags = new HashMap<String, String>();
tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));
tags.put("@ActLabel", actionLabel);
tags.put("@Bean", bean.getName());
tags.put("@bean", Utils.makeFirstLetterLowerCase(bean.getName()));
tags.put("@Action", Utils.makeFirstLetterUpperCase(action));
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetForm);
}
public static void generatePopUp(Bean bean, String sourceDir, String targetDir, String basePackage) throws Exception, FileNotFoundException, IOException, NoSuchMethodException, NamingException, ClassNotFoundException
{
InfoReader infoReader = new InfoReader(sourceDir);
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship rel = bean.getRelationships().get(i);
if (rel.isUsed() && !rel.isListBox())
{
// Genera la entry in pages per la pagina di PopUp
PagesConfig.addPopUpPage(sourceDir, targetDir, rel);
if ((!rel.isMasterDetail() || (rel.isMasterDetail() && rel.getOrderInForm() != 0)) && !rel.isToMany())
{
// Relazione a 1 implementata come popup
// Attributi nella pagina di origine
Vector<ShowAttribute> attributes = rel.getRelatedAttributes();
Vector<ShowAttribute> beanAttr = new Vector<ShowAttribute>();
beanAttr.add(new ShowAttribute(infoReader.getBeanKey(rel.getToBeanName())));
beanAttr.addAll(attributes);
// Sono aggiunti gli attributi derivanti dalle relazioni
// implementate come ListBox
Vector<Attribute> attributes1 = bean.getAttributes();
Vector<ShowAttribute> callingAttributes = new Vector<ShowAttribute>();
for (int l = 0; l < attributes1.size(); l++)
{
Attribute attr = attributes1.get(l);
if (attr.getImplementationType() != AttributeImplementationType.HIDEINFORM)
callingAttributes.add(new ShowAttribute(attributes1.get(l)));
}
/**
* Nei calling attributes ci vanno
*
* 1) Gli attributi visualizzati del bean origine
*
* 2) Gli attributi visualizzati nel bean, ereditati dal
* superbean origine (se esiste)
*
* 3) Gli attributi derivanti da relazioni implementate come
* LISTBOX
*
* 4) Gli attributi derivanti da relazioni implementate come
* LISTBOX ereditate dal superbean origine (se esiste)
*
*/
Vector<Relationship> re = bean.getRelationships();
for (int j = 0; j < re.size(); j++)
{
if (re.get(j).isListBox())
{
Attribute a = new Attribute();
a.setKey(false);
a.setName(Utils.makeFirstLetterLowerCase(re.get(j).getToBeanName()));
ShowAttribute attr = new ShowAttribute(re.get(j), a);
callingAttributes.add(attr);
}
}
Bean targetBean = infoReader.getBean(rel.getToBeanName());
/**
* generateSelectionPage2One(String sourceDir, String targetDir,
* Relationship rel, Vector<ShowAttribute>
* callingBeanAttributes, String bean, Vector<SearchAttribute>
* localSearchAttributes, Vector<ShowAttribute>
* targetBeanAttributes)
*/
HTMLGenerator.generatePopUpSingleSelection(sourceDir, targetDir, bean, rel, callingAttributes, targetBean.getLocalSearchAttributes(), beanAttr);
}
if ((!rel.isMasterDetail() || (rel.isMasterDetail() && rel.getOrderInForm() != 0)) && rel.isToMany())
{
// Relazione a n implementata come popup
// Attributi nella pagina di origine
Vector<ShowAttribute> attributes = rel.getRelatedAttributes();
Bean targetBean = infoReader.getBean(rel.getToBeanName());
Vector<Attribute> tmp = new Vector<Attribute>(bean.getAttributes());
Vector<ShowAttribute> beanAttr = new Vector<ShowAttribute>();
for (int l = 0; l < tmp.size(); l++)
{
beanAttr.add(new ShowAttribute(tmp.get(l)));
}
// Sono aggiunti gli attributi derivanti dalle relazioni
// implementate come ListBox
Vector<Relationship> re = bean.getRelationships();
for (int j = 0; j < re.size(); j++)
{
if (re.get(j).isListBox())
{
Attribute a = new Attribute();
a.setKey(false);
a.setName(Utils.makeFirstLetterLowerCase(re.get(j).getToBeanName()));
ShowAttribute attr = new ShowAttribute(re.get(j), a);
beanAttr.add(attr);
}
}
HTMLGenerator.generatePopUpMultipleSelection(sourceDir, targetDir, bean, targetBean.getLocalSearchAttributes(), rel);
}
}
}
}
public static void generatePopUpMultipleSelection(String sourceDir, String targetDir, Bean bean, Vector<SearchAttribute> localSearchAttributes, Relationship rel) throws FileNotFoundException, IOException, Exception
{
String javaScript = "";
String rows = "";
String columnClasses = "";
String hiddenAttributes = "";
String actionCreate = "";
String actionEdit = "";
String actionDelete = "";
CodeChunk localSearch;
String localSearchButton;
String relatedEJB = rel.getToBeanName();
// Vector<ShowAttribute> relatedAttributes = rel.getRelatedAttributes();
String template = "." + File.separator + "templates" + File.separator + "Seam_FormPopUp.xhtml";
String sourceFile = sourceDir + ".." + File.separator + "html" + File.separator + "popup" + File.separator + bean.getName() + rel.getName() + "PopUp.xhtml";
String targetFile = targetDir + "html" + File.separator + "popup" + File.separator + bean.getName() + rel.getName() + "PopUp.xhtml";
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JSP);
/** Funzione di inizializzazione dei campi nascosti **/
javaScript += generatePopUpJavascriptFunctionsInPopup(bean);
javaScript += "function onlyOneSelection(thisObj, event)\r\n";
javaScript += "{\r\n";
javaScript += "}\r\n";
columnClasses = listColumnClasses(rel.getRelatedAttributes(), true); // Stile delle colonne
columnClasses = "columnCenter," + columnClasses;
rows = listColumns(rel.getToBeanName(), rel.getRelatedAttributes()); // Colonne della tabella
/** Inserimento campi nascosti * */
for (int i = 0; i < bean.getAttributes().size(); i++)
{
Attribute attr = bean.getAttributes().get(i);
if (!attr.isKey() && (attr.getImplementationType() != AttributeImplementationType.HIDEINFORM) && (attr.getImplementationType() != AttributeImplementationType.READONLY))
{
hiddenAttributes += insertAttribute2Form(attr, bean.getName(), false) + "\r\n";
}
}
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship relationship = bean.getRelationships().get(i);
if (relationship.isUsed() && relationship.isListBox())
{
if (relationship.isToMany())
{
hiddenAttributes += insertMultipleSelectionListBox2Form(bean, relationship, false, true).getHtmlCode();
}
else
{
hiddenAttributes += insertSingleSelectionListBox2Form(sourceDir, bean, relationship, false, true).getHtmlCode();
}
}
}
/** Inserimento azioni previste * */
if (rel.getPopUpCreate())
{
actionCreate += "\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_new}\" action=\"#{" + relatedEJB + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />";
}
if (rel.getPopUpDelete())
{
actionDelete += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_delete}\" action=\"#{" + relatedEJB + "Manager.initDelete}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" >\r\n";
actionDelete += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
actionDelete += "\t</rich:menuItem>";
}
if (rel.getPopUpEdit())
{
actionEdit += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_edit}\" action=\"#{" + relatedEJB + "Manager.initEdit}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" >\r\n";
actionEdit += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
actionEdit += "\t</rich:menuItem>";
}
/** Ricerca locale * */
InfoReader infoReader = new InfoReader(sourceDir);
Bean targetBean = infoReader.getBean(rel.getToBeanName());
localSearch = localSearch(targetBean);
if (targetBean.getLocalSearchAttributes().size() > 0)
{
localSearchButton = "<h:commandButton styleClass=\"imageLink\" image=\"../img/search.gif\" action=\"#{" + targetBean.getName() + "Manager.startLocalSearch}\" />";
}
else
{
localSearchButton = " ";
}
javaScript += localSearch.getJavascriptCode();
HashMap<String, String> tags = new HashMap<String, String>();
if (rel.isPopUpSelectItems())
{
tags.put("@DisableSelection", "false");
}
else
{
tags.put("@DisableSelection", "true");
}
tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));
tags.put("@PopupName", "form_" + bean.getName() + "_" + rel.getName());
tags.put("@Javascript", javaScript);
tags.put("@Bean", relatedEJB);
tags.put("@bean", Utils.makeFirstLetterLowerCase(relatedEJB));
tags.put("@ColumnClasses", columnClasses);
tags.put("@Rows", rows);
tags.put("@HiddenAttributes", hiddenAttributes);
tags.put("@ActionCreate", actionCreate);
tags.put("@ActionEdit", actionEdit);
tags.put("@ActionDelete", actionDelete);
// tags.put("@LocalSearchIcon", localSearchButton);
tags.put("@LocalSearch", localSearch.getHtmlCode());
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
}
public static void generatePopUpSingleSelection(String sourceDir, String targetDir, Bean bean, Relationship rel, Vector<ShowAttribute> callingBeanAttributes, Vector<SearchAttribute> localSearchAttributes, Vector<ShowAttribute> targetBeanAttributes) throws Exception, FileNotFoundException, IOException
{
String javaScript = "";
String rows = "";
String columnClasses = "";
String hiddenAttributes = "";
String actionCreate = "";
String actionEdit = "";
String actionDelete = "";
CodeChunk localSearch;
String localSearchButton = "";
String relatedEJB = rel.getToBeanName();
String template = "." + File.separator + "templates" + File.separator + "Seam_FormPopUp.xhtml";
String sourceFile = sourceDir + ".." + File.separator + "html" + File.separator + "popup" + File.separator + bean.getName() + rel.getName() + "PopUp.xhtml";
String targetFile = targetDir + "html" + File.separator + "popup" + File.separator + bean.getName() + rel.getName() + "PopUp.xhtml";
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JSP);
/** Funzione di inizializzazione dei campi nascosti **/
javaScript += generatePopUpJavascriptFunctionsInPopup(bean);
javaScript += "function onlyOneSelection(thisObj, event)\r\n";
javaScript += "{\r\n";
javaScript += "\tidx = 0;\r\n";
javaScript += "\t\r\n";
javaScript += "\tvar element = document.getElementById(\"form:" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ":\"+idx+\":selections\");\r\n";
javaScript += "\t\r\n";
javaScript += "\twhile(element != null)\r\n";
javaScript += "\t{\r\n";
javaScript += "\t\tif (element != thisObj && element.checked)\r\n";
javaScript += "\t\t{\r\n";
javaScript += "\t\t\telement.checked = false;\r\n";
javaScript += "\t\t}\r\n";
javaScript += "\t\tidx++;\r\n";
javaScript += "\t\telement = document.getElementById(\"form:" + Utils.makeFirstLetterLowerCase(rel.getToBeanName()) + ":\"+idx+\":selections\");\r\n";
javaScript += "\t}\r\n";
javaScript += "}\r\n";
columnClasses = listColumnClasses(rel.getRelatedAttributes(), true); // Stile delle colonne
rows = listColumns(rel.getToBeanName(), rel.getRelatedAttributes()); // Colonne della tabella
/** Inserimento campi nascosti * */
for (int i = 0; i < bean.getAttributes().size(); i++)
{
Attribute attr = bean.getAttributes().get(i);
if (!attr.isKey() && (attr.getImplementationType() != AttributeImplementationType.HIDEINFORM) && (attr.getImplementationType() != AttributeImplementationType.READONLY))
{
hiddenAttributes += insertAttribute2Form(attr, bean.getName(), false) + "\r\n";
}
}
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship relationship = bean.getRelationships().get(i);
if (relationship.isUsed() && relationship.isListBox())
{
if (relationship.isToMany())
{
hiddenAttributes += insertMultipleSelectionListBox2Form(bean, relationship, false, true).getHtmlCode();
}
else
{
hiddenAttributes += insertSingleSelectionListBox2Form(sourceDir, bean, relationship, false, true).getHtmlCode();
}
}
}
/** Inserimento azioni previste * */
if (rel.getPopUpCreate())
{
actionCreate += "\t\t\t<h:commandLink immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_new}\" action=\"#{" + relatedEJB + "Manager.initCreate}\" style=\"text-decoration: none; color: black\" />";
}
if (rel.getPopUpDelete())
{
actionDelete += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_delete}\" action=\"#{" + relatedEJB + "Manager.initDelete}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" >\r\n";
actionDelete += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
actionDelete += "\t</rich:menuItem>";
}
if (rel.getPopUpEdit())
{
actionEdit += "\t<rich:menuItem immediate=\"true\" value=\"#{msgs.list_" + relatedEJB + "_edit}\" action=\"#{" + relatedEJB + "Manager.initEdit}\" actionListener=\"#{@BeanManager.popupMenuSelectItem}\" >\r\n";
actionEdit += "\t\t<a4j:actionparam name=\"selectedId\" value=\"{selectedBean}\" />\r\n";
actionEdit += "\t</rich:menuItem>";
}
/** Ricarca locale * */
InfoReader infoReader = new InfoReader(sourceDir);
Bean targetBean = infoReader.getBean(rel.getToBeanName());
localSearch = localSearch(targetBean);
if (targetBean.getLocalSearchAttributes().size() > 0)
{
localSearchButton = "<h:commandButton styleClass=\"imageLink\" image=\"../img/search.gif\" action=\"#{" + targetBean.getName() + "Manager.startLocalSearch}\" />";
}
else
{
localSearchButton = " ";
}
javaScript += localSearch.getJavascriptCode();
HashMap<String, String> tags = new HashMap<String, String>();
if (rel.isPopUpSelectItems())
{
tags.put("@DisableSelection", "false");
}
else
{
tags.put("@DisableSelection", "true");
}
tags.put("@generatorVersion", Messages.getString("WebAppGen.applicationVersion"));
tags.put("@PopupName", "form_" + bean.getName() + "_" + rel.getName());
tags.put("@Javascript", javaScript);
tags.put("@Bean", relatedEJB);
tags.put("@bean", Utils.makeFirstLetterLowerCase(relatedEJB));
tags.put("@ColumnClasses", columnClasses);
tags.put("@Rows", rows);
tags.put("@HiddenAttributes", hiddenAttributes);
tags.put("@ActionCreate", actionCreate);
tags.put("@ActionEdit", actionEdit);
tags.put("@ActionDelete", actionDelete);
// tags.put("@LocalSearchIcon", localSearchButton);
tags.put("@LocalSearch", localSearch.getHtmlCode());
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
}
/**
* Genera le pagine di Help dei campi del form di gestione del bean
*/
public static void generateHelp(String sourceDir, String targetDir, Bean bean) throws FileNotFoundException, IOException
{
String template = "." + File.separator + "templates" + File.separator + "Seam_Help.html";
for (int i = 0; i < bean.getAttributes().size(); i++)
{
Attribute attribute = bean.getAttributes().get(i);
if (attribute.isHelp())
{
String sourceFile = sourceDir + ".." + File.separator + "html" + File.separator + "help" + File.separator + "form_" + bean.getName() + "_" + attribute.getName() + ".html";
String targetFile = targetDir + "html" + File.separator + "help" + File.separator + "form_" + bean.getName() + "_" + attribute.getName() + ".html";
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JSP);
HashMap<String, String> tags = new HashMap<String, String>();
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
}
}
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship rel = bean.getRelationships().get(i);
if (rel.isHelp())
{
String sourceFile = sourceDir + ".." + File.separator + "html" + File.separator + "help" + File.separator + "form_" + bean.getName() + "_" + rel.getName() + ".html";
String targetFile = targetDir + "html" + File.separator + "help" + File.separator + "form_" + bean.getName() + "_" + rel.getName() + ".html";
// Recupera il codice custom nella pagina
LinkedList<String> yourJavaScriptCode = Utils.getYourCode(sourceFile, CustomCodeType.JAVA);
LinkedList<String> yourCode = Utils.getYourCode(sourceFile, CustomCodeType.JSP);
HashMap<String, String> tags = new HashMap<String, String>();
Utils.SeamReplaceTagAndSave(tags, yourJavaScriptCode, yourCode, template, targetFile);
}
}
}
/**
* Inserisce nel form della popup le funzioni di inizializzazione dei campi nascosti
*
*
*/
private static String generatePopUpJavascriptFunctionsInPopup(Bean bean)
{
String javaScript = "";
/** Funzione di inizializzazione dei campi nascosti * */
javaScript += "\tfunction startup()\r\n";
javaScript += "\t{\r\n";
for (int i = 0; i < bean.getAttributes().size(); i++)
{
Attribute attr = bean.getAttributes().get(i);
if (!attr.isKey() && (attr.getImplementationType() != AttributeImplementationType.HIDEINFORM) && (attr.getImplementationType() != AttributeImplementationType.READONLY))
{
if (attr.getType().equals("java.lang.Boolean"))
{
javaScript += "\t\t\tif (window.opener.document.forms[\"form\"].elements[\"form:" + attr.getName() + "\"] != null)\r\n";
javaScript += "\t\t\tdocument.forms[\"form\"].elements[\"form:" + attr.getName() + "\"].checked = window.opener.document.forms[\"form\"].elements[\"form:" + attr.getName() + "\"].checked;\r\n";
}
else
{
javaScript += "\t\tif (window.opener.document.forms[\"form\"].elements[\"form:" + attr.getName() + "\"] != null)\r\n";
javaScript += "\t\t\tdocument.forms[\"form\"].elements[\"form:" + attr.getName() + "\"].value = window.opener.document.forms[\"form\"].elements[\"form:" + attr.getName() + "\"].value;\r\n";
}
}
}
for (int i = 0; i < bean.getRelationships().size(); i++)
{
Relationship relationship = bean.getRelationships().get(i);
if (relationship.isUsed() && relationship.isListBox())
{
if (relationship.isToMany())
{
javaScript += "\t\tif (window.opener.document.forms[\"form\"].elements[\"form:" + relationship.getName() + "\"] != null)\r\n";
javaScript += "\t\t{\r\n";
javaScript += "\t\t\tfor(i=0; i<window.opener.document.forms[\"form\"].elements[\"form:" + relationship.getName() + "\"].length; i++)\r\n";
javaScript += "\t\t\t{\r\n";
javaScript += "\t\t\t\tdocument.forms[\"form\"].elements[\"form:" + relationship.getName() + "\"].options[i].selected = window.opener.document.forms[\"form\"].elements[\"form:" + relationship.getName() + "\"].options[i].selected;\r\n";
javaScript += "\t\t\t}\r\n";
javaScript += "\t\t}\r\n";
}
else
{
javaScript += "\t\tif (window.opener.document.forms[\"form\"].elements[\"form:" + relationship.getName() + "\"] != null)\r\n";
javaScript += "\t\t\tdocument.forms[\"form\"].elements[\"form:" + relationship.getName() + "\"].value = window.opener.document.forms[\"form\"].elements[\"form:" + relationship.getName() + "\"].value;\r\n";
}
}
}
javaScript += "\t}\r\n\r\n";
return javaScript;
}
// /**
// * Inserisce nella colonna il check per stabilire quale icona deve essere
// * mostrata
// */
// public static String insertIcon(ShowAttribute attribute)
// {
// String ret = "";
//
// int size = attribute.getIcons().size();
//
// for (int i = 0; i < size; i++)
// {
// ret += "\t<nested:equal property=\"" + attribute.getName() + "\" value=\"" + attribute.getIconValues().get(i) + "\">\r\n";
// ret += "<img src=\"img/" + attribute.getIcons().get(i) + "\" />";
// ret += "\t</nested:equal>\r\n";
// }
//
// return ret;
// }
private static int getChunkIndex(Vector<CodeChunk> chunkVector, CodeChunk codeChunk)
{
for (int i = chunkVector.size() - 1; i >= 0; i--)
{
if (chunkVector.get(i).getOrder() <= codeChunk.getOrder())
return i;
}
return 0;
}
/**
* Indica se nella catena delle relazioni di un attributo c'è almeno una relazione :N.
* <br>
* In tal caso l'attributo ha molteplicità N rispetto al bean di partenza
* @param attr
* @return
*/
private static boolean attribute2N(Attribute attr)
{
for (int k = 0; k < attr.getRelationships().size(); k++)
{
if (attr.getRelationships().get(k).isToMany())
{
return true;
}
}
return false;
}
private static String addAjaxSupport(String event, Vector<String> idsToReRender)
{
return addAjaxSupport(event, idsToReRender, null);
}
private static String addAjaxSupport(String event, Vector<String> idsToReRender, String onChangeAlso)
{
String ret = "";
String ids = "";
for (int i = 0; i < idsToReRender.size(); i++)
{
if (i > 0)
ids += ",";
ids += idsToReRender.get(i);
}
if (event.equals("onchange") || onChangeAlso != null)
{
if (ids.equals(""))
ret += "<a4j:support event=\"onchange\" reRender=\"" + onChangeAlso + "\" ajaxSingle=\"true\" limitToList=\"true\" />";
else
ret += "<a4j:support event=\"onchange\" reRender=\"" + ids + "," + onChangeAlso + "\" ajaxSingle=\"true\" limitToList=\"true\" />";
}
if (!event.equals("") && !event.equals("onchange"))
{
ret += "\r\n<a4j:support event=\"" + event + "\" reRender=\"" + ids + "\" ajaxSingle=\"true\" limitToList=\"true\" />";
}
return ret;
}
}