Announcement

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

    html link back to smart gwt page

    Hello,

    I have a form with some items on it. Some of the values of the items are long strings like
    "foo,bar, house, ..."

    I would like to have an action each of these items. I think I can get the value of the form item, break apart each item and have
    "foo"
    "bar"
    "house"
    ...

    but now I am not sure what objects to create to put back into the form item. If I make raw html then I will not be able to get back into my smart gwt application. Unless there is a way to make some html that generates an event with the values "foo", "bar", "house" that smart gwt can listen to. Or perhaps I should make smart gwt components, some buttons? Does a form item take such a list of items ...

    These list of items could have say 40 or 50 items, so I am thinking that if I use components it would be to slow, as I might have say 200 components being generated.

    So hoping to generate some html that when clicked gives an event. I am sure I could make say an html link for each item. But how would that link be picked up by my smart gwt code.

    Some pointers would be great,

    Thanks,
    Marc

    #2
    Not sure I follow, but it sounds like you might just build a LinkItem?

    Comment


      #3
      LinkItem

      Hello,

      Can't find the "setTarget" command on LinkItem

      Ean


      I am trying to use "setTarget" in the client to "javascript" per documentation (see link below). But the call to setTarget does not exist.

      http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/form/fields/LinkItem.html#getTarget%28%29

      On my server side I am building up some html like
      String strJavaScript =
      "$entry(@com.relay.winter.client.HeaderArea::handSearchEnt(" + code + ", '" + strValue + "' );";
      String strLink = "<input type=\"button\" value=";
      strLink += "\"" + strValue + "\"";
      strLink += "onClick=";
      strLink += "\"" + strJavaScript + "\"";
      strLink += "/>";

      Marc

      Comment


        #4
        ok

        Ok got the setTarget (had a FormItem, not a LinkItem).

        Now lets see if I can call java from javascript

        Marc

        Comment


          #5
          getting there

          <input type="button" onclick="$entry(@com.relay.winter.client.HeaderArea::handSearchEnt(3, 'C-reactive Protein' );" value="C-reactive Protein">

          So this is the content of the LinkItem.

          Which is showing the "button" now. However, when I click the button my GWT Java code is not being called.

          I have a method
          public boolean handSearchEnt(EntityEnumType eType, String strValueHead)

          defined in the class

          What else do I need to call this GWT method?

          Marc
          HeaderArea

          in the package
          com.relay.winter.client

          Comment


            #6
            how to get instance

            Hello,

            Well here is what I am "constructing"

            My javascript is weak, as I don't see what is wrong. I see some possible places I may be off. How do I get the instance of the application (is it this?), so I can get back to my HeaderArea. Of which there is only one, but not clear how to get to it.

            Also the javascript is not firing, why?

            Marc

            <a id="isc_LinkItem_24$20j" onclick="if(window.isc_LinkItem_24) return isc_LinkItem_24.$30i(event);" tabindex="3854" target="javascript" href="javascript:void">
            <input type="button" onclick="this.$entry(@com.relay.winter.client.HeaderArea::handSearchEnt(3, 'Isobutyryl-coa Dehydrogenase, Mitochondrial' );" value="Isobutyryl-coa Dehydrogenase, Mitochondrial">
            </a>

            Comment


              #7
              This approach isn't going to work - you can use the @com.foo.moo::MethodName(I)(1); type syntax within JSNI methods but you can't use it as raw JavaScript on the page.

              Any reason you can't just use the clickHandler on your linkItems to execute the action you want?

              Comment


                #8
                HTML in a form item

                Hello,

                I now have some HTML that I am putting into a HeaderItem on a form. However, what I really want is to put my html into AutoFitTextAreaItem which is a fantastic control item.

                What form items take HTML? And can I use any that do AutoFit?

                I did get the javascript to call back to GWT. The trick was to register the function I was calling. Here is an example for others.

                Thanks,
                Marc

                So in my client code I have

                public static void searchEntity(int code, String strValueHead) {
                EntityEnumType eType = EntityEnumType.values()[code];
                getGlobalHeaderArea().handSearchEnt(eType, strValueHead);
                }

                // http://code.google.com/p/google-web-toolkit-doc-1-5/wiki/FAQ_CallGWTMethodFromHandwrittenJS
                // http://vinaytech.wordpress.com/2008/10/07/javascript-native-interface-jsni/
                public static native void setupBridgeMethods() /*-{
                // searchEntity is setup for calling from AttivioDataSource.java in the returned entitiesfrom AIE
                $wnd.searchEntity = function(code, msg) {
                return @com.relay.winter.client.utils.AppUtils::searchEntity(ILjava/lang/String;)(code, msg);
                }
                }-*/;

                And on my server I have
                String strEscapedValue = strValue.replace("'", "\\x27");

                String strJavaScript = "searchEntity(" + code + ", '" + strEscapedValue + "');";
                String strLink = "<input type=\"button\" value=";
                strLink += "\"" + strValue + "\"";
                strLink += "onClick=";
                strLink += "\"" + strJavaScript + "\"";
                //strLink += "style=\"text-decoration:underline;background:none;border:0;color:blue\"";
                strLink += "id=\"entitysearch\"";
                strLink += "/>";

                Comment

                Working...
                X