Re: Question regarding AjaxFormSubmitBehavior

2011-01-21 Thread Daniel Bartl
Many thanks for your feedback!

I am well aware of the fact that HTML spec actually does not allow nested
forms and that wicket is already doing great job while transforming those
nested forms into divs.

I also expected that the bigger form gets submitted as well but only the
nested one processed and the rest ignored, but that's not exactly what's
happening in our case.

The reason for this is that AjaxFormSubmitBehavior always delegates to the
#onFormSubmitted() of the root form

AjaxFormSubmitBehavior, line 135:

getForm().getRootForm().onFormSubmitted();

which then looks up if there is any enabled, visible
IFormSubmittingComponent in the hierarchy that has been triggered. Only in
case that one such IFormSubmittingComponent gets identified, it sets
*formToProcess* to the form of the identified submittingComponent and then
finally invokes

Form, line 920: formToProcess.process(submittingComponent);

The problem with our crazy liitle nested form ;) is that it does not have
any IFormSubmittingComponent but rather a TextField with
AjaxFormSubmitBehavior attached to its "onchange" event that should then
submit the nested form accordingly. This leads to formToProcess being left
assigned to the parentForm that then gets processed at the end:

- from Form#onFormSubmitted():

// this is the root form
Form formToProcess = this;

// find out whether it was a nested form that was
submitted
if (submittingComponent != null)
{
formToProcess = submittingComponent.getForm();
}

// process the form for this request
formToProcess.process(submittingComponent);


We have in the meantime subclassed AjaxFormSubmitBehavior with our own
implementation of AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget target)
method the only difference being the line 135 that was changed from

getForm().getRootForm().onFormSubmitted();

to

getForm().onFormSubmitted();

and did not experience any problems with it, at least so far ;)

Daniel



On Fri, Jan 21, 2011 at 12:25 AM, jcgarciam  wrote:

>
> Adding to Igor's comment, remember that nested form is not allow in HTML
> spec per se, so what wicket is doing a trick where the root form is submit
> but only elements of nested form (which get transform in DIV tag) are
> processed
>
> On Thu, Jan 20, 2011 at 4:47 PM, Igor Vaynberg-2 [via Apache Wicket] <
> ml-node+3228304-1818027643-65...@n4.nabble.com
> 
> >
> > wrote:
>
> > the bigger form needs to be processed because what is submitted is the
> > root form's formtag. however, validation, etc, will probably be
> > delegated only to the inner form.
> >
> > -igor
> >
> > On Thu, Jan 20, 2011 at 4:14 AM, Daniel Bartl <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=3228304&i=0>>
> > wrote:
> >
> > > Have a small question regarding using AjaxFormSubmitBehavoir with
> nested
> > > forms.
> > >
> > > Would like to use it to submit a smaller nested form within a bigger
> > parent
> > > form.
> > >
> > > Even though I passed a nested form as a "*form that will be submitted*"
> > > while calling the following constructor of AjaxFormSubmitBehavoir :
> > >/**
> > > * Construct.
> > > *
> > > * @param form
> > > *   * form that will be submitted*
> > > * @param event
> > > *javascript event this behavior is attached to, like
> > > onclick
> > > */
> > >public AjaxFormSubmitBehavior(Form form, String
> > > event) <- passing nested form here
> > >{
> > >super(event);
> > >__form = form;
> > >
> > >if (form != null)
> > >{
> > >form.setOutputMarkupId(true);
> > >}
> > >}
> > >
> > >
> > > I noticed that the AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget
> > target)
> > > executes the following line first:
> > > "getForm().getRootForm().onFormSubmitted();"
> > > Why does it still delegate to the root form?
> > >
> > > Shouldn't the line be "getForm().onFormSubmitted();" so that the nested
> > form
> > > and possibly its children get processed only.
> > >
> > >
> > > Many thanks!
> > > Daniel
> > >
> >
> > -
> > To unsubscribe, e-mail: [hidden email]<
> http://us

Question regarding AjaxFormSubmitBehavior

2011-01-20 Thread Daniel Bartl
Have a small question regarding using AjaxFormSubmitBehavoir with nested
forms.

Would like to use it to submit a smaller nested form within a bigger parent
form.

Even though I passed a nested form as a "*form that will be submitted*"
while calling the following constructor of AjaxFormSubmitBehavoir :
/**
 * Construct.
 *
 * @param form
 *   * form that will be submitted*
 * @param event
 *javascript event this behavior is attached to, like
onclick
 */
public AjaxFormSubmitBehavior(Form form, String
event) <- passing nested form here
{
super(event);
__form = form;

if (form != null)
{
form.setOutputMarkupId(true);
}
}


I noticed that the AjaxFormSubmitBehavior#onEvent(AjaxRequestTarget target)
executes the following line first:
"getForm().getRootForm().onFormSubmitted();"
Why does it still delegate to the root form?

Shouldn't the line be "getForm().onFormSubmitted();" so that the nested form
and possibly its children get processed only.


Many thanks!
Daniel


Re: How to retrieve ListItem objects from a ListView

2010-12-13 Thread Daniel Bartl
Not really sure if this is what you are trying to achieve but here it is
anyway:

