How to open an external web page from a Wicket modal dialog - wicket

I have a modal dialog in Wicket that contains a link. I need to open an external web page (for example, http://www.google.com) by clicking on the link. The target of the link is set dynamically. How can I do this?
I think that my question hasn't been so clear(I apologize for that). I need to open Web page from modal dialog. Actually, I can explain the problem in the example of modal dialog that #Don Roby has proposed me (wicketstuff.org/wicket14/ajax/modal-window.0). If we click the "Show modal dialog with a page" link in the example, there will be shown the modal dialog with another link called "Open another modal dialog". By clicking on that link, I want to open Web page (for example: www.google.com). My question is: how to open a Web page in this situation?

You can use a PageCreator (instead of setContent()), and return a RedirectPage:
ModalWindow modal = new ModalWindow("modal");
modal.setPageCreator(new ModalWindow.PageCreator() {
#Override
public Page createPage() {
return new RedirectPage("http://www.google.com");
}
});
add(modal);

I understand what you mean.
I have found the solution here :
http://apache-wicket.1842946.n4.nabble.com/How-to-redirect-from-a-ModalWindow-td1889646.html
onClick( AjaxRequestTarget target ){
target.appendJavascript( "Wicket.Window.unloadConfirmation = false;" );
modal.show( target);
}

It sounds like you already know how to deal with the modal, but there's an example of doing it here. Opening an external link is not difficult, and there's an example of doing it here.

how do you create your link ?
did you tried with an externalLink ?
new ExternalLink("applicationLink","http://www.google.com");

Related

Protractor right click open in a new tab wrong menu proposed

I have a problem when I do the test of a right click with Protractor.
The element where I right click is a link ''
However when the test is run in chromeDriver the tab that appears is not a tab that offers the possibility of opening in a new tab.
It should rather be this
In protractor I use the following code:
let link = element(by.css('.ag-body-container div[colid="test"] a'));
await browser.actions().mouseMove(link).perform();
await browser.actions().click(protractor.Button.RIGHT).perform();
await browser.actions().mouseMove(link).keyDown(protractor.Key.CONTROL).click().perform();
await browser.actions().mouseMove(link).keyDown(protractor.Key.CONTROL).click().keyUp(protractor.Key.CONTROL).perform();
If you have a solution to this problem
I know that this problem has already been posed but without solution provided
No right click - open in new tab
I assume you have a Single Page App or some similar setup and you are executing the nav clicks with javascript, but you want them to also behave like links.
If so, wrap your navigation item in an a tag linking to the link, and prevent executing the link on left click with js
function navClick(event){
alert("click action");
return false;
}
<button>Link</button>
Hope this helps!

Open Eclipse Welcome Page To Page Other Than "home-page-id"

I have a properly functioning Eclipse RCP program which opens the org.eclipse.ui.intro extension to a home-page-id of root.xhtml. Inside of the root.xhtml home page, there are links to other XHTML pages to offer help.
I am trying to create buttons throuhout my GUI which, when you click them, they would take you to the correct XHTML documentation page. All I can figure out so far is how to get the buttons to take me to the root.xhtml page, but I cannot figure out how to tell the intro page to navigate to a different page. Here is the code I am using now to open the intro page:
help_button.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent event)
{
ActionFactory.INTRO.create(DataStore.getInstance().getCurrentWorkbenchPage().getWorkbenchWindow()).run();
}
})
For example, I am trying to do something like this where the hyperlink string in quotes is exactly the same as the hyperlink in the root.xhtml file:
ActionFactory.INTRO.create(DataStore.getInstance().getCurrentWorkbenchPage().getWorkbenchWindow()).run().navigateTo("http://org.eclipse.ui.intro/showPage?id=setuplogging");
I was able to figure this out, it was rather time consuming and painful to do so - hopefully it helps someone out. At least the answer is a few lines of code.
You have to show the intro site getIntroSite() first before changing the URL otherwise you will get a null pointer exception in IntroURL. If you get the null pointer exception when calling createIntroURL(), it may have to do with an intro site not being already open in your GUI, not necessarily that your link is bad. Also, if the intro is already open, don't try to reopen it because it will change the page to the home page rather than your page identified with page_id. So, for this class, I made the help button a toggle button meaning if the intro window is open, then the button is pressed. In some cases I close the intro site if it is already open when the button is pressed (example below), in other cases I just don't update the intro site so it won't go to the home page (example not shown, but just omit the first part of the if block).
If you try the ActionFactory run() code in my question, that will display the intro site in the entire Window. I wanted the intro site to be a sub-window within the perspective, so I used the method below by setting showIntro(null, true) - true meaning don't take up the entire window (they call the Boolean standby).
The page_id corresponds to the page id setup in your documentation XML file when setting up your extension point org.eclipse.ui.intro.config content variable.
final IIntroPart
intro = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().
getWorkbenchWindow().getWorkbench().getIntroManager().
getIntro();
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().
getWorkbenchWindow().getWorkbench().getIntroManager().
isIntroStandby(intro))
{
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().
getWorkbenchWindow().getWorkbench().getIntroManager().
closeIntro(intro);
help_button.setSelection(false);
}
else
{
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().
getWorkbenchWindow().getWorkbench().getIntroManager().
showIntro(null, true).getIntroSite();
IIntroURL
introURL = IntroURLFactory.createIntroURL(
"http://org.eclipse.ui.intro/showPage?id=" + page_id);
introURL.execute();
help_button.setSelection(true);
}

