Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Add HTML tags around SmartGWT widgets

    Hello,

    I'm creating an application that parses XML. After parsing, the corresponding widgets gets created and added to the page. To provide more customization, a user can include XHTML tags for formatting. These tags should go directly to the page in the spot they were specified. For example, lets say I have a "button" tag and the user writes:

    <b> <lab:button name="Run Me" evaluate="MyEvaluator"> </b>

    the HTML should look something like

    <b> <SmartGWT button widget code> </b>

    My first attempt was to do the following.

    window.addMember(new HTMLFlow("<"+tagName+">"));
    window.addMember(button);
    window.addMember(new HTMLFlow("</"+tagName+">"));

    SmartGWT, in the case where the tagName is "b", produces

    <Some sort of div> <b></b> <div>
    <SmartGWT button widget code>

    Since then, I also tried overwriting methods and classes, turning everything into HTML then adding one HTMLFlow widget, and some other unsuccessful approaches. I don't want to write the widget code by hand, because that defeats the purpose of using SmartGWT, or GWT for that matter. Plus I am using a lot more widgets then just buttons.

    Does anyone know a solution to this problem or can get me pointed in the right direction. It seems the simplest solution is to just directly write "<b>" before and "</b>" after the widget, although I'm not sure if that can be done. Anything ideas?

    Thanks!

    Tom

    #2
    The DOM is considered internal to the API and not to be changed for good reason. Though still possible in JSNI if you have a solid understanding of what your doing and code. But I don't quite understand your use case really, like why would you wrap <b> tags around a button? Are you trying to let the user customize the contents of the button?

    Comment


      #3
      Yea, bad example. The idea is for a user to put tags where they want to, without me having to know (since I just put the tag directly where they placed it). A better example would be a table. In this case, the user could layout the internal part of the lab. They could put a Button, Textbox, or some more complicated custom widgets within <table><tr><td> tags.

      Someone suggested a UIBinder, which wont work. I have to validate and process the xml myself. Also, a good portion of xml tags do something in the background and don't even show on the page.

      I could create my own <table> and <b> tags (for example) and translate them to a GWT widget, but again, the idea was a user could have full flexibility and customization . If we did it that way, we would have to add tags every time we wanted some new UI functionality. If we supported the use of xhtml, we wouldn't need to.

      Comment


        #4
        This still goes back to the thing that the DOM is internal. So it is one thing to customize content of a widget, but a whole other to customize the DOM of widgets which really isn't supported.

        Comment


          #5
          The more I explore different options, the more I realize it's a bad idea. It was worth a shot.

          Thanks for the reply and information!

          Tom

          Comment

          Working...
          X