Need help with simple XFORM

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help with simple XFORM

Isenor, Anthony
First, I am new to XForms.

I have an internal service running that does a multiplication by 10.
I thought I would experiment with XForms and access this service.

First, I know the service is running because I can communicate with it
through tools such as tcpmon.  The service is on a Linux box within my
organisation.

The XForms form is on my PC.  I run IExplorer and the Forms Player
plugin.

Here is the XForms I have in my file named "xforms_21.html":


<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xforms="http://
www.w3.org/2002/xforms"    xmlns:xsd="http://www.w3.org/2001/
XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:ns1="urn:xmethods-Temperature" xmlns:SOAP-ENV="http://
schemas.xmlsoap.org/soap/envelope/">
   <head>
      <title>XForms and Web Services</title>
   </head>
      <body>
         <object id="FormsPlayer" classid="CLSID:4D0ABA11-
C5F0-4478-991A-375C4B648F58">
            <b>FormsPlayer has not loaded. Please check your
installation.</b>
         </object>
         <?import namespace="xforms" implementation="#FormsPlayer" ?>

         <xforms:model id="MyServiceOnBonanza">
         <xforms:instance id="numberInstance" xmlns="">
            <SOAP-ENV:Envelope xmlns:SOAPSDK1="http://www.w3.org/2001/
XMLSchema" xmlns:SOAPSDK2="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAPSDK3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/">
               <SOAP-ENV:Body>
                  <SOAPSDK4:serviceMethod xmlns:SOAPSDK4="http://
example3.userguide.samples" xmlns:xs="http://www.w3.org/2001/
XMLSchema">
                     <bob>4</bob>
                  </SOAPSDK4:serviceMethod>
               </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>
         </xforms:instance>

         <xforms:submission id="gettimesten" replace="instance"
ref="instance('numberInstance')" action="http://185.124.10.245:8080/
axis2/services/MyService"/>
         </xforms:model>


         <xforms:switch id="switch1">
            <xforms:case id="requestGUI">

               <xforms:input ref="instance('numberInstance')//bob">
                  <xforms:label>Multiply this by 10:</xforms:label>
                  <xforms:hint>Enter the value.</xforms:hint>
               </xforms:input>

               <p></p>

               <xforms:trigger style="display:block">
                  <xforms:label>Obtain results of search</
xforms:label>
                  <xforms:action ev:event="DOMActivate">
                     <xforms:send submission="gettimesten"/>
                     <xforms:toggle case="responseGUI"/>
                  </xforms:action>
               </xforms:trigger>
            </xforms:case>

            <xforms:case id="responseGUI">
               <xforms:output ref="instance('numberInstance')/return">
               <xforms:label>Matching records:</xforms:label>
            </xforms:output>
            </xforms:case>
      </xforms:switch>
   </body>
</html>



When I drag and drop the file into IExplorer, I see the text "Multiply
this by 10:" and I see a text box that contains a value "4" (ie. the
bob element).  I also see a button with "obtain results of search".
However, when I click the button I simply get a blank window.

So, I have two questions.
1) Does anyone see obvious errors in the XForms above?
2) Are there any clever ways of debugging XForms code such as this?

Thanks for your time.
Anthony

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Need help with simple XFORM

Mark Birbeck-2
Hi Anthony,

I see that you are using formsPlayer, and obviously this list is for
the Mozilla implementation! However, since I think your form would not
work in Firefox either, then I'm sure people won't mind if I throw out
some comments. (Particularly because you ask about debugging
techniques, and everything I suggest below will work in formsPlayer
and the Firefox XForms Extension.)

> So, I have two questions.
> 1) Does anyone see obvious errors in the XForms above?

My guess is that the problem is a lack of a method on your submission.
This means that the submission is failing, (xforms-submit-error) but
because you don't have a handler for xforms-submit-error, you see
nothing. And worse, because you are toggling the second xf:case
immediately after you do the submit, _regardless of the result of that
submission_, then you simply get a blank page (because there is no
data to show).

So try setting @method="post".

Note by the way that even if there was data coming back correctly, if
you had your XPath expressions wrong then you would still not see any
data., so I'll outline below a few techniques that might speed up
spotting this kind of problem.


> 2) Are there any clever ways of debugging XForms code such as this?

The first thing I would strongly recommend is to use tools that show
you your network traffic--in IE we use Fiddler, and in Firefox we use
Firebug, but there are lots of tools out there--and in a case like
this you'd see very quickly whether your request was correctly formed,
what the server sent back, or even whether the submission was made at
all. (I don't think a request would be made here.)

Note also that the way you have your form structured you are toggling
immediately after the submission starts, and the toggle is done
regardless of the success or failure of the request. I'd recommend a
more 'defensive' approach, which involves putting any toggles on the
submission events, and having additional cases for 'error' and 'in
progress':

  <xforms:submission id="gettimesten" ...>
    <xforms:toggle case="sub-gettimesten-in-progress" ev:event="xforms-
submit" />
    <xforms:toggle case="sub-gettimesten-done" ev:event="xforms-submit-
done" />
    <xforms:toggle case="sub-gettimesten-error" ev:event="xforms-
submit-error" />
  </xforms:submission>
  .
  .
  .
  <xforms:switch id="switch1">
    <xforms:case id="requestGUI">
      <xforms:input ref="instance('numberInstance')//bob">
        <xforms:label>Multiply this by 10:</xforms:label>
        <xforms:hint>Enter the value.</xforms:hint>
      </xforms:input>

      <xforms:submit style="display:block" submission="gettimesten">
        <xforms:label>Obtain results of search</xforms:label>
      </xforms:submit>
    </xforms:case>

    <xforms:case id="sub-gettimesten-in-progress">
      Sending data to your server...

      or even:

      <img src="animated.gif" />
    </xforms:case>

    <xforms:case id="sub-gettimesten-done">
      <h1>Results</h1>
      <xforms:output ref="instance('numberInstance')/return">
        <xforms:label>Matching records:</xforms:label>
      </xforms:output>
    </xforms:case>

    <xforms:case id="sub-gettimesten-error">
      <h1>Error</h1>
    </xforms:case>
  </xforms:switch>

With this set-up you can at least tell whether everything went well
with the server. If you get the 'success' case toggled in, but still
don't see your data, then the most likely scenario is that you have
your XPath wrong.

(I've also changed your trigger for a submit.)

The technique I've just shown is one we use a lot in our forms,
because it makes it much easier to control the user experience with
things like 'in progress' animations, and so on. See our Flickr and
Amazon samples for an illustration of this:

  <http://www.formsplayer.com/project/search-amazon-books>
  <http://www.formsplayer.com/project/searching-flickr>

I hope that gives you a few things to try out.

Regards,

Mark

--
  Mark Birbeck, formsPlayer

  [hidden email] | +44 (0) 20 7689 9232
  http://www.formsPlayer.com | http://internet-apps.blogspot.com

  standards. innovation.

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms