Hi!

I haven't read all of this thread, but I have one suggestion: You should
"hijack" your onclick handlers with javascript to do additional work before
or after calling the original onclick. Don't know how experienced you are
with javascript, but it will look something like this:

var oldOnclick = firstButton.onclick;
firstButton.bind('click', myOwnOnclickListener);
var myOwnOnClickListener = function(event) {
  // My own code here
  oldOnclick();
}


On Fri, Jan 28, 2011 at 6:30 PM, Jessica Sobieski <
jessica.sobie...@gmail.com> wrote:

> Hi Thiago -
>
> > Which buttons? I'm not following you.
>
> To answer your question, I'm talking about these buttons in my template:
>
> <h1>Student Registration</h1>
> <input type="button" onclick="register(123)" value="Student 123"/>
> <input type="button" onclick="register(99)" value="Student 99"/>
> <!-- many more student buttons ... -->
>
> These input buttons come from an HTML stored in a database. I can't change
> that design, and these buttons must call register(studentId) javascript
> function.
>
> So what kind of JavaScript code can I use to connect register(studentId)
> function with the page class registerStudent method?
>
> Adam
>
> On Fri, Jan 28, 2011 at 10:34 AM, Thiago H. de Paula Figueiredo <
> thiag...@gmail.com> wrote:
>
> > On Fri, 28 Jan 2011 13:57:16 -0200, Jessica Sobieski <
> > jessica.sobie...@gmail.com> wrote:
> >
> >  Hello boys!
> >>
> >
> > Hi!
> >
> >
> >  1) I don't control how buttons are generated, therefore they must call
> >> register(studentId) javascript. No way around it.
> >>
> >
> > Which buttons? I'm not following you.
> >
> >
> >>    public String getStudent() {
> >>        return student.getName();
> >>    }
> >> }
> >>
> >> Here is my question:
> >>
> >> 2) I must somehow call Tapestry from register(studentId) method. I am
> >> both, clueless and frustrated as to how to do it.
> >>
> >
> > Just ask us. :)
> >
> > Define an event name for it. My example will use "register". Use the
> > JavaScript code in
> > http://tinybits.blogspot.com/2010/03/new-and-better-zoneupdater.html to
> > correctly handle zone updates. Use a query parameter to pass information.
> > Your code will look like this (not tested):
> >
> >
> > public class StudentCourse {
> >
> >    @Inject @Id("confirmation") private Block confirmationBlock;
> >
> >    @Inject private StudentDao studentDao;
> >
> >    private Student student;
> >
> >    @OnEvent("register") // without this annotation,
> >    Object registerStudent(@RequestParameter("id") Integer studentId) {
> >
> >        student = studentDao.register(studentId);
> >        return confirmationBlock;
> >    }
> >
> >    public String getStudent() {
> >        return student.getName();
> >    }
> > }
> >
> > This is probably a not complete solution, but at least I gave you some
> > hints. :) I hope it helps.
> >
> > --
> > Thiago H. de Paula Figueiredo
> > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> > and instructor
> > Owner, Ars Machina Tecnologia da Informação Ltda.
> > http://www.arsmachina.com.br
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
>

Reply via email to