Package com.cosmo.ui.templates

Examples of com.cosmo.ui.templates.TemplateControl


   {
      String xhtml;
      String icon;
      String title;
      String trace;
      TemplateControl ctrl;

      // Determina el t�tulo y el icono a mostrar
      if (this.getException() instanceof NotAuthorizedException ||
          this.getException() instanceof AuthorizationException ||
          this.getException() instanceof AuthenticationException)
      {
         title = "Av�s de seguretat (" + this.getException().getClass().getSimpleName() + ")";
         icon = "icon-lock";
      }
      else
      {
         title = "Error de servidor";
         icon = " icon-remove-circle";
      }

      // Determina la traza del error
      StringWriter writer = new StringWriter();
      PrintWriter printWriter = new PrintWriter(writer);
      exception.printStackTrace(printWriter);
      printWriter.flush();
      trace = writer.toString();

      // Obtiene la plantilla y la parte del control
      ctrl = getWorkspace().getTemplate().getControl(ErrorMessageControl.CTUID);

      // Obtiene el cuerpo del mensaje
      xhtml = ctrl.getElement(CPART_BODY);
      xhtml = Control.replaceTag(xhtml, TAG_TITLE, title);
      xhtml = Control.replaceTag(xhtml, TAG_ICON, icon);
      xhtml = Control.replaceTag(xhtml, TAG_MESSAGE, this.getException().getMessage());
      xhtml = Control.replaceTag(xhtml, TAG_TRACE, trace);
View Full Code Here


   public String render()
   {
      String xhtml;
      String xitem;
      FormField field;
      TemplateControl ctrl;
      Iterator<FormField> it;

      // Si no tiene grupos, no representa el control
      if (groups.isEmpty())
      {
         return "<-- FormControl placeholder (void) -->\n";
      }

      // Obtiene la plantilla y la parte del control
      ctrl = getWorkspace().getTemplate().getControl(FormControl.CTUID);

      // Genera la cabecera del formulario
      xhtml = "";

      xitem = ctrl.getElement(CPART_HEADER);
      xitem = Control.replaceTag(xitem, TAG_TITLE, this.getTitle());
      xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, this.getDescription());
      xitem = Control.replaceTag(xitem, TAG_FORM_NAME, this.getName());
      xitem = Control.replaceTag(xitem, TAG_FORM_METHOD, "POST");
      xhtml += xitem;

      for (FormFieldHidden hfield : this.hidden)
      {
         xhtml += hfield.render(getWorkspace()) + "\n";
      }

      for (FormFieldset group : this.groups)
      {
         xitem = ctrl.getElement(CPART_GROUP_HEADER);
         xitem = Control.replaceTag(xitem, TAG_TITLE, group.getTitle());
         xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, group.getDescription());
         xhtml += xitem;

         it = group.getFields();
         while (it.hasNext())
         {
            field = it.next();
           
            if (field instanceof FormFieldText)
            {
               xitem = ctrl.getElement(CPART_FIELD_CONTROL);
               xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
               xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldText) field).getLabel());
               xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldText) field).getDescription());
               xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldText) field).getName());
               xhtml += xitem;
            }
            else if (field instanceof FormFieldTextArea)
            {
               xitem = ctrl.getElement(CPART_FIELD_TEXTAREA);
               xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
               xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldTextArea) field).getLabel());
               xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldTextArea) field).getDescription());
               xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldTextArea) field).getName());
               xhtml += xitem;
            }
            else if (field instanceof FormFieldInteger)
            {
               xitem = ctrl.getElement(CPART_FIELD_CONTROL);
               xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
               xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldInteger) field).getLabel());
               xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldInteger) field).getDescription());
               xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldInteger) field).getName());
               xhtml += xitem;
            }
            else if (field instanceof FormFieldBoolean)
            {
               xitem = ctrl.getElement(CPART_FIELD_OPTION);
               xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
               xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldBoolean) field).getLabel());
               xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldBoolean) field).getDescription());
               xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldBoolean) field).getName());
               xhtml += xitem;
            }
            else if (field instanceof FormFieldDate)
            {
               xitem = ctrl.getElement(CPART_FIELD_CONTROL);
               xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
               xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldDate) field).getLabel());
               xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldDate) field).getDescription());
               xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldDate) field).getName());
               xhtml += xitem;
            }
            else if (field instanceof FormFieldList)
            {
               xitem = ctrl.getElement(CPART_FIELD_CONTROL);
               xitem = Control.replaceTag(xitem, TAG_CONTROL, field.render(getWorkspace()));
               xitem = Control.replaceTag(xitem, TAG_LABEL, ((FormFieldList) field).getLabel());
               xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, ((FormFieldList) field).getDescription());
               xitem = Control.replaceTag(xitem, TAG_CONTROL_NAME, ((FormFieldList) field).getName());
               xhtml += xitem;
            }
         }

         xitem = ctrl.getElement(CPART_GROUP_FOOTER);
         xhtml += xitem;
      }

      xitem = ctrl.getElement(CPART_BUTTONS);
      xitem = Control.replaceTag(xitem, TAG_BUTTONS, getButtonsXhtml(getWorkspace().getServerSession()));
      xhtml += xitem;

      xitem = ctrl.getElement(CPART_FOOTER);
      xitem = Control.replaceTag(xitem, TAG_FORM_NAME, this.name);
      xhtml += xitem;

      return xhtml;
   }
