/**
  * Builds the column section
  *
  * @param context The WidgetTransformerContext
  * @param widget The widget
  * @return Element return the column
  */
 protected Element buildColumn(WidgetTransformerContext context, Widget widget) {
   Element column = createElement(context, XGUI_NAMESPACE_URI, XGUI_COLUMN_ELEMENT);
   Element text = createElement(context, XGUI_NAMESPACE_URI, XGUI_TEXT_ELEMENT);
   Element udpColumnName = createElement(context, UDP_NAMESPACE_URI, UDP_COLUMN_NAME_ELEMENT);
   column.appendChild(text);
   text.appendChild(udpColumnName);
   TransformUtils.appendChild(context, column);
   if (hasSorter(context, widget)) {
     buildLogicSortColumn(context, widget, column);
   }
   return column;
 }
예제 #2
0
  /** property url should be src attribute with url as value */
  @Override
  public void transform(WidgetTransformerContext context, Property property) throws CoreException {

    String domainAttributValue =
        property
            .getWidget()
            .getPropertyValue(PropertyTypeConstants.DOMAIN_ATTRIBUTE_WITHOUT_VALIDATOR);

    if (domainAttributValue != null && domainAttributValue.length() > 0) {
      Property beanNameProperty =
          BeanPropertyUtils.findBeanNameProperty(context, property.getWidget());
      String beanNamePropertyValue = beanNameProperty.getValue();

      // Create the element <xsp:attribute name="src">...</xsp:attribute>
      Namespace ns = context.getTransformModel().findNamespace(XSP_NAMESPACE_URI);
      Element valElmt =
          context
              .getDocument()
              .createElementNS(ns.getUri(), TransformerConstants.ATTRIBUTE_ELEMENT_NAME);
      valElmt.setPrefix(ns.getPrefix());
      TransformUtils.appendChild(context, valElmt);
      // Create the attribute name="src"
      Attr a = context.getDocument().createAttribute(TransformerConstants.NAME_ATTRIBUTE_NAME);
      a.setValue("src");
      valElmt.setAttributeNode(a);

      // create the <bean:get-property bean="..." property="..."/>
      Namespace beanNamespace = context.getTransformModel().findNamespace(BEAN_URI);
      Element defElmt =
          context.getDocument().createElementNS(beanNamespace.getUri(), BEAN_GET_PROPERTY_ELEMENT);
      defElmt.setPrefix(beanNamespace.getPrefix());
      addAttribute(context, defElmt, BEAN_BEAN_ATTRIBUTE, beanNamePropertyValue);
      addAttribute(context, defElmt, BEAN_PROPERTY_ATTRIBUTE, domainAttributValue);
      valElmt.appendChild(defElmt);

    } else {
      String url = property.getValue();
      if (url != null && url.length() != 0) {
        addAttribute(context, "src", url);
      }
    }
  }