Question

I'm trying out wiQuery to see if it suits my needs, but I've run into problems with very basic stuff. Consider the following, where I try to control when a Dialog opens and closes, using its open() and close() methods:

HTML:

<input type="submit" wicket:id="open" value="Open dialog"/>    
<div wicket:id="dialog">    
    <input type="submit" wicket:id="close" value="Close"/>    
</div>

Java:

final Dialog dialog = new Dialog("dialog");

add(new Link("open") {
    @Override
    public void onClick() {
        dialog.open();
    }
});

dialog.add(new Link("close") {
    @Override
    public void onClick() {
        dialog.close();
    }   
});

add(dialog);

Thing is, the above doesn't work.

The only way I've got the dialog to actually open & close from my code is by calling setAutoOpen() with either true or false, but it seems strange is this is the only way. (That method's Javadoc says "Sets if this window opens autmatically after the page is loaded." so it clearly should be reserved for a different purpose.)

What's the right way of opening and closing wiQuery Dialogs dynamically in your code?

Was it helpful?

Solution

I have been using the last 2 weeks and I have a similar problem. Try using an AjaxLink this way:

AjaxLink openingLink = new AjaxLink("open")
{

  @Override
  public void onClick(AjaxRequestTarget target)
  {
    // Do something with model
    target.addComponent(content);
    dialog.open(target);
  }

};
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top