You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by aksarben <rw...@up.com> on 2011/08/18 14:30:24 UTC

Opening Wicket Page in New Browser Tab/Window

How can I make a Wicket page open in a new browser tab/window? I'm not
talking about a popup, but a standard window. I have an app that needs to
open a GIS map viewer in a separate window, based on the user's current
context. The map viewer requires that I submit a form with GPS coordinates,
so I need Wicket to render some simple HTML with the coordinates in hidden
form fields, then submit the form to the map viewer URL as soon as the page
renders. This part is no problem. The problem is that Wicket renders the
HTML in the wrong window.

Currently, I'm using code to generate the link to invoke the map viewer:

*final MenuItem mapMenu = new EnmMenuItem("Map") {
private static final long serialVersionUID = 1L;

@Override protected AbstractLink newLink(final String componentId) {
final SubmitLink link = new SubmitLink(componentId, form) {
private static final long serialVersionUID = 1L;
@Override public void onSubmit() {
selectMapMenu();
}
};
link.setDefaultFormProcessing(false);
link.setEnabled(true);
link.setRenderBodyOnly(false);
link.add(new SimpleAttributeModifier("target", "_blank"));

return link;
}
};*

When the menu item is chosen, the following is invoked:

*@Override protected void selectMapMenu() {
for (final TrackSummary summary : grid.getSelectedItems()) {
try {
setResponsePage(new TrackMapRequestPage(summary.getSystemNumber()));
}
catch (final UnauthorizedPageError ex) {
error(ex.getMessage());
}
}
}*

Despite setting the link target to "_blank", the TrackMapRequestPage opens
in the SAME window as the application. How can I make it open in a DIFFERENT
window so both windows are visible at the same time? My design specs says
the new window shouldn't be a popup.


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Opening-Wicket-Page-in-New-Browser-Tab-Window-tp3752465p3752465.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: Opening Wicket Page in New Browser Tab/Window

Posted by Gregor Kaczor <gk...@gmx.de>.
Some months ago I had the same/similar problem.

You have to add the attribute by overriding onComponentTag(ComponentTag 
tag). As far as I remember you should use the usual 
org.apache.wicket.markup.html.form.Button with it, AjaxButton won't work.

         Form<Void> form = new Form<Void>("ConvertForm") {
             @Override
             protected void onComponentTag(ComponentTag tag) {
                 super.onComponentTag(tag);
                 tag.put("target", "_blank");
             }
         };
-- 
How to find files on the Internet? FindFiles.net <http://findfiles.net>!

On 08/18/2011 02:30 PM, aksarben wrote:
> How can I make a Wicket page open in a new browser tab/window? I'm not
> talking about a popup, but a standard window. I have an app that needs to
> open a GIS map viewer in a separate window, based on the user's current
> context. The map viewer requires that I submit a form with GPS coordinates,
> so I need Wicket to render some simple HTML with the coordinates in hidden
> form fields, then submit the form to the map viewer URL as soon as the page
> renders. This part is no problem. The problem is that Wicket renders the
> HTML in the wrong window.
>
> Currently, I'm using code to generate the link to invoke the map viewer:
>
> *final MenuItem mapMenu = new EnmMenuItem("Map") {
> private static final long serialVersionUID = 1L;
>
> @Override protected AbstractLink newLink(final String componentId) {
> final SubmitLink link = new SubmitLink(componentId, form) {
> private static final long serialVersionUID = 1L;
> @Override public void onSubmit() {
> selectMapMenu();
> }
> };
> link.setDefaultFormProcessing(false);
> link.setEnabled(true);
> link.setRenderBodyOnly(false);
> link.add(new SimpleAttributeModifier("target", "_blank"));
>
> return link;
> }
> };*
>
> When the menu item is chosen, the following is invoked:
>
> *@Override protected void selectMapMenu() {
> for (final TrackSummary summary : grid.getSelectedItems()) {
> try {
> setResponsePage(new TrackMapRequestPage(summary.getSystemNumber()));
> }
> catch (final UnauthorizedPageError ex) {
> error(ex.getMessage());
> }
> }
> }*
>
> Despite setting the link target to "_blank", the TrackMapRequestPage opens
> in the SAME window as the application. How can I make it open in a DIFFERENT
> window so both windows are visible at the same time? My design specs says
> the new window shouldn't be a popup.
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Opening-Wicket-Page-in-New-Browser-Tab-Window-tp3752465p3752465.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: Opening Wicket Page in New Browser Tab/Window

Posted by Dan Retzlaff <dr...@gmail.com>.
On Thu, Aug 18, 2011 at 11:03 AM, aksarben <rw...@up.com> wrote:

> Unfortunately, by that point, it's too late. The small HTML form has
> already
> appeared in my app window, & even the map viewer subsequently opens in a
> new
> window, my app content has been destroyed.
>

Is it necessary to replace your app window's contents with the form? Can't
you just put the form in the existing page (using panel swapping) and submit
it with some dom ready JavaScript?

Dan

Re: Opening Wicket Page in New Browser Tab/Window

Posted by aksarben <rw...@up.com>.
Unfortunately, by that point, it's too late. The small HTML form has already
appeared in my app window, & even the map viewer subsequently opens in a new
window, my app content has been destroyed.

