Topic
8 replies Latest Post - ‏2009-07-17T17:08:13Z by SystemAdmin
SystemAdmin
SystemAdmin
181 Posts
ACCEPTED ANSWER

Pinned topic Unable to Capture HTML Input as String and Fire it to another Widget

‏2009-07-16T13:55:17Z |
Hello there,

I am currently working in the Lotus Widget Factory plugin for the Eclipse IDE environment. I am currently having trouble with capturing HTML input using the builders provider in Widget Factory. Right now I am using Flash to send a string, but I have simplified it since I do not expect anyone to extensively until stand Flash's External Interface Class. Here is what I am trying to do:

  • Text appears in a text input field in HTML on the Page.
  • The Page is a HTML page generated using the Page Builder in Widget Factory.
  • The text input field has an attribute "id" with a value "text1", and is located in a SPAN tag I created called "newTag".
  • Using the Button builder, I created a "Submit" button that will fire the event "sendWSDL" (which was created using the Widget Event Builder) with an Argument: firesendWSDL_Arg1 with the string value of ${Inputs/text1}.

When I wire the widget together with the event explorer and my Target widget which I built using the tutorial located in the Help files, it receives nothing. My question is:

Am I unable to obtain text from an input field and fire it to another widget?

Thanks,
Chris
Updated on 2009-07-17T17:08:13Z at 2009-07-17T17:08:13Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    181 Posts
    ACCEPTED ANSWER

    Re: Unable to Capture HTML Input as String and Fire it to another Widget

    ‏2009-07-16T16:00:29Z  in response to SystemAdmin
    The handling of widget events uses some optimizations that often make things easier, but in cases like this can cause confusion. If you have page action builder (Button, Link, etc.) call an event's "fire" method directly, it will fire the event from pure-client code, with no server round-trip required. If the fire method is called indirectly - e.g., from some other action targeted by the page action builder - then it will by necessity be executing server code at the time, and a server round-trip will happen. The ${Inputs} reference type is always evaluated on the server, so the pure-client code path does not allow for their proper evaluation.

    So one easy way to get what you want is to add an Action List builder call with the same arguments as your "fire" method, have the Action List call the fire method passing its own arguments, and point your button at this new Action List.

    I can imagine an enhancement in which a ${Input/foo} reference in a pure-client call would resove to something like "${JavaScript/this.form.foo.value}", but the details of implementing this correctly may be a bit tricky.
    • SystemAdmin
      SystemAdmin
      181 Posts
      ACCEPTED ANSWER

      Re: Unable to Capture HTML Input as String and Fire it to another Widget

      ‏2009-07-16T18:14:41Z  in response to SystemAdmin
      So from what I understand from your advice this is what I did:

      • Created an Action List Builder named: Action_Builder
      • Has one argument of type string named: textinput
      • I set the return type to String
      • The first and only item in the action list is firesendWSDL(${Arguments/textinput})
      • I changed the action field in my Submit Button to Action_Builder, evaluated my arguments to run "When action is run", and have one input mapping of firesendWSDL_Arg1 with value ${Inputs/text1}

      Results: null

      So at least I got something this time. I also went ahead and inserted a Variable Builder to create a variable wsdl_link with an initial string value "(wsdl link goes here)" and inserted that into the value of firesendWSDL_Arg1, so that it looks like this:

      Name: firesendWSDL_Arg1
      Value: ${Variables/wsdl_link}

      Result: (wsdl link goes here)

      So like before in my earlier testing I was able to pass a predefined variable built using a Variable Builder, but still am unable to use the test input field I want. I am not sure If I followed your advice wrong, but I will try and highlight the passing of the value below from what I understand.

      Submit Button(${Inputs/text1}) --> Action_Builder(textinput) --> sendWSDL event

      Thank you very much for your help thus far.
      • SystemAdmin
        SystemAdmin
        181 Posts
        ACCEPTED ANSWER

        Re: Unable to Capture HTML Input as String and Fire it to another Widget

        ‏2009-07-16T18:22:36Z  in response to SystemAdmin
        What is the "Action Type" input for your button? To access form values, it needs to be "submit form and invoke action", not "link to action".
        • SystemAdmin
          SystemAdmin
          181 Posts
          ACCEPTED ANSWER

          Re: Unable to Capture HTML Input as String and Fire it to another Widget

          ‏2009-07-16T18:46:51Z  in response to SystemAdmin
          I was set to "Link to action", but then I changed it to "Submit form and invoke action", but it produced the same result: null. I put the input text field within the form of the page and I am assuming that is all that must be done in order for the submit form to work. So I tried again with the button in the form as well. Same result.
          • SystemAdmin
            SystemAdmin
            181 Posts
            ACCEPTED ANSWER

            Re: Unable to Capture HTML Input as String and Fire it to another Widget

            ‏2009-07-16T18:52:37Z  in response to SystemAdmin
            I am not sure if this will help, but this is what my submit button is sending:

            (typeof lwf_widget_event_adapter != 'undefined') && lwf_widget_event_adapter.fire('sendWSDL', { _simple_payload: 'null' })
            • SystemAdmin
              SystemAdmin
              181 Posts
              ACCEPTED ANSWER

              Re: Unable to Capture HTML Input as String and Fire it to another Widget

              ‏2009-07-16T21:10:11Z  in response to SystemAdmin
              I am also trying a way to obtain the input using the webAppAccess interface by doing the following:

              webAppAccess.getRequestInputs().getInputValue("text1");

              What exactly is the value of argument for getInputValue suppose to be. Because if you look at a sample of my HTML page,

              <input id="text1" type="text" value="Initial Value"></input>

              I am using ""text1" which is the id attribute value to point the method to the value of the input field. Is "text1" the incorrect argument for getInputValue if I am trying to get "Initial Value"?
              • SystemAdmin
                SystemAdmin
                181 Posts
                ACCEPTED ANSWER

                Re: Unable to Capture HTML Input as String and Fire it to another Widget

                ‏2009-07-16T21:32:04Z  in response to SystemAdmin
                I don't see a "name" attribute value - this is what is used in HTML to build the request parameters you're trying to fetch. The "id" value is pretty much purely a client-side identifier, and doesn't impact what is submitted from the form.
  • SystemAdmin
    SystemAdmin
    181 Posts
    ACCEPTED ANSWER

    Re: Unable to Capture HTML Input as String and Fire it to another Widget

    ‏2009-07-17T17:08:13Z  in response to SystemAdmin
    I have finally got it working now. I used a Method Builder to create a method with return type string that retrieves the "value" attribute by changing the "id" attribute to "name" with value of "text1", and then using this code:

    
    Object o = webAppAccess.getRequestInputs().getInputValue(
    "text1")   
    
    return o.toString();
    


    Then having my inputs in the form of the page, and using "Submit form and invoke action" as suggested, I was able to fire the string over to receiving widgets.

    Thanks for all your help mtr.