Enjoy :)

As you can see, this is accomplished with only a few lines of actual code.
Of course, it is easy to extend with parameters to open up event type,
window attributes and so on... So far, I don't need anything like that.

PopupPageLink.java:

@IncludeJavaScriptLibrary("PopupPageLink.js")
public class PopupPageLink {

  @Inject
  private ComponentResources resources;

  @Environmental
  private RenderSupport renderSupport;

  @InjectContainer
  private ClientElement container;

  @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
  private String page;

  @Parameter
  private Object[] context;

  void afterRender() {
    Link link = resources.createPageLink(page, true, context);
    renderSupport.addScript("new PopupPageLink('%s', '%s');",
container.getClientId(), link);
  }
}

PopupPageLink.js:

var PopupPageLink = Class.create();
PopupPageLink.prototype = {
    initialize: function(id, link) {
        this.element = $(id);
        this.link = link;
        Event.observe(this.element, 'click',
this.onclick.bindAsEventListener(this));
    },
    onclick: function() {
        var width = 800;
        var height = 600;
        var    name = 'dialogWindow';
        var win = window.open(this.link,name,'width=' + width + ',height=' +
height +
',resizable=yes,scrollbars=yes,menubar=no,screenX=0,screenY=0,left=0,top=0'
);
        win.focus();
    }
}

On Sun, Mar 8, 2009 at 6:49 PM, Tan cyb...@n <quesoft.cyber...@gmail.com>wrote:

> Yes Please.
>
> On Sun, Mar 8, 2009 at 11:23 PM, Andy Pahne <andy.pa...@googlemail.com
> >wrote:
>
> >
> > Yes please, would be nice to see...
> >
> > Andy
> >
> >
> > Inge Solvoll schrieb:
> >
> >> I created a mixin, PopupPageLink, that opens a new window containing a
> the
> >> link, with window.open() in javascript. It gives you more control over
> the
> >> opened window. Also, you can add the mixin to any element, not just a
> >> link,
> >> just make a hook to the onclick event.
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> > For additional commands, e-mail: users-h...@tapestry.apache.org
> >
> >
>

Reply via email to