View Full Code Here

    * @return Devuelve una cadena en formato XHTML que representa el control.
    */
   @Override
   public String render()
   {
      TemplateControl ctrl;
      StringBuilder str = new StringBuilder();

      // Si no tiene elementos, no representa el control (deja una traza)
      if (this.buttons.isEmpty())
      {
         return "<-- ButtonBarControl placeholder (void) -->\n";
      }

      // Obtiene la plantilla y la parte del control
      ctrl = getWorkspace().getTemplate().getControl(ButtonBarControl.CTUID);

      // Genera la cabecera de la barra de navegaci�n
      str.append(ctrl.getElement(CPART_HEADER));

      for (ButtonBarItem item : this.buttons)
      {
         str.append(item.render(ctrl));
      }

      // Genera el pie de la barra de navegaci�n
      str.append(ctrl.getElement(CPART_FOOTER));

      return str.toString();
   }
View Full Code Here

    */
   @Override
   public String render()
   {
      String xhtml = StringUtils.EMPTY;
      TemplateControl ctrl = getWorkspace().getTemplate().getControl(DynamicMessageControl.CTUID);

      // Si no es visible, no se renderiza
      if (!this.visible)
      {
         return "<!-- Dynamic label placeholder [" + this.getId() + "] -->";
      }

      switch (this.type)
      {
         case Information:
            xhtml = ctrl.getElement(DynamicMessageControl.CPART_MSG_INFORMATION);
            xhtml = Control.replaceTag(xhtml, DynamicMessageControl.TAG_TEXT, this.message);
            break;

         case Warning:
            xhtml = ctrl.getElement(DynamicMessageControl.CPART_MSG_WARNING);
            xhtml = Control.replaceTag(xhtml, DynamicMessageControl.TAG_TEXT, this.message);
            break;

         case Error:
            xhtml = ctrl.getElement(DynamicMessageControl.CPART_MSG_ERROR);
            xhtml = Control.replaceTag(xhtml, DynamicMessageControl.TAG_TEXT, this.message);
            break;
      }

      return xhtml;
View Full Code Here

   public String render()
   {
      int count = 0;
      String xitem;
      String first = StringUtils.EMPTY;
      TemplateControl ctrl;
      StringBuilder str = new StringBuilder();

      // Si no tiene elementos, no representa el control
      if (items.isEmpty())
      {
         return "<-- SliderControl placeholder (void) -->\n";
      }

      // Obtiene la plantilla y la parte del control
      ctrl = getWorkspace().getTemplate().getControl(SliderControl.CTUID);

      // Obtiene el indicador de primer elemento (permite diferenciar la clase cuando es el primer elemento)
      first = ctrl.getElement(CPART_FIRST);

      // Genera la cabecera de la barra de navegaci�n
      xitem = ctrl.getElement(CPART_HEADER);
      xitem = Control.replaceTag(xitem, TAG_SLIDER_ID, this.getId());
      xitem = Control.replaceTag(xitem, TAG_SLIDER_WIDTH, StringUtils.EMPTY + this.width);
      xitem = Control.replaceTag(xitem, TAG_SLIDER_HEIGHT, StringUtils.EMPTY + this.height);
      str.append(xitem);

      xitem = ctrl.getElement(CPART_ITEM_HEADER);
      xitem = Control.replaceTag(xitem, TAG_SLIDER_ID, this.getId());
      str.append(xitem);

      for (SliderItem item : this.items)
      {
         count++;

         xitem = ctrl.getElement(CPART_ITEM);
         xitem = Control.replaceTag(xitem, TAG_SLIDER_ID, this.getId());
         xitem = Control.replaceTag(xitem, TAG_SLIDER_CONTENTS, item.render());
         xitem = Control.replaceTag(xitem, TAG_SLIDER_COUNT, StringUtils.EMPTY + count);
         xitem = Control.replaceTag(xitem, TAG_SLIDER_FIRST, first);
         str.append(xitem);

         first = StringUtils.EMPTY;
      }

      xitem = ctrl.getElement(CPART_ITEM_FOOTER);
      xitem = Control.replaceTag(xitem, TAG_SLIDER_ID, this.getId());
      xitem = Control.replaceTag(xitem, TAG_SLIDER_COUNT, StringUtils.EMPTY + count)// N�mero total de diapositivas
      str.append(xitem);

      // Obtiene el indicador de primer elemento (permite diferenciar la clase cuando es el primer elemento)
      first = ctrl.getElement(CPART_FIRST);

      xitem = ctrl.getElement(CPART_CONTENT_HEADER);
      xitem = Control.replaceTag(xitem, TAG_SLIDER_ID, this.getId());
      str.append(xitem);

      for (SliderItem item : this.items)
      {
         count++;

         xitem = ctrl.getElement(CPART_CONTENT);
         xitem = Control.replaceTag(xitem, TAG_SLIDER_ID, this.getId());
         xitem = Control.replaceTag(xitem, TAG_SLIDER_CONTENTS, item.render());
         xitem = Control.replaceTag(xitem, TAG_SLIDER_COUNT, StringUtils.EMPTY + count);
         xitem = Control.replaceTag(xitem, TAG_SLIDER_TITLE, item.getTitle());
         xitem = Control.replaceTag(xitem, TAG_SLIDER_DESCRIPTION, item.getDescription());
         xitem = Control.replaceTag(xitem, TAG_SLIDER_FIRST, first);
         str.append(xitem);

         first = StringUtils.EMPTY;
      }

      xitem = ctrl.getElement(CPART_CONTENT_FOOTER);
      xitem = Control.replaceTag(xitem, TAG_SLIDER_ID, this.getId());
      xitem = Control.replaceTag(xitem, TAG_SLIDER_COUNT, StringUtils.EMPTY + count)// N�mero total de diapositivas
      str.append(xitem);

      // Genera el pié de la barra de navegaci�n
      xitem = ctrl.getElement(CPART_FOOTER);
      xitem = Control.replaceTag(xitem, TAG_SLIDER_ID, this.getId());
      str.append(xitem);

      return str.toString();
   }
View Full Code Here

   {
      String xhtml = "";
      String xitem;
      String actions;
      String xrowtitle, xrow, xrowdata, xcell, xhead;
      TemplateControl ctrl;

      // Obtiene la plantilla y la parte del control
      ctrl = getWorkspace().getTemplate().getControl(CTUID);

      // Genera la fila de títulos
      xrowdata = "";
      xcell = ctrl.getElement(CPART_ROWTITLE_CELL);
      for (int col = 0; col < this.gridData.getColumnCount(); col++)
      {
         xrowdata += Control.replaceTag(xcell, TAG_VALUE, this.gridData.getCell(0, col, StringUtils.EMPTY).toString());
      }
      if (!this.rowActions.isEmpty())
      {
         xrowdata += Control.replaceTag(xcell, TAG_VALUE, this.rowActionsCaption);
      }
      xrowtitle = ctrl.getElement(CPART_ROWTITLE_BODY);
      xrowtitle = Control.replaceTag(xrowtitle, TAG_CELLS, xrowdata);

      // Genera las celdas de datos
      xrow = "";
      xcell = ctrl.getElement(CPART_ROW_CELL);
      for (int row = 1; row < this.gridData.getRowCount(); row++)
      {
         xrowdata = "";
         for (int col = 0; col < this.gridData.getColumnCount(); col++)
         {
            xrowdata += Control.replaceTag(xcell, TAG_VALUE, StringUtils.formatValue(this.gridData.getCell(row, col, StringUtils.EMPTY)));
         }
         if (!this.rowActions.isEmpty())
         {
            actions = "";
            for (GridRowAction action : this.rowActions)
            {
               actions += action.render(ctrl, this.gridData.getRowId(row));
            }
            xrowdata += Control.replaceTag(xcell, TAG_VALUE, actions);
         }
         xhead = ctrl.getElement(CPART_ROW_BODY);
         xhead = Control.replaceTag(xhead, TAG_CELLS, xrowdata);

         xrow += xhead;
      }

      // Genera la cabecera del grid
      xitem = ctrl.getElement(CPART_TITLE);
      xitem = Control.replaceTag(xitem, TAG_TITLE, this.getTitle());
      xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, this.getDescription());
      xhtml += xitem;

      // Forma la tabla
      xitem = ctrl.getElement(CPART_BODY);
      xitem = Control.replaceTag(xitem, TAG_TITLE_ROW, xrowtitle);
      xitem = Control.replaceTag(xitem, TAG_DATA_ROWS, xrow);
      xhtml += xitem;

      return xhtml;
View Full Code Here

   @Override
   public String render()
   {
      int nitems = 0;
      String xitem;
      TemplateControl ctrl = getWorkspace().getTemplate().getControl(ListViewControl.CTUID);
      StringBuilder sb = new StringBuilder();

      xitem = ctrl.getElement(CPART_TITLE);
      xitem = Control.replaceTag(xitem, TAG_TITLE, this.caption);
      xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, this.description);
      sb.append(xitem);

      sb.append(ctrl.getElement(CPART_HEADER));
     
      for (ListViewItem item : this.items)
      {
         sb.append(item.render(ctrl));
         nitems++;
      }

      xitem = ctrl.getElement(CPART_FOOTER);
      xitem = Control.replaceTag(xitem, TAG_ITEMS, StringUtils.EMPTY + nitems);
      sb.append(xitem);

      return sb.toString();
   }
