you can output some javascript using the ajaxrequesttarget that does window.open

-igor

On Fri, Dec 11, 2009 at 12:31 PM, Jeff Andersen <[email protected]> wrote:
> I need to know how I can post a form to a new window using an AjaxSubmitLink. 
>  I have a small page where a user can make a few setting changes and then 
> either save those settings (using an AjaxButton) or preview those settings 
> (using an AjaxSubmitLink) in a new window.  The problem is, I can't figure 
> out how to make the preview button open in a new window.  Since there are no 
> popup settings for an AjaxSubmitLink, I'm not sure what to do.
>
> I've tried searching for a solution and the best I could find indicated that 
> I should use a form target="_blank".  But that doesn't seem to change 
> anything.  The call to setResponsePage always results in the preview page 
> opening in the same browser window.
>
> Below is the code for my submit and preview buttons:
>
>        AjaxButton submit = new AjaxButton("websiteSetting-submit-button") {
>
>           �...@override
>            protected void onError(AjaxRequestTarget target, Form<?> form) {
>                super.onError(target, form);
>                feedbackPanel.add(new AttributeModifier("style", true, new 
> Model("color:red;")));
>                target.addComponent(feedbackPanel);
>                target.addComponent(form);
>            }
>
>           �...@override
>            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
>                processSubmission(target, form, false);
>            }
>
>            //Prepending the call to set the target to nothing for normal form 
> submission.
>           �...@override
>            protected IAjaxCallDecorator getAjaxCallDecorator() {
>                return new 
> AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator()) {
>
>                    private static final long serialVersionUID = 1L;
>
>                   �...@override
>                    public CharSequence preDecorateScript(CharSequence script) 
> {
>                        String sJs = "document.getElementById('" + 
> form.getMarkupId() + "').target = '';";
>
>                        return sJs + script;
>                    }
>                };
>            }
>        };
>
>        AjaxSubmitLink preview = new 
> AjaxSubmitLink("websiteSetting-preview-button") {
>
>           �...@override
>            protected void onError(AjaxRequestTarget target, Form<?> form) {
>                super.onError(target, form);
>                feedbackPanel.add(new AttributeModifier("style", true, new 
> Model("color:red;")));
>                target.addComponent(feedbackPanel);
>                target.addComponent(form);
>            }
>
>           �...@override
>            protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
>                setResponsePage(HomePage.class);
>            }
>
>            //Prepending the call to set the target to "_blank" for preview 
> submission to new window.
>           �...@override
>            protected IAjaxCallDecorator getAjaxCallDecorator() {
>                return new 
> AjaxPreprocessingCallDecorator(super.getAjaxCallDecorator()) {
>
>                    private static final long serialVersionUID = 1L;
>
>                   �...@override
>                    public CharSequence preDecorateScript(CharSequence script) 
> {
>                        String sJs = "document.getElementById('" + 
> form.getMarkupId() + "').target = '_blank';alert(document.getElementById('" + 
> form.getMarkupId() + "').target);";
>
>                        return sJs + script;
>                    }
>                };
>            }
>        };
>
> Thanks,
> Jeff
>
> * This e-mail and any files transmitted with it may contain confidential 
> and/or privileged information and intended solely for the use of the 
> individual or entity to whom they are addressed. If you are not the addressee 
> or authorized to receive this for the addressee, you must not use, copy, 
> disclose, or take any action based on this message or any information herein. 
> If you have received this message in error, please advise the sender 
> immediately by reply e-mail and delete this message.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to