Since I posted this topic, I decided to go with PopupSettings. Since my
corporate target audience all has Internet Explorer, I can tell them to
configure the browser to open popups in a new tab. However, this fix means
that in Firefox (which doesn't offer this option) users still get a free
floating popup, even if that's not what they want.

Sounds like the powers that be ought to think about this for Wicket 1.5.
This is such  a standard browser feature it's absence seems (IMHO) like a
serious deficiency in the framework.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Opening-Wicket-Page-in-New-Browser-Tab-Window-tp3752465p3753218.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: Opening Wicket Page in New Browser Tab/Window

Posted by Dan Retzlaff <dr...@gmail.com>.
s/black/blank/ :)

On Thu, Aug 18, 2011 at 10:41 AM, Dan Retzlaff <dr...@gmail.com> wrote:

> Did you try putting target="_black" on the <form> tag?
>
>
> On Thu, Aug 18, 2011 at 5:30 AM, aksarben <rw...@up.com> wrote:
>
>> How can I make a Wicket page open in a new browser tab/window? I'm not
>> talking about a popup, but a standard window. I have an app that needs to
>> open a GIS map viewer in a separate window, based on the user's current
>> context. The map viewer requires that I submit a form with GPS
>> coordinates,
>> so I need Wicket to render some simple HTML with the coordinates in hidden
>> form fields, then submit the form to the map viewer URL as soon as the
>> page
>> renders. This part is no problem. The problem is that Wicket renders the
>> HTML in the wrong window.
>>
>> Currently, I'm using code to generate the link to invoke the map viewer:
>>
>> *final MenuItem mapMenu = new EnmMenuItem("Map") {
>> private static final long serialVersionUID = 1L;
>>
>> @Override protected AbstractLink newLink(final String componentId) {
>> final SubmitLink link = new SubmitLink(componentId, form) {
>> private static final long serialVersionUID = 1L;
>> @Override public void onSubmit() {
>> selectMapMenu();
>> }
>> };
>> link.setDefaultFormProcessing(false);
>> link.setEnabled(true);
>> link.setRenderBodyOnly(false);
>> link.add(new SimpleAttributeModifier("target", "_blank"));
>>
>> return link;
>> }
>> };*
>>
>> When the menu item is chosen, the following is invoked:
>>
>> *@Override protected void selectMapMenu() {
>> for (final TrackSummary summary : grid.getSelectedItems()) {
>> try {
>> setResponsePage(new TrackMapRequestPage(summary.getSystemNumber()));
>> }
>> catch (final UnauthorizedPageError ex) {
>> error(ex.getMessage());
>> }
>> }
>> }*
>>
>> Despite setting the link target to "_blank", the TrackMapRequestPage opens
>> in the SAME window as the application. How can I make it open in a
>> DIFFERENT
>> window so both windows are visible at the same time? My design specs says
>> the new window shouldn't be a popup.
>>
>>
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Opening-Wicket-Page-in-New-Browser-Tab-Window-tp3752465p3752465.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: Opening Wicket Page in New Browser Tab/Window

Posted by Dan Retzlaff <dr...@gmail.com>.
Did you try putting target="_black" on the <form> tag?

On Thu, Aug 18, 2011 at 5:30 AM, aksarben <rw...@up.com> wrote:

> How can I make a Wicket page open in a new browser tab/window? I'm not
> talking about a popup, but a standard window. I have an app that needs to
> open a GIS map viewer in a separate window, based on the user's current
> context. The map viewer requires that I submit a form with GPS coordinates,
> so I need Wicket to render some simple HTML with the coordinates in hidden
> form fields, then submit the form to the map viewer URL as soon as the page
> renders. This part is no problem. The problem is that Wicket renders the
> HTML in the wrong window.
>
> Currently, I'm using code to generate the link to invoke the map viewer:
>
> *final MenuItem mapMenu = new EnmMenuItem("Map") {
> private static final long serialVersionUID = 1L;
>
> @Override protected AbstractLink newLink(final String componentId) {
> final SubmitLink link = new SubmitLink(componentId, form) {
> private static final long serialVersionUID = 1L;
> @Override public void onSubmit() {
> selectMapMenu();
> }
> };
> link.setDefaultFormProcessing(false);
> link.setEnabled(true);
> link.setRenderBodyOnly(false);
> link.add(new SimpleAttributeModifier("target", "_blank"));
>
> return link;
> }
> };*
>
> When the menu item is chosen, the following is invoked:
>
> *@Override protected void selectMapMenu() {
> for (final TrackSummary summary : grid.getSelectedItems()) {
> try {
> setResponsePage(new TrackMapRequestPage(summary.getSystemNumber()));
> }
> catch (final UnauthorizedPageError ex) {
> error(ex.getMessage());
> }
> }
> }*
>
> Despite setting the link target to "_blank", the TrackMapRequestPage opens
> in the SAME window as the application. How can I make it open in a
> DIFFERENT
> window so both windows are visible at the same time? My design specs says
> the new window shouldn't be a popup.
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Opening-Wicket-Page-in-New-Browser-Tab-Window-tp3752465p3752465.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
>
>