I have created a JDialog to be opened when I click on the edit button of my JFrame, it is being opened properly and does'nt have any issue, but when I took this code on the windows ce 5.0 device this dialog is being opened twice. hat is i am clicking only once on the edit button but the dialog is appearing twice, I want there should be only one dialog appear on edit button click.
ok I have got the solution
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting() == false) {
List lsm = (List) e.getSource();
showDialog();
lsm.clearSelection();
}
}
Related
I am trying to select Status form a new windows popup. After clicking the select status button it opens the dialog page but i can't see the HTML of that page. So not sure how to interact with that dialog page from selenium.
NB: I have switched to the new window but can't proceed from there.
HTML looks like this..
After clicking the select Status button following dialog page opens.
but i can see the html of the dialog page so how to interact with it form selenium?
Update -14/09/17
When i click on Select Status it call the below url. Opened the url in a separate tab and was able to see the HTML.
http://xxx.xxx.xxx.int/tasks/status.aspx?CurrFilters=OPEN
Tried to select a values from the new windows like below...
public void SelectStatus()
{
_SelectStatus.Click();
Browser.Switch_to_child_page();
_container.FindElement(By.CssSelector("input[onclick^='SelectAll']")).Click();
}
getting following error.
Test 'x.RegressionSuite.TestCases.xTest.TC_x' failed:
OpenQA.Selenium.StaleElementReferenceException : Element is no longer
valid
It looks like new windows popup. you can switch to new window. then interact with it.
// Store the current window handle
String winHandleBefore = driver.getWindowHandle();
// Perform the click operation that opens new window
// Switch to new window opened
for(String winHandle : driver.getWindowHandles()){
driver.switchTo().window(winHandle);
}
//select the checkbox
driver.findElement(By.xpath("xpath for checkbox")).click();
//click on select button
driver.findElement(By.xpath("xpath for submit")).click();
// Close the new window, if that window no more required
driver.close();
// Switch back to original browser (first window)
driver.switchTo().window(winHandleBefore);
I want to know from which page navigated to a given page by pressing the back button. But I didn't find a solution for it in WP8.1
Parameters can be used for forwards navigation, as I know.
Can anyone help me?
You want to know which page was displayed before the user navigated back to your current page? You can inspect Frame.ForwardStack for that:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (e.NavigationMode == NavigationMode.Back)
{
// get the type of the page that was shown previously
var navigatedFromPage = Frame.ForwardStack[0].SourcePageType;
}
}
I have a global page that hosts navigation buttons to diffeernt pages. it also hosts a frame called ContentFrame. It navigates to the diffeernt pages as the navigation buttons are clicked. But initially some calls are made to the DB and when data is returned, the ContentFrame navigates to the mainpage first.
I have a back button and a home button. When the contentframe has MainPage in it and the back button is clicked, I want the app to go back to a previous page from which this whole global page is loaded. If the content frame just has some other pages loaded, then I want it to simply go back to the previous page that was loaded when back button is clicked.
Here is my code for the contentframe in the global xaml
<Frame x:Name="ContentFrame" Grid.Row="1" Grid.Column="1" />
Here is my back button click code for global page
private void Back_Click(object sender, RoutedEventArgs e)
{
if ((ContentFrame.CurrentSourcePageType != null) && (ContentFrame.CurrentSourcePageType.Name.Equals("MainPage")) && (this.navigationHelper.CanGoBack()))
{
ResetPageCache();
this.navigationHelper.GoBack();
}
else
{
if (this.ContentFrame.CanGoBack)
{
this.ContentFrame.GoBack();
}
else if (this.navigationHelper.CanGoBack())
{
this.navigationHelper.GoBack();
}
}
}
private void ResetPageCache()
{
var cacheSize = (this.Frame).CacheSize;
(this.Frame).CacheSize = 0;
}
The issue that I am facing is that when the ContentFrame has main page loaded and back button is clicked, it navigates back to a previous page before the global page was loaded but in the process, the onnavigatedfrom() event for MainPage is not raised where I unsubscribe some events.
Any idea how I can get the onNavigatedFrom() to fire for MainPage in this case?
Thanks
The simplest solution might be to handle the Unloaded event apart from/instead of OnNavigatedFrom so that your clean up happens regardless of navigation but rather when just being removed from the visual tree. You might want to pair it with the Loaded event though in case your page gets added to the visual tree without being navigated to (e.g. when the cached parent page is being navigated to).
Sure. Do this:
var frame = Window.Current.Content as Frame;
frame.SetNavigationState(string.Empty);
Best of luck!
i have created a windows phone application. In each page i have given a back button using "NavigationService.GoBack()" command. i want that when the back button is pressed the previous page to which it navigate the whole code of that page must again be executed.
If you're relying the user pressing the hardware back button you shouldn't have to call GoBack() yourself.
To refresh a page when the user navigates back to it you can use the following in your page (and add the refresh code as appropriate):
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.NavigationMode == NavigationMode.Back)
{
// Do your refreshing here
}
}
I have a combo box. After selecting an item in combo box new JDialog opens.
When i use JDK 1.6_06, I am able
to click on buttons in JDialog
properly.
When i use JDK 1.6_24,
then i need to click anywhere in
JDialog first. Then only clicking on
button works. Firstly i thought this
is some issue with the focus. But
component works fine with JDK
1.6_06. But its a issue only with JDK 1.6_24.
I tried to google it. But didnt find any answer. Does anybody have any idea?
I don't know about the java versions - but putting dialog.setVisible(true) in SwingUtilities#invokeLater solved this issue some time back for me. YMMV.
#All: Aplogize for late reply. I was trying out different scenarios. And i have found that issue is with the threading. It seems that combo box is not yet finished its work, and jdialog is opened. And after that combo box tries to finish its work, so the focus is lost to the parent window. I tried opening dialog in thread:
new Thread() {
public void run() {
// open dialog here
}
}.start();
And it works fine. Now i am planning to open dialog using SwingWorker:
SwingWorker worker = new SwingWorker() {
#Override
protected Object doInBackground() throws Exception {
// TODO Auto-generated method stub
// open dialog here
return null;
}
};
This is also working. Hope this is the right way. Please let me know, if I am doing a right thing.