You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by nino martinez wael <ni...@gmail.com> on 2011/03/30 10:12:05 UTC
1.5 visiting forms?
Hi
Can't I use the equals method on forms? How do I detect if 2 forms are
equal across requests?
Below does not work .... But does iterate over the form where equals
should match. But I can see the forms contain different model types,
it's after a form submit...
public class DiscoverFeedBackPanelsVisitor<T> implements
IVisitor<Component, Void> {
private Boolean shouldAccept;
private Form<T> form;
public DiscoverFeedBackPanelsVisitor(Form<T> form) {
setShouldAccept(false);
setForm(form);
}
@Override
public void component(Component component, IVisit<Void> visit) {
if (Form.class.isAssignableFrom(component.getClass())) {
Form<T> possibleForm = Form.class.cast(component);
if (possibleForm.equals(getForm())) {
setShouldAccept(true);
visit.stop();
}
}
}
public void setShouldAccept(Boolean shouldAccept) {
this.shouldAccept = shouldAccept;
}
public Boolean getShouldAccept() {
return shouldAccept;
}
public void setForm(Form<T> form) {
this.form = form;
}
public Form<T> getForm() {
return form;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: 1.5 visiting forms?
Posted by nino martinez wael <ni...@gmail.com>.
I have a page which have several panels of the same type which
contains forms, all those forms have the same id.. Currently I am
considering grabbing the modelobject on the form and equaling those,
this of course means if I have multiple forms editing the same object
on the same page with feedbackpanels those would show each others
messages.. In my case I do not have that. But I thought somehow the
equals method on forms where safe to use across requests...
About iterating over forms, I am doing so :) visitParents does not
allow other types than components AFAIK...
DiscoverFormsVisitor<T> discoverFeedBackPanelsVisitor = new
DiscoverFormsVisitor<T>(
getForm());
message.getReporter().visitParents(Form.class,
discoverFeedBackPanelsVisitor);
return discoverFeedBackPanelsVisitor.getShouldAccept();
2011/3/30 Martin Grigorov <mg...@apache.org>:
> Iterate over Form.class, not Component.class
> You may use form.getId() to check whether this is the form you're looking
> for.
>
> On Wed, Mar 30, 2011 at 11:12 AM, nino martinez wael <
> nino.martinez.wael@gmail.com> wrote:
>
>> Hi
>>
>> Can't I use the equals method on forms? How do I detect if 2 forms are
>> equal across requests?
>>
>> Below does not work .... But does iterate over the form where equals
>> should match. But I can see the forms contain different model types,
>> it's after a form submit...
>>
>>
>>
>>
>> public class DiscoverFeedBackPanelsVisitor<T> implements
>>
>> IVisitor<Component, Void> {
>>
>> private Boolean shouldAccept;
>>
>> private Form<T> form;
>>
>> public DiscoverFeedBackPanelsVisitor(Form<T> form) {
>> setShouldAccept(false);
>> setForm(form);
>> }
>>
>> @Override
>> public void component(Component component, IVisit<Void>
>> visit) {
>>
>> if
>> (Form.class.isAssignableFrom(component.getClass())) {
>> Form<T> possibleForm =
>> Form.class.cast(component);
>> if (possibleForm.equals(getForm())) {
>>
>> setShouldAccept(true);
>> visit.stop();
>> }
>> }
>>
>> }
>>
>> public void setShouldAccept(Boolean shouldAccept) {
>> this.shouldAccept = shouldAccept;
>> }
>>
>> public Boolean getShouldAccept() {
>> return shouldAccept;
>> }
>>
>> public void setForm(Form<T> form) {
>> this.form = form;
>> }
>>
>> public Form<T> getForm() {
>> return form;
>> }
>>
>> }
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: 1.5 visiting forms?
Posted by Martin Grigorov <mg...@apache.org>.
Iterate over Form.class, not Component.class
You may use form.getId() to check whether this is the form you're looking
for.
On Wed, Mar 30, 2011 at 11:12 AM, nino martinez wael <
nino.martinez.wael@gmail.com> wrote:
> Hi
>
> Can't I use the equals method on forms? How do I detect if 2 forms are
> equal across requests?
>
> Below does not work .... But does iterate over the form where equals
> should match. But I can see the forms contain different model types,
> it's after a form submit...
>
>
>
>
> public class DiscoverFeedBackPanelsVisitor<T> implements
>
> IVisitor<Component, Void> {
>
> private Boolean shouldAccept;
>
> private Form<T> form;
>
> public DiscoverFeedBackPanelsVisitor(Form<T> form) {
> setShouldAccept(false);
> setForm(form);
> }
>
> @Override
> public void component(Component component, IVisit<Void>
> visit) {
>
> if
> (Form.class.isAssignableFrom(component.getClass())) {
> Form<T> possibleForm =
> Form.class.cast(component);
> if (possibleForm.equals(getForm())) {
>
> setShouldAccept(true);
> visit.stop();
> }
> }
>
> }
>
> public void setShouldAccept(Boolean shouldAccept) {
> this.shouldAccept = shouldAccept;
> }
>
> public Boolean getShouldAccept() {
> return shouldAccept;
> }
>
> public void setForm(Form<T> form) {
> this.form = form;
> }
>
> public Form<T> getForm() {
> return form;
> }
>
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>