public final List ListView#getModelObject()


On Mon, Dec 13, 2010 at 8:19 PM, drf  wrote:

>
> I have the following use case :
>
> Having built a page using a standard ListView and implementing
> populateItem(), I then want to pass the ListView to  a method, extract the
> contents, and use those contents to build a spreadsheet, cvs file, etc.
> This
> way, there will be no need to repeat the same logic (i.e. the logic used in
> populateItem()), in more than one place.
>
> What is the best way to extract this information?  In the debugger I can
> see
> that the 'children' variable of the ListView has the info I want, but it is
> not clear to me how, using the API, to get the ListView objects from the
> ListView.
>
> As always, help is greatly appreciated.
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/How-to-retrieve-ListItem-objects-from-a-ListView-tp3085988p3085988.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Re: repeters with

2010-12-12 Thread Daniel Bartl
Use RepeatingView#newChildId() in order to generate unique id for each of
your LinkAndImagePanels while iterating through these like this:

for (LinkAndImagePanel panel : allPanels) {
String id = repeater.newChildId();
repeater.add(new LinkAndImagePanel(id, entry));
}


On Sun, Dec 12, 2010 at 10:02 PM, Ladislav DANKO  wrote:

> Panel added
> ...
> view.add(new LinkAndImagePanel("linkandimagepanel"));
> ...
>
> with apropriate panel markup and java code.
>
> Looks works when there is just one image but for two or more images
> there is error:
> Caused by: java.lang.IllegalArgumentException: A child with id
> 'linkandimagepanel' already exists:
>
> How to add multiple panels in repeater? For Image there is param in
> constructor, but for Panel?
>
>
>
>
> > -Original Message-
> > From: Martin Grigorov [mailto:mgrigo...@apache.org]
> > Sent: Sunday, December 12, 2010 11:10 AM
> > To: users@wicket.apache.org
> > Subject: Re: repeters with
> >
> > the repeater should add a Panel (or a Fragment) instead of
> > Image The Panel itself will contain something like:
> >
> > ExternalLink link = new ExternalLink("id", href); add(link);
> > link.add(new Image("image", ...);
> >
> > On Sun, Dec 12, 2010 at 11:07 AM, Ladislav DANKO
> >  wrote:
> >
> > > How is possible to make a nested html tag with AttributeModifier?
> > >
> > > Laco
> > >
> > > > -Original Message-
> > > > From: Per Newgro [mailto:per.new...@gmx.ch]
> > > > Sent: Sunday, December 12, 2010 10:23 AM
> > > > To: users@wicket.apache.org
> > > > Subject: Re: repeters with
> > > >
> > > > You could add Links (instead of the image) and use an
> > > > AttributeModifier for the href.
> > > >
> > > > CHeers
> > > > Per
> > > >
> > > > Am 12.12.2010 09:19, schrieb Ladislav DANKO:
> > > > > Hi,
> > > > >
> > > > > from files in dir I do a list of photos. I do it this way:
> > > > > public class InsertPhotos extends WebPage {
> > > > > public InsertPhotos() throws IOException
> > > > > {
> > > > >
> > > > > Folder folder =
> > > > > ((Start)Application.get()).getPhotosFolder();
> > > > > File[] files = folder.getFiles();
> > > > > List  lList = Arrays.asList(files);
> > > > > Collections.sort(lList);
> > > > >
> > > > > RepeatingView view = new RepeatingView("repeater");
> > > > > while(iterator.hasNext())
> > > > > {
> > > > > iterator.next();
> > > > > String fileName = lList.get(i).getName();
> > > > > String path = "../../photos/" + fileName;
> > > > > i++;
> > > > > view.add(new
> > Image(view.newChildId(), path));
> > > > > }
> > > > > this.add(view);
> > > > > }
> > > > > }
> > > > >
> > > > > and markup:
> > > > > 
> > > > >
> > > > > so resulting markup is:
> > > > >  > style="padding: 2px; width:
> > > > > 90px;"/>
> > > > >  > style="padding: 2px; width:
> > > > > 90px;"/>
> > > > > ...
> > > > >
> > > > > This works but now I need to make a clickable list of
> > photos, so
> > > > > resulting markup should be:
> > > > >  > > > href="resources/../../photos/1.jpg">
> > > > >  > > > > src="resources/../../photos/01.jpg" />   > > > > rel="lightbox[svatebni]" href="resources/../../photos/1.jpg">
> > > > >  > > > > src="resources/../../photos/02.jpg" />  ...
> > > > >
> > > > > I don't know how to add anchor around img tag, can
> > someone help me
> > > > > please? I was searching through doc and list but found nothing.
> > > > >
> > > > > Thanks, Laco
> > > > >
> > > > >
> > > > >
> > > >
> > 
> > > > -
> > > > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > > > For additional commands, e-mail: users-h...@wicket.apache.org
> > > > >
> > > > >
> > > >
> > 
> > > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > > For additional commands, e-mail: users-h...@wicket.apache.org
> > > >
> > > >
> > >
> > >
> > >
> > -
> > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> > > For additional commands, e-mail: users-h...@wicket.apache.org
> > >
> > >
> >
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>