You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Menesty <ah...@gmail.com> on 2010/01/13 15:26:34 UTC

Re: Pass form input from modal window back to the caller page

I have same problem
When open second window, and look in FF with Firebug there disappear form
thats why your button not work if look in Wicket Ajax Debug there will be
msg ERROR: Wicket.Ajax.Call.submitFormById: Trying to submit form with id
'form87' that is not in document.
 

k1dev wrote:
> 
> Hi!
> 
> A rookie question.
> 
> Disclaimer: looked the modal window example but that does not pass values
> back as I understood it.
> 
> I have a page that has a form. The form has an text field and a value
> chooser.
> A value chooser is a modal window that contains a panel that further
> contains a form and a checkbox multiple choice. How can I pass the
> selected value(s) back to the text field (or transformed to a comma
> separated string list)?
> My code also doesn't close the modal window when the submit button
> clicked. What is the right solution?
> Thanks.
> bye
> 
> Here's my code list:
> DemoPage.html:
> ...
> <form wicket:id="form">
> 	
> 	<input type="text" wicket:id="text" />
> 	<div wicket:id="chooserWindow"></div> Chooser 
> 	<br/>
> 	<input wicket:id="button" type="submit" />
> </form>
> ...
> DemoPage.java:
> public class DemoPage extends WebPage {
> 	
> 	private Object text;
> 	private Object itemselection;
> 	
> 	public DemoPage() {
> 		Form form = new Form("form", new CompoundPropertyModel(this)) {
> 			@Override
> 			protected void onSubmit() {
> 				System.out.println("form submitted.");
> 			}
> 		};
> 		add(form);
> 		form.add(new Label("label", "Item codes"));
> 		form.add(new TextField("text"));
> 		form.add(new Button("button"));
> 		
> 		final ModalWindow chooserWindow = new ModalWindow("chooserWindow");
> 		chooserWindow.setOutputMarkupId(true);
> 		form.add(chooserWindow);
> 
> 		chooserWindow.setContent(
> 				new ChooserPanel(chooserWindow.getContentId(), chooserWindow)
> 		);
> 		chooserWindow.setTitle("Make your choice");
> 		chooserWindow.setCookieName("chooserWindow-1");
> 
> 		chooserWindow.setCloseButtonCallback(new
> ModalWindow.CloseButtonCallback()
> 		{
> 			public boolean onCloseButtonClicked(AjaxRequestTarget target) {return
> true;}
> 		});
> 
> 		chooserWindow.setWindowClosedCallback(new
> ModalWindow.WindowClosedCallback()
> 		{
> 			public void onClose(AjaxRequestTarget target) {}
> 		});
> 
> 		form.add(new AjaxLink("chooserLink")
> 		{
> 			public void onClick(AjaxRequestTarget target)
> {chooserWindow.show(target);}
> 		});
> 		
> 	}
> }
> 
> ChooserPanel.html:
> <wicket:panel>
> <div wicket:id="chooser">
> <form wicket:id="chooserForm">
>     
> 	<input wicket:id="button" type="submit" />
> </form>
> </div>
> </wicket:panel>
> 
> ChooserPanel.java:
> public class ChooserPanel extends Panel {
> 
> 	private static final long serialVersionUID = 1L;
> 
> 	private List<ChooserItem> availItems = Arrays.asList(
> 		new ChooserItem("I1","Item 1"),
> 		new ChooserItem("I2","Item 2"),
> 		new ChooserItem("I2","Item 3") );
> 
> 	public ChooserPanel(String id, final  ModalWindow window) {
> 		super(id);
> 
> 	    final WebMarkupContainer parent = new WebMarkupContainer("chooser");
> 	    parent.setOutputMarkupId(true);
> 	    add(parent);
> 
> 		Form form = new Form("chooserForm") {
> 			@Override
> 			protected void onSubmit() {
> 				System.out.println("chooseForm submitted.");
> 			}
> 		};
> 		parent.add(form);
> 		
> 		form.add(new CheckBoxMultipleChoice("itemselection", new
> PropertyModel(this,
> 				"availItems"), new ChoiceRenderer("name", "id")));
> 		form.add(new AjaxButton("button") {
> 			@Override
> 			protected void onSubmit(AjaxRequestTarget target, Form form) {
> 				window.close(target);
> 			}
> 		});
> 	}
> 
> 	public class ChooserItem {
> 		private String id, name;
> 
> 		public ChooserItem(String id, String name) {
> 			this.id = id;
> 			this.name = name;
> 		}
> 	}
> }
> 
> 

-- 
View this message in context: http://old.nabble.com/Pass-form-input-from-modal-window-back-to-the-caller-page-tp14944556p27145826.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org