Re: Newbie BSelect question

Jacob Kjome <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
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
>[email protected]
>http://barracudamvc.org/lists/listinfo/barracuda
Barracuda_scripting.zip (application/zip, 13.3 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.