nyroModal v2: How to validate form opened in iframe?

I'm trying to figure out how to validate a form opened using nyroModal.
The page is being opened as below on click of a button:
$(function() {
$('.btnedit').click(function() {
$.nmManual('form_page.php);
});
});
On the form that opens up, I have a few fields that are mandatory and a cancel & submit button.
<a class="nyroModalClose button" href="#" id="btn_submit">Submit</a>
On clicking of the submit button, I want to make sure the mandatory fields have value. If no, an error message should be displayed & the modal window should not close.
I'm trying to use the jquery validation plugin, but without success. The modal window always closes irrespective of the validation scripts.
I haven't found much info regarding form validation in a modal window. Is this not a preferred approach?
Thanks in advance.
I'm not able to help you about the jquery validation plugin in a modal window, but I know that using the instruction $.nmManual in that way, the form will not be placed inside the iframe tag, and if I remember correctly the content of new page will be added without header and body tags, so in a word incorrectly. I guess this can produce no validation.
To successfully open an iframe you need to use filters as described here:
Open iframe manually in nyroModal?
I hope this can help you.

How to open a href link in a FormToolkit of eclipse

made a hyperlink but it is not opening any webpage.
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createScrolledForm(parent);
form.setText("Hello, Abhishek Eclipse Form");
GridLayout layout = new GridLayout();
form.getBody().setLayout(layout);
final Hyperlink link = toolkit.createHyperlink(form.getBody(),
"Click here.", SWT.WRAP);
link.setHref("http://www.google.com");
As per the above piece of code,how should I open the webPage in the FormToolkit view
The Hyperlink widget isn't like a browser link. It doesn't by itself know how to handle links. You work with it like a button, in that you listen for the click event and then do what you need to.
You can find examples on how to work with forms here:
http://www.eclipse.org/articles/Article-Forms/article.html
Here is how you listen for link activation:
link.addHyperlinkListener(new HyperlinkAdapter() {
public void linkActivated(HyperlinkEvent e) {
System.out.println("Link activated!");
}
To actually replace the contents of the view with a web page is quite a bit more complicated. You would have to dispose of all widgets currently in the view (such as the hyperlink), then you would create a Browser widget and point it at the appropriate URL.

Want to open FB.Connect.streamPublish in a popup

I have been trying to make the Publish Stream preview modal that appears when i click on Publish Button, to appear in a pop window instead of a javascript modal.
Here is how you might go:
1: Create a html page
2: Put all your FB publish stream code in above created page
3: Use the window.open with the path to above created page to it in popup window.
Example:
<a href="#" onclick="window.open('popup.html', 'win', 'toolbar=0, menubar=0'); return false;">
In the callback for your FB.ensureInit, add this:
FB.Connect.get_status().waitUntilReady(function(status)
{
FB.Connect._openFeedDialogIframe = function(b, a, f)
{
FB.Connect._openFeedDialogWindow(b, a, f);
};
});
This will cause the call to _openFeedDialogIframe to actually call _openFeedDialogWindow, so your feed dialog will be in a popup instead of in an iframe.
Good luck!