[prev in list] [next in list] [prev in thread] [next in thread] 

List:       barracuda
Subject:    Re: [Barracuda] Newbie BSelect question
From:       Jacob Kjome <hoju () visi ! com>
Date:       2003-04-11 9:44:01
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Normand,

Sorry to have missed your post.  I think it got lost when it got sent over 
the weekend.  Hopefully I have a decent answer for you...

You can find the option selected in your event handler which is set by 
binding a BAction element to your select or form element.  See this page 
for a number of examples...
http://barracudamvc.org/Barracuda/RedirectEx1

What generally happens with a BAction bound to a form element is that it 
first changes the "action" attribute of the form and then submits the 
form.  So, you are not really "defining" a javascript event handler.  It is 
being generated for you via the binding of the BAction element to the 
node.  The only handler you define is the handler associated with the event 
or URL that you provided to the BAction component.

The source for this is at...
Barracuda/src/org/enhydra/barracuda/examples/xmlc/RedirectEx1.html
and
Barracuda/src/org/enhydra/barracuda/examples/xmlc/RedirectEx1.java

Most times you would probably not want the select list to trigger the form 
submit.  In most cases you'd probably bind the BAction to a submit, button, 
or form element.  Actually, you probably want to do this because, unless 
you are using the very latest CVS source, there is a bug where any 
arbitrary element is disabled before being sent.  Browsers like Mozilla 
won't send disabled form elements.  I have fixed things so that only input 
elements and buttons of type "submit", "button", and "image" get 
disabled.  The reason for disabling is to avoid multiple submits but this 
was a little overzealous.  The next release of Barracuda will have this fix.

Note, I am working on some changes that I have in my own tree for you to 
put your own client-side form validation checking in front of the code that 
submits stuff giving you the opportunity to return false to avoid the 
submit.  I'm attaching the code in case you want to try it out.  Actually, 
it would be helpful if others would look at this to see if they find any 
problems with it.


Jake

At 05:55 PM 4/4/2003 -0500, you wrote:
>I have been trying to understand Barracuda with the view to apply it to
>building a fairly extensive web application (actually porting and expanding
>an existing application written ColdFusion / javascript / servlets).
>Barracuda seems very promising but daunting. I need help in order to grasp
>the basics.
>
>For instance: I need to create a select element in an html page, which will
>allow the user to choose an action. In other words, selecting an option and
>then pressing a button will take the user to a page, according to which
>option was chosen.
>
>Am I right in assuming that, since choosing the option happens on the client
>side, you have to define a form on the page and then either:
>- define a javascript event handler on the button, that sets the form action
>according to the option chosen, and submits the form (this is what I would do
>spontaneously); or
>- submit the form and handle it completely on the server side (redirecting
>according to option chosen)?
>
>If that is so, why is Barracuda offering the possibility to link a BAction to
>a BSelect, or the addEventListener() method on BSelect? What is the point in
>taking an action based on an event fired by BSelect, if you have no way of
>knowing which option was selected?
>
>I know these sound like elementary questions, but I have put a lot of time
>trying to understand the components and especially their relationship with
>the event model. I have read the appropriate tutorials, as well as looked at
>the source code of the examples and of the components themselves.
>
>As mentioned above I have experience with web appications and also with 
>Swing,
>but none of that seems relevant here.
>
>Perhaps I am missing something obvious... Could someone be kind enough to 
>post
>relevant snippets of html and java code that would accomplish what I am
>describing?
>
>--
>Normand Fortier
>_______________________________________________
>Barracuda mailing list
>Barracuda@barracudamvc.org
>http://barracudamvc.org/lists/listinfo/barracuda