View Full Code Here

   @Override
   public String render()
   {
      String xhtml;
      String xitem;
      TemplateControl ctrl;

      // Obtiene la plantilla y la parte del control
      ctrl = getWorkspace().getTemplate().getControl(HeaderControl.CTUID);

      // Genera la cabecera del formulario
      xhtml = "";
      xitem = ctrl.getElement(CPART_TITLE);
      xitem = Control.replaceTag(xitem, TAG_TITLE, this.getTitle());
      xitem = Control.replaceTag(xitem, TAG_AUTHOR, this.author);
      xitem = Control.replaceTag(xitem, TAG_DESCRIPTION, this.getDescription());
      xitem = Control.replaceTag(xitem, TAG_UTILITIES, ctrl.getElement(CPART_UTILITIES));
      xhtml += xitem;

      return xhtml;
   }
View Full Code Here

   @Override
   public String render() throws TemplateUnavailableException
   {
      String xhtml = "";
      String xitem;
      TemplateControl ctrl;
      Template template;
      ArrayList<BannerAreaItem> items = new ArrayList<BannerAreaItem>();

      if (!items.isEmpty())
      {
         // Obtiene la plantilla y la parte del widget
         template = this.getWorkspace().getTemplate();
         ctrl = template.getControl(WIDGET_ID);

         // Renderiza el control
         xhtml = "";
         xhtml += ctrl.getElement(WPART_HEADER);
         for (BannerAreaItem item : items)
         {
            xitem = ctrl.getElement(WPART_BANNER);
            xitem = xitem.replace(Widget.getTag(TAG_BANNER_ID), item.getId());
            xitem = xitem.replace(Widget.getTag(TAG_BANNER_OBJ), item.render());
            xhtml += xitem;
         }
         xhtml += ctrl.getElement(WPART_FOOTER);
      }

      return xhtml;
   }
