You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by cabra <bh...@bk.ru> on 2010/09/26 16:31:16 UTC

modalWindow setContent

Hi all. on my page i have search form. All i need is:
user makes some input and then presses search button, and on this button
click form should be submitted and modalwindow with search results should
uppear.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/modalWindow-setContent-tp2714385p2714385.html
Sent from the Users forum 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


Re: modalWindow setContent

Posted by Mathias Nilsson <wi...@gmail.com>.
I'm not entire sure what you want to achive.

This example is to open a new window that extends WebPage. You don't need to
call setContent.



public class HomePage extends WebPage {

	private static final long serialVersionUID = 1L;
	private String content; // This is a variable to hold the search result
	
    public HomePage(final PageParameters parameters) {
    	
    	Form<Void> form = new Form<Void>( "form" );
    	final TextField<String> field = new TextField<String>( "field" );
    	form.add( field );
    	
    	// Create modal window
    	final ModalWindow window = new ModalWindow( "window" );
    	window.setPageMapName("window-1");
    	window.setCookieName("window-1");

    	window.setPageCreator(new ModalWindow.PageCreator() {
			private static final long serialVersionUID = 1L;
				public org.apache.wicket.Page createPage() {
	               return new MyWebPage( content ); // A new Page with the
search result
	            }
	        });
    	window.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
			private static final long serialVersionUID = 1L;
				public void onClose(AjaxRequestTarget target) {
	            }
	        });
    	window.setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
			private static final long serialVersionUID = 1L;

				public boolean onCloseButtonClicked(AjaxRequestTarget target) {
	                return true;
	            }
	        });
		
		add( window );
    	
    	
    	AjaxSubmitLink submit = new AjaxSubmitLink( "submit" ){
			@Override
			protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
				content = field.getDefaultModelObjectAsString();
                                window.show( target );
			}
    		
    	};
    	
    	form.add( submit );
    	add( submit );
    	
    	
    	
    }
}
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/modalWindow-setContent-tp2714385p2714624.html
Sent from the Users forum 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


Re: modalWindow setContent

Posted by cabra <bh...@bk.ru>.
Hi all.
Thank you for replies but this is not what i want.

The problem is that as I understood I should do like this

modal.setcontent and then add(modal)

but i need to do modal.setcontent after form is submitted.
will this work or not?
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/modalWindow-setContent-tp2714385p2714559.html
Sent from the Users forum 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


Re: modalWindow setContent

Posted by Alexander Morozov <al...@gmail.com>.
check this:

  modalWindow.setContent(new SearchResults(modalWindow .getContentId(),
modalWindow, resultModel)); 
  /* FIXME use ModalWindow.show(target) instead
     target.addComponent(modalWindow, "modal"); 
  */
  logger.info("hey hey"); 
  modalWindow.show(target); 
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/modalWindow-setContent-tp2714385p2714959.html
Sent from the Users forum 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


Re: modalWindow setContent

Posted by cabra <bh...@bk.ru>.
Hi this is part of my code. Something like that:


			final DateTimeField from = new DateTimeField("start", new Model());
			add(from);
			final DateTimeField till = new DateTimeField("end", new Model());
			add(till);
			final DropDownChoice ddc3 = new DropDownChoice<String>("types", new
Model(), Types.toStringList());
	        final ModalWindow modalWindow = new ModalWindow("modal");
	        modalWindow.setCookieName("resultModal");
	        modalWindow.setOutputMarkupId(true);
	        add(modalWindow);
			add(ddc3);

			add(new AjaxButton("search") {
		        private static final long serialVersionUID = 1L;

				protected void onSubmit(AjaxRequestTarget target, Form form) {
					super.onSubmit();
					final HashMap<String,Object> params = new HashMap<String,Object>();
					if(from.getConvertedInput() != null){
						logger.info("from");
						Date fromDate = from.getConvertedInput();
						params.put("from", fromDate);
					}
					if(till.getConvertedInput() != null){
						logger.info("till");
						Date tillDate = till.getConvertedInput();
						params.put("till", tillDate);
					}
					if(ddc1.getConvertedInput() != null){
						logger.info("ddc1");
						String channel =
(String)ddc1.getChoices().get(Integer.parseInt(ddc1.getValue()));
						params.put("channel", channel);
					}
					if(ddc2.getConvertedInput() != null ){
						logger.info("ddc2");
						String program =
(String)ddc2.getChoices().get(Integer.parseInt(ddc2.getValue()));//
						params.put("program", program);
					}
					if(ddc3.getConvertedInput() != null){
						logger.info("ddc3");
						String type = (String) ddc3.getValue();
						params.put("type", type);
					}
					if(params.values().size() > 0){
						IModel resultModel = new LoadableDetachableModel() {
							private static final long serialVersionUID = 1L;

							protected Object load() {
				                return getProgramService().getSearchResults(params);
				            }
				        };						

				        modalWindow.setContent(new SearchResults(modalWindow
.getContentId(), modalWindow, resultModel));
				        target.addComponent(modalWindow, "modal");
				        logger.info("hey hey");
				        modalWindow.show(target);
					}
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/modalWindow-setContent-tp2714385p2714631.html
Sent from the Users forum 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


Re: modalWindow setContent

Posted by Mathias Nilsson <wi...@gmail.com>.
http://wicketstuff.org/wicket14/ajax/ http://wicketstuff.org/wicket14/ajax/ 

Click on ModalWindow for example
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/modalWindow-setContent-tp2714385p2714490.html
Sent from the Users forum 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


Re: modalWindow setContent

Posted by Alexander Morozov <al...@gmail.com>.
Hi

You need to add modal window placeholder tag  on the page and call, attach
ModalWindow instance to it and call modalWindowInstance.show(target) within
onSubmit(AjaxRequestTarget target) method on the submit button.


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/modalWindow-setContent-tp2714385p2714448.html
Sent from the Users forum 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