[Attachment #5 (text/html)]

<html>
<body>
<font size=3><br>
Hi Normand,<br><br>
Sorry to have missed your post.&nbsp; I think it got lost when it got
sent over the weekend.&nbsp; Hopefully I have a decent answer for
you...<br><br>
You can find the option selected in your event handler which is set by
binding a BAction element to your select or form element.&nbsp; See this
page for a number of examples...<br>
<a href="http://barracudamvc.org/Barracuda/RedirectEx1" \
eudora="autourl">http://barracudamvc.org/Barracuda/RedirectEx1</a><br><br> What \
generally happens with a BAction bound to a form element is that it first changes the \
&quot;action&quot; attribute of the form and then submits the form.&nbsp; So, you are \
not really &quot;defining&quot; a javascript event handler.&nbsp; It is being \
generated for you via the binding of the BAction element to the node.&nbsp; The only \
handler you define is the handler associated with the event or URL that you provided
to the BAction component.<br><br>
The source for this is at...<br>
Barracuda/src/org/enhydra/barracuda/examples/xmlc/RedirectEx1.html<br>
and<br>
Barracuda/src/org/enhydra/barracuda/examples/xmlc/RedirectEx1.java<br><br>
Most times you would probably not want the select list to trigger the
form submit.&nbsp; In most cases you'd probably bind the BAction to a
submit, button, or form element.&nbsp; Actually, you probably want to do
this because, unless you are using the very latest CVS source, there is a
bug where any arbitrary element is disabled before being sent.&nbsp;
Browsers like Mozilla won't send disabled form elements.&nbsp; I have
fixed things so that only input elements and buttons of type
&quot;submit&quot;, &quot;button&quot;, and &quot;image&quot; get
disabled.&nbsp; The reason for disabling is to avoid multiple submits but
this was a little overzealous.&nbsp; The next release of Barracuda will
have this fix.<br><br>
Note, I am working on some changes that I have in my own tree for you to
put your own client-side form validation checking in front of the code
that submits stuff giving you the opportunity to return false to avoid
the submit.&nbsp; I'm attaching the code in case you want to try it
out.&nbsp; Actually, it would be helpful if others would look at this to
see if they find any problems with it.<br><br>
<br>
Jake<br><br>
At 05:55 PM 4/4/2003 -0500, you wrote:<br>
<blockquote type=cite class=cite cite>I have been trying to understand
Barracuda with the view to apply it to <br>
building a fairly extensive web application (actually porting and
expanding <br>
an existing application written ColdFusion / javascript / servlets).
<br>
Barracuda seems very promising but daunting. I need help in order to
grasp <br>
the basics.<br><br>
For instance: I need to create a select element in an html page, which
will <br>
allow the user to choose an action. In other words, selecting an option
and <br>
then pressing a button will take the user to a page, according to which
<br>
option was chosen.<br><br>
Am I right in assuming that, since choosing the option happens on the
client <br>
side, you have to define a form on the page and then either:<br>
- define a javascript event handler on the button, that sets the form
action <br>
according to the option chosen, and submits the form (this is what I
would do <br>
spontaneously); or <br>
- submit the form and handle it completely on the server side
(redirecting <br>
according to option chosen)?<br><br>
If that is so, why is Barracuda offering the possibility to link a
BAction to <br>
a BSelect, or the addEventListener() method on BSelect? What is the point
in <br>
taking an action based on an event fired by BSelect, if you have no way
of <br>
knowing which option was selected?<br><br>
I know these sound like elementary questions, but I have put a lot of
time <br>
trying to understand the components and especially their relationship
with <br>
the event model. I have read the appropriate tutorials, as well as looked
at <br>
the source code of the examples and of the components
themselves.<br><br>
As mentioned above I have experience with web appications and also with
Swing, <br>
but none of that seems relevant here.<br><br>
Perhaps I am missing something obvious... Could someone be kind enough to
post <br>
relevant snippets of html and java code that would accomplish what I am
<br>
describing?<br><br>
-- <br>
Normand Fortier<br>
_______________________________________________<br>
Barracuda mailing list<br>
Barracuda@barracudamvc.org<br>
<a href="http://barracudamvc.org/lists/listinfo/barracuda" \
eudora="autourl">http://barracudamvc.org/lists/listinfo/barracuda</a></font></blockquote></body>
 </html>


["Barracuda_scripting.zip" (application/zip)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic