You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Christian Dutaret <cd...@gmail.com> on 2006/09/13 12:05:30 UTC
EventListener and PropertySelection
Hi all,
I am trying to change the content of a dropdown list when some event occur.
I am using PropertySelection to render the dropdown list. I assumed that my
listener could change the component's PropertySelectionModel, and that
updateComponent would render the updated content, but this doesn't work.
Shouldn't the "model" binding be re-rendered when updateComponent is called,
or am i doing something wrong?
I am using the latest 4.1.1 snapshot.
Thx for any hint.
My page class:
public abstract void setModelB(IPropertySelectionModel value);
@EventListener(targets="A", events="onchange", submitForm="form")
public void changeA(IRequestCycle cycle) {
this.setModelB(buildNewModelFromDb(a));
cycle.getResponseBuilder().updateComponent("B");
}
My HTML template:
<span jwcid="@Shell" title="Tapestry 4.1 test" browserLogLevel="DEBUG">
<body jwcid="@Body">
<form jwcid="form@Form" success="listener:doNothing">
<span jwcid="A@PropertySelection" model="ognl:modelA" value="ognl:a"/>
<span jwcid="B@PropertySelection" model="ognl:modelB" value="ognl:b"/>
<input type="submit" value="Go"/>
</form>
</body>
</span>
Ch.
Re: EventListener and PropertySelection
Posted by Jani Lindqvist <ac...@gmail.com>.
when i changed the initialization from @InitialValues to finishLoad(...) it
started working. It really is amazingly simple to make this kind of
functionality with EventListener.
On 9/19/06, Jani Lindqvist <ac...@gmail.com> wrote:
>
> Hello,
>
> should the model of component B be persisted or set as property?
>
> I have a page that has the same logic as in this example, but the
> dynamically populated combobox value is always null when the post is done
> (and also in the eventlistener method).
>
> If i change the model to be fetch from a getModel() method that builds the
> model from database, the value is set when the submit is made.
>
> I have 3 different comboboxes, A that is built from the database and it's
> model doesnt change between user selections. It's value is set correctly.
> Combobox B is populated depending on what was selected in combo B and combo
> C is populated depending on the selection of combo B.
>
> now when i try to get the value of combo B in another eventlistener
> method, the value is always null, and the same is also with combo C value.
>
> tapestry version is the latest 4.1
>
> On 9/13/06, Christian Dutaret <cd...@gmail.com> wrote:
> >
> > Hi all,
> >
> > I am trying to change the content of a dropdown list when some event
> > occur.
> > I am using PropertySelection to render the dropdown list. I assumed that
> > my
> > listener could change the component's PropertySelectionModel, and that
> > updateComponent would render the updated content, but this doesn't work.
> > Shouldn't the "model" binding be re-rendered when updateComponent is
> > called,
> > or am i doing something wrong?
> > I am using the latest 4.1.1 snapshot.
> >
> > Thx for any hint.
> >
> > My page class:
> >
> > public abstract void setModelB(IPropertySelectionModel value);
> >
> > @EventListener(targets="A", events="onchange", submitForm="form")
> > public void changeA(IRequestCycle cycle) {
> > this.setModelB(buildNewModelFromDb(a));
> > cycle.getResponseBuilder().updateComponent("B");
> > }
> >
> > My HTML template:
> >
> > <span jwcid="@Shell" title="Tapestry 4.1 test" browserLogLevel="DEBUG">
> > <body jwcid="@Body">
> > <form jwcid="form@Form" success="listener:doNothing">
> > <span jwcid="A@PropertySelection" model="ognl:modelA" value="ognl:a"/>
> > <span jwcid="B@PropertySelection" model="ognl:modelB" value="ognl:b"/>
> > <input type="submit" value="Go"/>
> > </form>
> > </body>
> > </span>
> >
> > Ch.
> >
> >
>
Re: EventListener and PropertySelection
Posted by Jani Lindqvist <ac...@gmail.com>.
Hello,
should the model of component B be persisted or set as property?
I have a page that has the same logic as in this example, but the
dynamically populated combobox value is always null when the post is done
(and also in the eventlistener method).
If i change the model to be fetch from a getModel() method that builds the
model from database, the value is set when the submit is made.
I have 3 different comboboxes, A that is built from the database and it's
model doesnt change between user selections. It's value is set correctly.
Combobox B is populated depending on what was selected in combo B and combo
C is populated depending on the selection of combo B.
now when i try to get the value of combo B in another eventlistener method,
the value is always null, and the same is also with combo C value.
tapestry version is the latest 4.1
On 9/13/06, Christian Dutaret <cd...@gmail.com> wrote:
>
> Hi all,
>
> I am trying to change the content of a dropdown list when some event
> occur.
> I am using PropertySelection to render the dropdown list. I assumed that
> my
> listener could change the component's PropertySelectionModel, and that
> updateComponent would render the updated content, but this doesn't work.
> Shouldn't the "model" binding be re-rendered when updateComponent is
> called,
> or am i doing something wrong?
> I am using the latest 4.1.1 snapshot.
>
> Thx for any hint.
>
> My page class:
>
> public abstract void setModelB(IPropertySelectionModel value);
>
> @EventListener(targets="A", events="onchange", submitForm="form")
> public void changeA(IRequestCycle cycle) {
> this.setModelB(buildNewModelFromDb(a));
> cycle.getResponseBuilder().updateComponent("B");
> }
>
> My HTML template:
>
> <span jwcid="@Shell" title="Tapestry 4.1 test" browserLogLevel="DEBUG">
> <body jwcid="@Body">
> <form jwcid="form@Form" success="listener:doNothing">
> <span jwcid="A@PropertySelection" model="ognl:modelA" value="ognl:a"/>
> <span jwcid="B@PropertySelection" model="ognl:modelB" value="ognl:b"/>
> <input type="submit" value="Go"/>
> </form>
> </body>
> </span>
>
> Ch.
>
>
Re: EventListener and PropertySelection
Posted by Christian Dutaret <cd...@gmail.com>.
Ok thanks Jesse
I think I figured out what the problem was. My model values were initialized
in the pageBeginRender listener, thus resetting the model value I had just
modified in the event listener. After I switched to @InitialValue
annotations instead, it worked.
This brings a question: what is the proper strategy to initialize property
values when using ajax submits? Does finishLoad() does the trick? I am still
a bit confused about when all those methods/listeners are invoked and in
which order
I am now also facing another (probably unrelated) problem : the event is
properly triggered and the select content is updated... but only once. The
second time, the event is not fired, and no XHR request is sent to the
server. I think I remember reading something about this in the list, but I
couldn't put a hand on it. Do you have any idea?
Thx again for all the great job. Although I'm having a tough time making it
work, it really is a nice programming model
Ch.
2006/9/14, Jesse Kuhnert <jk...@gmail.com>:
>
> I'm not sure. Something sounds wrong. How does the work when not using
> ajax?
> I mean, are you sure you are hitting problems related to dynamic behavior
> or
> more with dealing with normal api semantics?
>
> The debug should explicitly show you the content it is updating a
> component
> with. If it has debug statements showing the content then it could be your
> listener method doing something funky.
>
> Mark Reynolds has become my favorite bug reporter of all time. His issues
> usually come with completely self contained projects that I can invoke
> "mvn
> jetty:run" on to see all the gory bug details (documented examples and
> all)
> for myself. One such issue was unrelated to what you are experiencing but
> does include a good example of doing exactly what you are trying to do.
> Perhaps it will be of some help.
>
> http://issues.apache.org/jira/browse/TAPESTRY-1072
>
> Let me know if the documentation hasn't made something clear after you try
> it out and I can attempt updating with whatever relevant information there
> is.
>
> On 9/13/06, Christian Dutaret <cd...@gmail.com> wrote:
> >
> > debug statement says it has updated the content of the component, but
> the
> > options are still the old ones.
> > I also ran the app on debug, and set a breakpoint within the
> > renderComponent() method in the PropertySelection class. It seems it
> still
> > grabs the old value of the model, even after I updated it.
> > I also tried with other bindings, such as "disabled", and it doesn't
> work
> > either. The only binding I can see updated is the "value" binding.
> > Also tried with a surrounding div, still no success.
> >
> > Is there a chance this would work better with the Select/Option
> > components?
> > Didn't try those (I never used them actually).
> > My app really needs to update the full content of a dropdown list
> > depending
> > on some other selections. I used to achieve this with XTile components,
> > and
> > that worked like a charm, but required quite a lot of javascript
> plumbing.
> >
> > 2006/9/13, Jesse Kuhnert <jk...@gmail.com>:
> > >
> > > It should work, I ~think~...What kind of response do you get from the
> > > server
> > > ? (via the dojo debug statements or FireBug ? )
> > >
> > > On 9/13/06, Christian Dutaret <cd...@gmail.com> wrote:
> > > >
> > > > Hi all,
> > > >
> > > > I am trying to change the content of a dropdown list when some event
> > > > occur.
> > > > I am using PropertySelection to render the dropdown list. I assumed
> > that
> > > > my
> > > > listener could change the component's PropertySelectionModel, and
> that
> > > > updateComponent would render the updated content, but this doesn't
> > work.
> > > > Shouldn't the "model" binding be re-rendered when updateComponent is
> > > > called,
> > > > or am i doing something wrong?
> > > > I am using the latest 4.1.1 snapshot.
> > > >
> > > > Thx for any hint.
> > > >
> > > > My page class:
> > > >
> > > > public abstract void setModelB(IPropertySelectionModel value);
> > > >
> > > > @EventListener(targets="A", events="onchange", submitForm="form")
> > > > public void changeA(IRequestCycle cycle) {
> > > > this.setModelB(buildNewModelFromDb(a));
> > > > cycle.getResponseBuilder().updateComponent("B");
> > > > }
> > > >
> > > > My HTML template:
> > > >
> > > > <span jwcid="@Shell" title="Tapestry 4.1 test"
> > browserLogLevel="DEBUG">
> > > > <body jwcid="@Body">
> > > > <form jwcid="form@Form" success="listener:doNothing">
> > > > <span jwcid="A@PropertySelection" model="ognl:modelA"
> value="ognl:a"/>
> > > > <span jwcid="B@PropertySelection" model="ognl:modelB"
> value="ognl:b"/>
> > > > <input type="submit" value="Go"/>
> > > > </form>
> > > > </body>
> > > > </span>
> > > >
> > > > Ch.
> > > >
> > > >
> > >
> > >
> > > --
> > > Jesse Kuhnert
> > > Tapestry/Dojo/(and a dash of TestNG), team member/developer
> > >
> > > Open source based consulting work centered around
> > > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> > >
> > >
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo/(and a dash of TestNG), team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
>
Re: EventListener and PropertySelection
Posted by Jesse Kuhnert <jk...@gmail.com>.
I'm not sure. Something sounds wrong. How does the work when not using ajax?
I mean, are you sure you are hitting problems related to dynamic behavior or
more with dealing with normal api semantics?
The debug should explicitly show you the content it is updating a component
with. If it has debug statements showing the content then it could be your
listener method doing something funky.
Mark Reynolds has become my favorite bug reporter of all time. His issues
usually come with completely self contained projects that I can invoke "mvn
jetty:run" on to see all the gory bug details (documented examples and all)
for myself. One such issue was unrelated to what you are experiencing but
does include a good example of doing exactly what you are trying to do.
Perhaps it will be of some help.
http://issues.apache.org/jira/browse/TAPESTRY-1072
Let me know if the documentation hasn't made something clear after you try
it out and I can attempt updating with whatever relevant information there
is.
On 9/13/06, Christian Dutaret <cd...@gmail.com> wrote:
>
> debug statement says it has updated the content of the component, but the
> options are still the old ones.
> I also ran the app on debug, and set a breakpoint within the
> renderComponent() method in the PropertySelection class. It seems it still
> grabs the old value of the model, even after I updated it.
> I also tried with other bindings, such as "disabled", and it doesn't work
> either. The only binding I can see updated is the "value" binding.
> Also tried with a surrounding div, still no success.
>
> Is there a chance this would work better with the Select/Option
> components?
> Didn't try those (I never used them actually).
> My app really needs to update the full content of a dropdown list
> depending
> on some other selections. I used to achieve this with XTile components,
> and
> that worked like a charm, but required quite a lot of javascript plumbing.
>
> 2006/9/13, Jesse Kuhnert <jk...@gmail.com>:
> >
> > It should work, I ~think~...What kind of response do you get from the
> > server
> > ? (via the dojo debug statements or FireBug ? )
> >
> > On 9/13/06, Christian Dutaret <cd...@gmail.com> wrote:
> > >
> > > Hi all,
> > >
> > > I am trying to change the content of a dropdown list when some event
> > > occur.
> > > I am using PropertySelection to render the dropdown list. I assumed
> that
> > > my
> > > listener could change the component's PropertySelectionModel, and that
> > > updateComponent would render the updated content, but this doesn't
> work.
> > > Shouldn't the "model" binding be re-rendered when updateComponent is
> > > called,
> > > or am i doing something wrong?
> > > I am using the latest 4.1.1 snapshot.
> > >
> > > Thx for any hint.
> > >
> > > My page class:
> > >
> > > public abstract void setModelB(IPropertySelectionModel value);
> > >
> > > @EventListener(targets="A", events="onchange", submitForm="form")
> > > public void changeA(IRequestCycle cycle) {
> > > this.setModelB(buildNewModelFromDb(a));
> > > cycle.getResponseBuilder().updateComponent("B");
> > > }
> > >
> > > My HTML template:
> > >
> > > <span jwcid="@Shell" title="Tapestry 4.1 test"
> browserLogLevel="DEBUG">
> > > <body jwcid="@Body">
> > > <form jwcid="form@Form" success="listener:doNothing">
> > > <span jwcid="A@PropertySelection" model="ognl:modelA" value="ognl:a"/>
> > > <span jwcid="B@PropertySelection" model="ognl:modelB" value="ognl:b"/>
> > > <input type="submit" value="Go"/>
> > > </form>
> > > </body>
> > > </span>
> > >
> > > Ch.
> > >
> > >
> >
> >
> > --
> > Jesse Kuhnert
> > Tapestry/Dojo/(and a dash of TestNG), team member/developer
> >
> > Open source based consulting work centered around
> > dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
> >
> >
>
>
--
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
Re: EventListener and PropertySelection
Posted by Christian Dutaret <cd...@gmail.com>.
debug statement says it has updated the content of the component, but the
options are still the old ones.
I also ran the app on debug, and set a breakpoint within the
renderComponent() method in the PropertySelection class. It seems it still
grabs the old value of the model, even after I updated it.
I also tried with other bindings, such as "disabled", and it doesn't work
either. The only binding I can see updated is the "value" binding.
Also tried with a surrounding div, still no success.
Is there a chance this would work better with the Select/Option components?
Didn't try those (I never used them actually).
My app really needs to update the full content of a dropdown list depending
on some other selections. I used to achieve this with XTile components, and
that worked like a charm, but required quite a lot of javascript plumbing.
2006/9/13, Jesse Kuhnert <jk...@gmail.com>:
>
> It should work, I ~think~...What kind of response do you get from the
> server
> ? (via the dojo debug statements or FireBug ? )
>
> On 9/13/06, Christian Dutaret <cd...@gmail.com> wrote:
> >
> > Hi all,
> >
> > I am trying to change the content of a dropdown list when some event
> > occur.
> > I am using PropertySelection to render the dropdown list. I assumed that
> > my
> > listener could change the component's PropertySelectionModel, and that
> > updateComponent would render the updated content, but this doesn't work.
> > Shouldn't the "model" binding be re-rendered when updateComponent is
> > called,
> > or am i doing something wrong?
> > I am using the latest 4.1.1 snapshot.
> >
> > Thx for any hint.
> >
> > My page class:
> >
> > public abstract void setModelB(IPropertySelectionModel value);
> >
> > @EventListener(targets="A", events="onchange", submitForm="form")
> > public void changeA(IRequestCycle cycle) {
> > this.setModelB(buildNewModelFromDb(a));
> > cycle.getResponseBuilder().updateComponent("B");
> > }
> >
> > My HTML template:
> >
> > <span jwcid="@Shell" title="Tapestry 4.1 test" browserLogLevel="DEBUG">
> > <body jwcid="@Body">
> > <form jwcid="form@Form" success="listener:doNothing">
> > <span jwcid="A@PropertySelection" model="ognl:modelA" value="ognl:a"/>
> > <span jwcid="B@PropertySelection" model="ognl:modelB" value="ognl:b"/>
> > <input type="submit" value="Go"/>
> > </form>
> > </body>
> > </span>
> >
> > Ch.
> >
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo/(and a dash of TestNG), team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
>
Re: EventListener and PropertySelection
Posted by Jesse Kuhnert <jk...@gmail.com>.
It should work, I ~think~...What kind of response do you get from the server
? (via the dojo debug statements or FireBug ? )
On 9/13/06, Christian Dutaret <cd...@gmail.com> wrote:
>
> Hi all,
>
> I am trying to change the content of a dropdown list when some event
> occur.
> I am using PropertySelection to render the dropdown list. I assumed that
> my
> listener could change the component's PropertySelectionModel, and that
> updateComponent would render the updated content, but this doesn't work.
> Shouldn't the "model" binding be re-rendered when updateComponent is
> called,
> or am i doing something wrong?
> I am using the latest 4.1.1 snapshot.
>
> Thx for any hint.
>
> My page class:
>
> public abstract void setModelB(IPropertySelectionModel value);
>
> @EventListener(targets="A", events="onchange", submitForm="form")
> public void changeA(IRequestCycle cycle) {
> this.setModelB(buildNewModelFromDb(a));
> cycle.getResponseBuilder().updateComponent("B");
> }
>
> My HTML template:
>
> <span jwcid="@Shell" title="Tapestry 4.1 test" browserLogLevel="DEBUG">
> <body jwcid="@Body">
> <form jwcid="form@Form" success="listener:doNothing">
> <span jwcid="A@PropertySelection" model="ognl:modelA" value="ognl:a"/>
> <span jwcid="B@PropertySelection" model="ognl:modelB" value="ognl:b"/>
> <input type="submit" value="Go"/>
> </form>
> </body>
> </span>
>
> Ch.
>
>
--
Jesse Kuhnert
Tapestry/Dojo/(and a dash of TestNG), team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com