You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Baldur Norddahl <bb...@clansoft.dk> on 2003/11/14 22:49:58 UTC

Bad conditional handling

Hi,

I am working on a system that tells the user to wait until they received an 
SMS and then submit the form. When the SMS is received, our database is 
updated automatically. So if the user submits too early, we will just show 
them the same page again. The html ended up looking something like this:

<html>
  <body>
    <form jwcid="@Form">
      <div jwcid="@Conditional" condition='ognl:@java.lang.Math@random()>0.5'>
        <input jwcid="@Submit" listener="ognl:listeners.checkSMS" label="I 
received the SMS"/>
      </div>
    </form>
  </body>
<html>

The above is just testcode that shows the problem. The random() call 
symbolises a database that changes state.

When you click on the button, there is 50% change that you get a stale link 
exception.

This apparently means that you can not use conditionals on anything that other 
users can change, or which changes as result of some external event.

Any ideas how to solve this? I am aware I could use more page files, and avoid 
using conditional. But the actual program has a zillion small special cases, 
and I want to avoid copying the whole page file just to change a single line 
with error text.

Thanks,

Baldur


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Bad conditional handling

Posted by Mindbridge <mi...@yahoo.com>.
Please use the FormConditional component in Contrib (and ListEdit instead of
Foreach) for cases like this when the input values may differ between form
generation and form submission.

----- Original Message ----- 
From: "Baldur Norddahl" <bb...@clansoft.dk>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, November 14, 2003 11:49 PM
Subject: Bad conditional handling


> Hi,
>
> I am working on a system that tells the user to wait until they received
an
> SMS and then submit the form. When the SMS is received, our database is
> updated automatically. So if the user submits too early, we will just show
> them the same page again. The html ended up looking something like this:
>
> <html>
>   <body>
>     <form jwcid="@Form">
>       <div jwcid="@Conditional"
condition='ognl:@java.lang.Math@random()>0.5'>
>         <input jwcid="@Submit" listener="ognl:listeners.checkSMS" label="I
> received the SMS"/>
>       </div>
>     </form>
>   </body>
> <html>
>
> The above is just testcode that shows the problem. The random() call
> symbolises a database that changes state.
>
> When you click on the button, there is 50% change that you get a stale
link
> exception.
>
> This apparently means that you can not use conditionals on anything that
other
> users can change, or which changes as result of some external event.
>
> Any ideas how to solve this? I am aware I could use more page files, and
avoid
> using conditional. But the actual program has a zillion small special
cases,
> and I want to avoid copying the whole page file just to change a single
line
> with error text.
>
> Thanks,
>
> Baldur
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: Bad conditional handling

Posted by James Iry <ja...@hotmail.com>.
The problem you're having is that the structure of the components inside the
form component can't be different from what the browser actually submits.
Tapestry figures out the components inside a form without looking at
conditionals, but the browser receives only the components that were not
removed by conditionals.  As a result, the browser submits something
different from what Tapestry was expecting.

One option is to put the whole form inside the conditional.  That doesn't
work in all cases, but in the simple example you gave it will. 

Another option is to use Tapestry's disabled property on the button and use
CSS to not display it when it's disabled.  The CSS stuff may not work on all
browsers, but on those where it doesn't work the button will still be grayed
out.  Similar techniques (and limitations) can be used on other form
components.

Or, for an even more reliable cross browser solution, use an ImageSubmit
button and specify a disabled image that's a 1x1 transparent pixel.  Then
the disabled button will be truly invisible.  Obviously that doesn't work
for non-button form components.

A third possibility is to put the user on a page that just says "waiting for
SMS..." and refreshes itself periodically using the appropriate HTML tags.
At each refresh, the server polls to check for a received SMS.  If the SMS
hasn't been received, then the same page is returned.  Upon finding a
successful hit in the database, the server should send back the real page
with the all the goodies enabled.

Or, as a more sophisticated alternative than the page doing the polling, see
this thread:
http://article.gmane.org/gmane.comp.java.tapestry.user/4047/match=innerhtml



-----Original Message-----
From: Baldur Norddahl [mailto:bbn-tapestry.user@clansoft.dk] 
Sent: Friday, November 14, 2003 3:50 PM
To: Tapestry users
Subject: Bad conditional handling


Hi,

I am working on a system that tells the user to wait until they received an 
SMS and then submit the form. When the SMS is received, our database is 
updated automatically. So if the user submits too early, we will just show 
them the same page again. The html ended up looking something like this:

<html>
  <body>
    <form jwcid="@Form">
      <div jwcid="@Conditional"
condition='ognl:@java.lang.Math@random()>0.5'>
        <input jwcid="@Submit" listener="ognl:listeners.checkSMS" label="I 
received the SMS"/>
      </div>
    </form>
  </body>
<html>

The above is just testcode that shows the problem. The random() call 
symbolises a database that changes state.

When you click on the button, there is 50% change that you get a stale link 
exception.

This apparently means that you can not use conditionals on anything that
other 
users can change, or which changes as result of some external event.

Any ideas how to solve this? I am aware I could use more page files, and
avoid 
using conditional. But the actual program has a zillion small special cases,

and I want to avoid copying the whole page file just to change a single line

with error text.

Thanks,

Baldur


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org