I am kind of new to Silverlight and I am having some issues. I have been trying to figure this out for a few hours now...
I have a main page that waits for a packet from a server. When that packet arrives it is handled in a module. Depending on the packet data the module handles an action. Some of those actions involve subroutines on the main page. I access them via:
Dim MainPage As MainPage = App.Current.RootVisual
If strPacketData(1) = "0" Then
MainPage.Do_Sign_In(True, strPacketData(2))
Else
MainPage.Do_Sign_In(False, strPacketData(2))
End If
And this works fine.
Assuming the sign in works the main page calls
Me.Content = New Page2
And the page switches to Page2
The problem is that the same code doesn't work when trying to access subs and controls on page2.
If I try:
Dim Page2 As Page2 = App.Current.RootVisual
If strPacketData(1) = "1" Then
Page2.lblCreateError.Opacity = 100
End If
I get Unable to cast object of type 'SLClient.MainPage' to type 'SLClient.Page2'.
What I am getting from this is that App.Current.RootVisual is set to MainPage, but MainPage shouldn't be open...
I have tried setting App.Current.RootVisual to Page2 but that doesn't seem to do anything.
I am hoping that this issue is caused by my ignorance of silverlight and that there is an easy fix for this...
I guess what I need to do is detect which page is currently being displayed and manipulate the controls and functions\subroutines on that page.
Any Input would be greatly appreciated.
OK well I finally figured it out. Or at least I figured out a way to do it.
I used a dictionary to store the addresses of the pages once they were created in memory. I also modified the program so that rootVisual is its own grid instead of a page. Now the grid loads and clears the pages as children.
I don't know... Silverlight is kind of screwy. Whatever, it works now.
Related
I've found some inconstistency in the RSelenium navigation function. Namely, I've started just the server this way:
rS <- rsDriver(browser = "phantomjs", port = 4567L, check = T)
rDr <- rS[['client']]
rDr$navigate(yahoo)
doc <- rDr$getPageSource()
and navigated to the Yahoo page. And everything is ok, but while I try to do it once again (this or other page from Yahoo) it returns very similar page, but this seems like some scripts haven't been loaded. While I renew it once or twice or trice this works again. My idea is there's some checker when you want to load the resource from the server too quickly. If so, how to handle this programically? I haven't found any methods in documentation something like isPageLoadedProperly() or so. I can set some timeout but don't know how long, is it constant value and many other questions. Anyone had that issue before?
I am trying to make WatiN attach to an IE popup window (IE 10).
This popup contains a frameset --> a single frame --> a pdf document.
My goal is to save this pdf to my disk.
Dim winExists = IE.Exists(Of IE)(Find.ByUrl(Function(url) url.Contains("__ADFvDlg")))
If winExists Then 'this evaluates to true
Dim win = IE.AttachTo(Of IE)(Find.ByUrl(Function(url) url.Contains("__ADFvDlg"))) ' Timeout while waiting for frame document becoming available
End If
1) I have tried using the above code inline or in a STA thread
2) When coded inline, its parent thread is also STA
3) I have tried to increase the default timeout to 8 minutes, same result after 8 minutes have passed
There is no other option for me than to parse this particular popup, since it is a site built with Oracle ADF and, apart from the fact that it is A MESS, it is very strange at times...this popup has a URL that somehow works only once. If I try to use it in another window, no pdf is returned. The same happens when I refresh the popup.
I cannot fetch the PDF in the Temporary Internet Files since it is not there (I suppose this is because the website works under SSL).
Any guidelines or solutions even outside WatiN's scope is more than welcome since I've hit a brick wall.
Technologies: VS2012, WPF
Thanks a lot in advance.
I found it easiest when I tried the same thing by making the pop-up show up as a new tab. That way I could attach to it's URL. From there I would use
File.WriteAllText(fileName, responseDownLoad.Content.ReadAsStringAsync().Result);
Where responseDownload will be a HttpResponseMessage
I have a scenario where I need to change the HtmlPage.Window.CurrentBookmark property, but I want to do it without causing the Silverlight application to reload. Right now, I'm doing this, but it's causing the application to restart:
public void SetBookmark(string authenticationGroupTag, string ownerUserTag, string roomName)
{
string bookmark = GetBookmark(authenticationGroupTag, ownerUserTag, roomName);
HtmlPage.Window.CurrentBookmark = bookmark;
// HtmlPage.Window.Eval("window.location.hash='" + bookmark + "'");
}
That particular behavior -- restarting the application -- doesn't seem to be documented anywhere, so I wonder if I'm just doing it wrong. I've tried catching various navigation related events (either Page.OnNavigatedFrom or RootFrame.Navigating), but neither of those actually get fired: the app just unloads and then reloads.
So I guess I have two parts to my question: (1) Is this the expected behavior, or am I just doing something wrong? and (2) If it is the expected behavior, has anyone come up with a workaround for it? Is there a way to update the portion of the URL after the "#" without reloading the Silverlight application?
Turns out that this is just a variant of a problem that's been long noted, namely, that Internet Explorer refreshes the page when (a) the user has arrived at the current page after a redirect, and (b) you change the window.location.hash. In other words, this is an IE issue (still not fixed in IE9!), not a Silverlight problem. Everything behaves correctly with Firefox and Chrome. (See javascript location.hash refreshing in IE and Response.Redirect with a fragment identifier causes unexpected refresh when later using location.hash for more details, and some suggested workarounds.)
I've got a FlowDocumentPageViewer with dynamic content. The flow document is made of paragraphs, each run in the paragraph contains a word. I'm trying to navigate to a given run, so I got the method which will return me the run I want.
But once I got this Run how can I navigate to it, with automatic page change?
For example I select the last run in a page, the next run is in the next page. How do I navigate to the next page from there?
I had a look at the TextPointer but I'm not sure this will help here.
Thanks for your help,
Boris
I just found the solution, once you get a pointer to your FrameworkElement, you will have to call FrmkElement.BringIntoView(), it will automatically change page in the PageFlowDocumentViewer.
I am trying to figure out how to make a hyperlink in a Livecycle Form which points to a URL which will change on different days that the form is rendered. For example on one day I might want the hyperlink to point to:
mywebsite/mypage?option=XXX
and on another day I want it to point to:
mywebsite/mypage?option=YYY
The XXX and YYY can be passed into the form's data pretty easily as XML, but I just don't know how to make it so that the hyperlink is changed to correspond to this.
Any suggestions?
This can be accomplished with JavaScript in LiveCycle Designer. The following script, placed on the Form's docReady event will let you dynamically change the URL of a text object.
form1::docReady - (JavaScript, client)
// If this code is running on the server, you don't want it to run any code
// that might force a relayout, or you could get stuck in an infinite loop
if (xfa.host.name != "XFAPresentationAgent") {
// You would load the URL that you want into this variable, based on
// whatever XML data is being passed into your form
var sURL = "www.stackoverflow.com"; // mywebsite/mypage?option=xxx
// URLs are encoded in XHTML. In order to change the URL, you need
// to create the right XHTML string and push it into the Text object's
// <value> node. This is a super simple XHTML shell for this purpose.
// You could add all sorts of markup to make your hyperlink look pretty
var sRichText = "<body><p>Foo</p></body>";
// Assuming you have a text object called "Text1" on the form, this
// call will push the rich text into the node. Note that this call
// will force a re-layout of the form
this.resolveNode("Text1").value.exData.loadXML(sRichText, false, true);
}
There are a couple of caveats: URLs in Acrobat are only supported in Acrobat 9.0 and later. So if someone using an older version of Acrobat opens your form, the URLs won't work.
Also, as you can see from the "if (xfa.host.name !=...)" line, this code won't run properly if the form is being generated on the server, because forcing a re-layout of a form during docReady can cause problems on certain older versions of the LiveCycle server. If you do need to run this script on the server, you should probably pick a different event then form::docReady.
I a number of complaints from users in WorkSpace that clicking links opened them in the same tab so they lost their WorkSpace form, and there's no option to change that in Designer 11. I think the solution I came up with for that would work for you too.
I made buttons with no border and no background, and in their click event have this line (in Javascript, run at client)
app.launchURL("http:/stackoverflow.com/", true);
It would be easy to add some logic to choose the right URL based on the day and it doesn't cause any form re-rendering.
In some spots where the hyperlink is in line with other text, I leave the text of the link blue and underlined but with no hyperlink, and just place the button (no background, no border, no caption) over it. Does require positioned and not flowed subforms for that to work, so depending on your layout it could get a little clunky.
Wow, just realized I am super late to the party. Well, for anyone using ES4 facing a similar problem . . .
Ended up using a 3rd party component to manipulate the PDF's hyperlinks...wish there was a better solution as this one costs about $1000.