OW2 Consortium
Search OW2 Mail Archive: 

Advanced Search - Powered by Google


Mail Archive Home | exo-ecm List | August 2008 Index

<--  Date Index     <--  Thread Index    

[[exo-ecm]] Re: [[exo-ecm]] How to do to save node in document class in ECM


Why do you create a dedicated class, a dialog in ECM with multi value of property nodetype should be enough no?



On Fri, Aug 29, 2008 at 2:45 PM, <hugues.poisseroux@xxxxxx> wrote:
Hello all,

I'm writing a class to make a multivalue document i undestand some part but i
don't know how to build & save a new node.
Someone can get me the string for a solution.

Thanks for your help.
Regards.

Where's my code class

@ComponentConfig(
           lifecycle = UIFormLifecycle.class,
           template = "system:/groovy/webui/form/UIForm.gtmpl",
           events = {
             @EventConfig(listeners = UIServiceForm.SaveActionListener.class),
             @EventConfig(phase = Phase.DECODE, listeners =
UIServiceForm.AddActionListener.class),
             @EventConfig(phase = Phase.DECODE, listeners =
UIServiceForm.RemoveActionListener.class)
           }
       )

public class UIServiceForm extends UIForm {

         final static public String FIELD_IDSERVICE            = "id_Service"
;
         final static public String FIELD_TITRESERVICE         =
"titre_service" ;
         final static public String FIELD_CONTENUSERVICE       =
"contenu_service" ;
         final static public String FIELD_TYPESERVICE          =
"type_service" ;
         final static public String FIELD_PRODUCTEUR           = "producteur"
;
         final static public String FIELD_RESFONC                      =
"responsable_fonctionnel" ;
         final static public String FIELD_RESTECH                      =
"responsable_technique" ;
         final static public String FIELD_BACKUPFCT            =
"backup_fonctionnel" ;
         final static public String FIELD_BACKUPTECH           =
"backup_technique" ;
         final static public String FIELD_REMARQUES            = "remarques" ;
         final static public String FIELD_PUBLICATION      =
"date_1ere_publication_service" ;
         final static public String FIELD_FREMAJ                       =
"frequence_maj_donnees_service" ;

         public UIFormMultiValueInputSet uiFormMValueProd  = null ;
         public UIFormMultiValueInputSet uiFormMValueFonc  = null ;
         public UIFormMultiValueInputSet uiFormMValueTech  = null ;
         public UIFormMultiValueInputSet uiFormMValueBFonc = null ;
         public UIFormMultiValueInputSet uiFormMValueBTech = null ;

