[rt-users] Need help understanding mason and query args

Ruslan Zakirov ruslan.zakirov at gmail.com
Wed Aug 31 10:49:49 EDT 2005


This problem is not about Mason, but HTML standard. Your form tag has
no action attribute, but this attribute is required by
standard(http://www.w3.org/TR/html401/interact/forms.html#edef-FORM).
There is no defined behaviour of UAs when this attribute is not
defined, but as I think all behave similar they use current URI as
action attribute.
When you click submit button your data goes to "http://...?sMonth=2"
and POST data also has sMonth new value. Mason parse both data
sources: URI params and POST stream for other params, Mason see two
arguments with same name and construct array. You can use this fact to
send mutiply values with one name.

I hope this is right answer :)

On 8/31/05, Kelly F. Hickel <kfh at mqsoftware.com> wrote:
> I'm trying to add bookmarkable urls to the Statistics stuff, and almost
> have it working.  But, I don't seem to understand what mason is trying
> to do with query args.  Mason seems to be doing what it's documented to
> do, I just don't understand why, or what to do about it.
> 
> If you take the text below, and save it to /opt/rt3/local/html/foo.html,
> and then go to the URL http://MYRT/foo.html?sMonth=2 then it will do
> what I expect, the text area will show that the value of the sMonth arg
> is two, and the pull downs showing the start date will display March 1,
> 2010 (ok, maybe that's odd, but this is a stripped down test).
> 
> Now, if you chose a different month and hit the update button, when the
> page gets built again, the sMonth arg is an array ref, with the new
> value you selected, and the original value specified in the URL.  This
> isn't what I expected, although reading the mason doc, it's supposed to
> do this.
> 
> Now, I'm not a mason, apache, or web page developer normally, but most
> of this has seemed straight forward, up to now.  I'm sure that I'm
> missing something basic, can anyone tell me what it is?  (short words,
> please! ;> )
> 
> Here's foo.html:
> 
> <& /Elements/Header, Title => loc("Test page") &>
> <& /Elements/Tabs,  Title => loc("Test page") &>
> 
> <h3>Description</h3>
> <p>This is a test page</p>
> <form method="POST">
> 
> 
> <table>
>   <tr>
>     <td>Start Date:</td>
>     <td>
>       <select name="sMonth" >
> % for ($n=0;$n<=$#months;$n++){
> %       if ($sMonth eq $n){
> %               $selected ="selected";
> %       }else {
> %               $selected ="";
> %       }
>           <option  value=<% $n %> <% $selected %> ><% $months[$n]
> %></option>
> %}
>       </select>
>     </td>
>     <td>
>       <select name="sDay" >
> % for ($n=1;$n<=31;$n++){
> %       if ($sDay == $n ){
> %               $selected ="selected";
> %       }else {
> %               $selected ="";
> %       }
>             <option  value=<% $n %> <% $selected %> ><% $n  %></option>
> % }
>       </select>
>     </td>
>     <td>
>           <select name="sYear">
> %
> % for ($n=0;$n <= scalar @years-1;$n++){
> %       if ($years[$n] == $sYear){
> %               $selected ="selected";
> %       }else{
> %               $selected ="";
> %       }
>           <option value=<% $years[$n] %> <% $selected %> ><% $years[$n]
> %></option>
> % }
>           </select>
>     </td>
>   </tr>
> </table>
> 
> <br>
> <INPUT TYPE="submit" VALUE="<&|/l&>Update Page</&>"</INPUT>
> 
> <br>
> % $debugtext .= "value of sMonth is |$sMonth|\n";
> % $debugtext .= "ref of sMonth is " . ref($sMonth) . "\n";
> % if (ref $sMonth) {$debugtext .= "join of sMonth is " . join(',',
> @$sMonth) . "\n";}
> <TEXTAREA NAME=debugarea COLS=50 ROWS=20><% $debugtext %></TEXTAREA>
> 
> </form>
> 
> <%ARGS>
> $sMonth=>undef
> $sDay=>undef
> $sYear=>undef
> </%ARGS>
> 
> <%INIT>
> my $n;
> my $selected;
> my $debugtext="";
> my @years =('2010', '2009', '2008', '2007', '2006', '2005', '2004',
> '2003' ,'2003' ,'2002');
> my @months=qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
> my %monthsMaxDay = (
>                  0 => 31,  # January
>                  1 => 29,  # February, allow for leap year
>                  2 => 31,  # March
>                  3 => 30,  # April
>                  4 => 31,  # May
>                  5 => 30,  # June
>                  6 => 31,  # July
>                  7 => 31,  # August
>                  8 => 30,  # September
>                  9 => 31,  # October
>                  10=> 30,  # November
>                  11=> 31   # December
>                  );
> 
> </%INIT>
> 
> --
> Kelly F. Hickel
> Senior Software Architect
> MQSoftware, Inc
> 952.345.8677
> kfh at mqsoftware.com
> 
> 
> _______________________________________________
> http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
> 
> Be sure to check out the RT Wiki at http://wiki.bestpractical.com
> 
> Buy your copy of our new book, RT Essentials, today!
> 
> Download a free sample chapter from http://rtbook.bestpractical.com
> 



-- 
Best regards, Ruslan.



More information about the rt-users mailing list