View Full Code Here

    */
   @Override
   public String render() throws TemplateUnavailableException
   {
      String xhtml = "";
      TemplateControl ctrl;
      Template template;

      // Obtiene la plantilla y la parte del widget
      template = this.getWorkspace().getTemplate();
      ctrl = template.getControl(WIDGET_ID);

      if (!getWorkspace().isValidUserSession())
      {
         // Configura la url del login
         URL url = new URL(getWorkspace().getProperties().getSecurityProperties().getLoginPage());
         url.addParameter("tourl", getWorkspace().getRequestedUrl());

         // Genera el XHTML del widget
         xhtml += ctrl.getElement(WPART_LOGIN);
         xhtml = Control.replaceTag(xhtml, TAG_HREF, url.build(getWorkspace().getCharset()));
      }
      else
      {
         // Configura la url del login
         URL url = new URL("LogoutPage");
         url.addParameter("tourl", getWorkspace().getRequestedUrl());

         // Genera el XHTML del widget
         xhtml += ctrl.getElement(WPART_LOGOUT);
         xhtml = Control.replaceTag(xhtml, TAG_HREF, url.build(getWorkspace().getCharset()));
         xhtml = Control.replaceTag(xhtml, TAG_USER, getWorkspace().getUserSession().getCurrentUser().getLogin());
      }

      return xhtml;
View Full Code Here

TOP

Related Classes of com.cosmo.ui.templates.TemplateControl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.