         public UIServiceForm() throws Exception {
           this.addUIFormInput(new UIFormStringInput(FIELD_IDSERVICE,
FIELD_IDSERVICE, null));
           this.addUIFormInput(new UIFormStringInput(FIELD_TITRESERVICE,
FIELD_TITRESERVICE, null));
           this.addUIFormInput(new UIFormTextAreaInput(FIELD_CONTENUSERVICE,
FIELD_CONTENUSERVICE, null));

           List<SelectItemOption<String>> typeListService = new
ArrayList<SelectItemOption<String>>();
           typeListService.add(new SelectItemOption("xml"));
           typeListService.add(new SelectItemOption("base de donnees"));
           typeListService.add(new SelectItemOption("service Web"));
           typeListService.add(new SelectItemOption("flux de donnees
Edifact"));
           typeListService.add(new SelectItemOption("flux de donnees IHFN"));
           typeListService.add(new SelectItemOption("fichier excel MS office
(.xls)"));
           typeListService.add(new SelectItemOption("feuille de calcul
OpenOffice (.ods)"));

           UIFormSelectBox actionTypeService = new
UIFormSelectBox(FIELD_TYPESERVICE, FIELD_TYPESERVICE, typeListService) ;
           //actionType.setOnChange("ChangeType") ;
           this.addUIFormInput(actionTypeService) ;

           initMultiValuesField();

           this.addUIFormInput(new UIFormWYSIWYGInput(FIELD_REMARQUES,
FIELD_REMARQUES,null,true));

           List<SelectItemOption<String>> typeListPub = new
ArrayList<SelectItemOption<String>>();
           typeListPub.add(new SelectItemOption("en temps reel"));
           typeListPub.add(new SelectItemOption("quotidienne"));
           typeListPub.add(new SelectItemOption("hebdomadaire"));
           typeListPub.add(new SelectItemOption("mensuelle"));
           typeListPub.add(new SelectItemOption("semestrielle"));
           typeListPub.add(new SelectItemOption("annuelle"));
           typeListPub.add(new SelectItemOption("a la demande"));

           UIFormSelectBox actionTypePub = new
UIFormSelectBox(FIELD_PUBLICATION, FIELD_PUBLICATION, typeListPub) ;
           //actionType.setOnChange("ChangeType") ;
           this.addUIFormInput(actionTypePub) ;

           this.addUIFormInput(new
UIFormDateTimeInput(FIELD_FREMAJ,FIELD_FREMAJ, null));


           setActions( new String[]{"Save", "Cancel"}) ;
         }

         private void initMultiValuesField() throws Exception{

               List<String> list;

               // Multivalue pour le champs producteur
               uiFormMValueProd =
createUIComponent(UIFormMultiValueInputSet.class, null, null);
               uiFormMValueProd.setId(FIELD_PRODUCTEUR);
               uiFormMValueProd.setName(FIELD_PRODUCTEUR);
               uiFormMValueProd.setType(UIFormStringInput.class);
               list = new ArrayList<String>();
           uiFormMValueProd.setValue(list);
               this.addUIFormInput(uiFormMValueProd);

               // Multivalue pour le champs responsable fonctionnel
               uiFormMValueFonc =
createUIComponent(UIFormMultiValueInputSet.class, null, null);
               uiFormMValueFonc.setId(FIELD_RESFONC);
               uiFormMValueFonc.setName(FIELD_RESFONC);
               uiFormMValueFonc.setType(UIFormStringInput.class);
           list = new ArrayList<String>();
           uiFormMValueFonc.setValue(list);
               this.addUIFormInput(uiFormMValueFonc);

               // Multivalue pour le champs responsable technique
               uiFormMValueTech =
createUIComponent(UIFormMultiValueInputSet.class, null, null);
               uiFormMValueTech.setId(FIELD_RESTECH);
               uiFormMValueTech.setName(FIELD_RESTECH);
               uiFormMValueTech.setType(UIFormStringInput.class);
           list = new ArrayList<String>();
           uiFormMValueTech.setValue(list);
               this.addUIFormInput(uiFormMValueTech);

               // Multivalue pour le champs backup responsable fonctionnel
               uiFormMValueBFonc =
createUIComponent(UIFormMultiValueInputSet.class, null, null);
               uiFormMValueBFonc.setId(FIELD_BACKUPFCT);
               uiFormMValueBFonc.setName(FIELD_BACKUPFCT);
               uiFormMValueBFonc.setType(UIFormStringInput.class);
           list = new ArrayList<String>();
           uiFormMValueBFonc.setValue(list);
               this.addUIFormInput(uiFormMValueBFonc);

               // Multivalue pour le champs backup responsable technique
               uiFormMValueBTech =
createUIComponent(UIFormMultiValueInputSet.class, null, null);
               uiFormMValueBTech.setId(FIELD_BACKUPTECH);
               uiFormMValueBTech.setName(FIELD_BACKUPTECH);
               uiFormMValueBTech.setType(UIFormStringInput.class);
           list = new ArrayList<String>();
           uiFormMValueBTech.setValue(list);
               this.addUIFormInput(uiFormMValueBTech);
         }

         static public class CancelActionListener extends
EventListener<UIServiceForm> {
           public void execute(Event<UIServiceForm> event) throws Exception {
             UIServiceForm uiForm = event.getSource();
             uiForm.reset();
             UIActionManager uiActionManager =
uiForm.getAncestorOfType(UIActionManager.class) ;
             uiActionManager.removeChild(UIPopupWindow.class) ;

event.getRequestContext().addUIComponentToUpdateByAjax(uiActionManager);
           }
         }

         static public class AddActionListener extends
EventListener<UIServiceForm> {
           public void execute(Event<UIServiceForm> event) throws Exception {
             UIServiceForm uiForm = event.getSource();

event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
           }
         }

         static public class RemoveActionListener extends
EventListener<UIServiceForm> {
           public void execute(Event<UIServiceForm> event) throws Exception {
             UIServiceForm uiForm = event.getSource();

event.getRequestContext().addUIComponentToUpdateByAjax(uiForm.getParent());
           }
         }

         static public class SaveActionListener extends
EventListener<UIServiceForm> {
           public void execute(Event<UIServiceForm> event) throws Exception {
               UIServiceForm uiForm = event.getSource() ;
               UIJCRExplorer uiExplorer =
uiForm.getAncestorOfType(UIJCRExplorer.class);
               UIApplication uiApp =
uiForm.getAncestorOfType(UIApplication.class);

               String repository = uiForm.getRepository() ;
               NodeTypeManager ntManager =
uiForm.getApplicationComponent(RepositoryService.class).getRepository(repository).getNodeTypeManager()
;

               String namespace = "/node/refsrc:";
               String name;

               if(!uiExplorer.getCurrentNode().isCheckedOut()) {
                   uiApp.addMessage(new
ApplicationMessage("UIPropertyForm.msg.node-checkedin", null)) ;

event.getRequestContext().addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages())
;
                   return ;
                 }

               NodeType nodeType =
uiExplorer.getCurrentNode().getPrimaryNodeType();
               if(nodeType.isNodeType(Utils.NT_UNSTRUCTURED)) {
                       name = namespace +
uiForm.getUIStringInput(FIELD_TITRESERVICE).getValue();
                   if(uiExplorer.getCurrentNode().hasProperty(name)) {
                       Object[] args = { name } ;
                       uiApp.addMessage(new
ApplicationMessage("UIPropertyForm.msg.propertyName-exist", args,
                           ApplicationMessage.WARNING)) ;

event.getRequestContext().addUIComponentToUpdateByAjax(uiApp.getUIPopupMessages())
;
                       UIPropertiesManager uiPropertiesManager =
uiForm.getAncestorOfType(UIPropertiesManager.class) ;

uiPropertiesManager.setRenderedChild(UIPropertyForm.class) ;
                       return ;
                   }



               }
           }
         }

         private String getRepository() {
                   PortletRequestContext pcontext =
(PortletRequestContext)WebuiRequestContext.getCurrentInstance() ;
                   PortletPreferences portletPref =
pcontext.getRequest().getPreferences() ;
                   return portletPref.getValue(Utils.REPOSITORY, "") ;
         }


--
You receive this message as a subscriber of the exo-ecm@xxxxxxx mailing list.
To unsubscribe: mailto:exo-ecm-unsubscribe@xxxxxxx
For general help: mailto:sympa@xxxxxxx?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




<--  Date Index     <--  Thread Index    

Reply via email to:

Powered by MHonArc.

Copyright © 2006-2007, OW2 Consortium | contact | webmaster.