Thanks for the answers. Because these are my first steps I don't
know how to get the selected item value and how to open a new html
page. The following code shows my tries:

Here the html code to create the form and a link

        <form name="colors" id="colors">
      <select name="color" 
onChange="ognl:'javascript:document.form.colors.options[document.form.colors.selectedIndex].value'">
        <option selected="selected" value="empty">select color</option>
        <span jwcid="@Foreach" source="ognl:colors" value="ognl:currentColor" 
index="ognl:currentColorIndex">
          <span jwcid="@InsertText" value="ognl:colorString" raw="true"/>
                </span>
      </select>
    </form>

    <form jwcid="@Form">
     <select jwcid="[EMAIL PROTECTED]" multiple="ognl:false"  
validators="validators:required" onChange="ognl:...">
      <span jwcid="@Foreach" source="ognl:colors" value="ognl:currentColor" 
index="ognl:currentColorIndex">
       <option jwcid="@Option" selected="ognl:selection[currentColorIndex]" 
label="ognl:currentColor"/>
      </span>
     </select>
    </form>

<a href="#" jwcid="@PageLink" page="ognl:currentColor"> Open page with color 
<span jwcid="@Insert" value="ognl:currentColor">...</span></a>


and the java class

import org.apache.tapestry.event.PageBeginRenderListener;

public abstract class Home extends BasePage implements
PageBeginRenderListener{

          private String[] colors = {"blue", "red", "green", "yellow",
"a", "b", "c"};

          public abstract int getCurrentColorIndex();
          public abstract String getCurrentColor();
          public abstract boolean[] getSelection();
          public abstract void setSelection(boolean[] selection);

          public String getColorString() {
                  return "<option value='" +
                  getCurrentColorIndex() + "'>" +
                  colors[getCurrentColorIndex()] +
                  "</option>";
          }

          public String[] getColors() {
            return colors;
          }

          public void pageBeginRender(PageEvent event) {
            if (getSelection() == null) {
              setSelection(new boolean[colors.length]);
            }
          }
        }


Thanks for any help
Hans

On Sun, 1 Apr 2007, Martino Piccinato wrote:

> I the problem is just opening a new page (simple javascript with no async
> interaction with server) you could just extend tapestry list component
> adding the desired javascript.
>
> On 4/1/07, Yiannis Mavroukakis <[EMAIL PROTECTED]> wrote:
> >
> > Hi Hans,
> >
> > IMHO this is a nice candidate for the @EventListener.
> > Check out http://tapestry.apache.org/tapestry4.1/ajax/eventlistener.htmlfor 
> > more details and examples.
> >
> >
> > -----Original Message-----
> > From:   Hans Braxmeier [mailto:[EMAIL PROTECTED]
> > Sent:   Sun 01/04/2007 11:26
> > To:     users@tapestry.apache.org
> > Cc:
> > Subject:        list box onchange
> >
> >
> > Hi,
> >
> > I'm very new to tapestry and doing the first steps.
> >
> > Does anybody know how to realize a list box, that opens onChange
> > a new html page? Everything works well with html and javascript,
> > but I could not get it work in tapestry.
> >
> > the html code:
> >
> >       <form name="namelist">
> >       <select class="choose" name="list" size="1" onChange="getValues()">
> >         <option selected="selected" value="empty">select name</option>
> >         <option value="john">John</option>
> >         <option value="tom">Tom</option>
> >       </select>
> >       </form>
> >
> > the js code:
> >
> > function getValues() {
> >   var name =
> > document.form.list.options[document.form.list.selectedIndex].value;
> >   if (name == "empty") window.location.href = "index.html";
> >   else window.location.href = name + ".html";
> > }
> >
> > Thanks for any help
> > Hans
> >
> >
> > --
> >
> > Abteilungen SAI
> > und Stochastik
> >
> > Universität Ulm
> > Helmholtzstr. 18
> > Raum E22
> > 0731/50-23575
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> > ________________________________________________________________________
> > This e-mail has been scanned for all known viruses.
> >
> >
> >
> >
> > Note:__________________________________________________________________
> > This message is for the named person's use only. It may contain
> > confidential, proprietary or legally privileged information. No
> > confidentiality or privilege is waived or lost by any mistransmission.
> > If you receive this message in error, please immediately delete it and
> > all copies of it from your system, destroy any hard copies of it and
> > notify the sender. You must not, directly or indirectly, use, disclose,
> > distribute, print, or copy any part of this message if you are not the
> > intended recipient. Jaguar Freight Services and any of its subsidiaries
> > each reserve the right to monitor all e-mail communications through its
> > networks.
> > Any views expressed in this message are those of the individual sender,
> > except where the message states otherwise and the sender is authorized
> > to state them to be the views of any such entity.
> > ________________________________________________________________________
> > This e-mail has been scanned for all known viruses.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>


--

Abteilungen SAI
und Stochastik

Universität Ulm
Helmholtzstr. 18
Raum E22
0731/50-23575

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to