You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by RoyBatty <ma...@afjochnick.net> on 2009/03/18 12:56:29 UTC

reloading ajaxlaxyloadpanel via ajaxbutton

Hello there, 

i have a panelclass which i have a form with a button (well 2 actually but
doesn't matter for the problem i have), and below the form a div with
"results". 

When you enter an sql in the form field and click the button, i want to
submit it via ajax, do the sql, and print the resultset in the
"results"-div. Easy enough, right?

Well, it works, IF i use a label for the results-div, but i thought it'd be
nifty to have a progress thingie while the sql is executed, so i'm trying to
exchange the label with an "ajaxlazyload" panel. I'm not very successful
sofar... when the page loads first time all is initialized properly, but
nothing happens when i click on the ajax button.

Am I missing something? is it not possible to update the lazyloadpanel?? I'm
new at Wicket so there's probably something i don't understand.

My panel:
public class TestPanel extends AbstractPanel {

	AjaxLazyLoadPanel test;
	private String sql;

	public TestPanel(final String id) {
                super(id);
                add(new TestForm("testForm",this));
		test = new AjaxLazyLoadPanel("testResults"){
			public Component getLazyLoadComponent(String markupId) {
				return new Label(markupId, getTestData());
			}
		};
		test.setOutputMarkupId(true);
	        add(test);
       }
...
My form:
private class TestForm extends Form {

		FreemarkerTestPanel panel;

		public FreemarkerTestForm(String id, FreemarkerTestPanel panel) {
	            super(id);
	            this.panel= panel;
	            add(new TextArea("sql", new PropertyModel(panel, "sql")));
	            add(new TextArea("script", new PropertyModel(panel,
"script")));
	            SqlButton cancel = new SqlButton("sqlbutton");
	            add(cancel);
               }

        public void onSubmit() {}

	    private class SqlButton extends AjaxButton {

		    public SqlButton(String id) {
			    super(id);
		    }

		    protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
			    System.out.println("SqlButton;onsubmit");
			    target.addComponent(test);
		    }
.......

Then there's a getTestData() that runs the actual sql, which is called by my
AjaxLazyLoadPanel as you can see.


What happens is that the ajaxbutton's onsubmit method is called fine, but
the markup div with the id "testResults" is not updated, and the
"getTestData()" method is never called.


If i just switch the test parameter from ajaxlazyloadpanel to a normal label
everything works fine (i then make the ajaxbutton onsubmit execute the
getTestData and assign it to a property that the label reads.


I would much appreciate any pointers.

-- 
View this message in context: http://www.nabble.com/reloading-ajaxlaxyloadpanel-via-ajaxbutton-tp22577518p22577518.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