Calling Response.RedirectLocation from within ICallbackEventHandler.RaiseCallbackEvent does nothing - redirect

We're attempting to make a redirect during a page callback. We have an aspx page that is implementing ICallbackEventHandler. Inside of the ICallbackEventHandler.RaiseCallbackEvent() event handler in the code-behind we're attempting to use the Response.RedirectLocation to move the user on to another aspx page. Our code is below.
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
HttpContext.Current.Response.RedirectLocation = "http://www.google.com";
HttpContext.Current.Response.End();
}
After raising the event client-side and setting breakpoints in the event handler we are sure that the code is being called but the page doesn't actually redirect. Are we missing something important here? We've tried several other ways including setting the Response.StatusCode and using Flush() instead of End(). Let me know if you need any additional information about what we're trying to do.
Any ideas would be greatly appreciated!
Thanks,
Daniel

I did it without the last line and it works.
HttpContext.Current.Response.RedirectLocation = "http://www.google.com";

The old fashioned way was Response.Redirect(url). Does that fix it?

Related

Issue with setting AutomationElement value

I have an issue with setting value of AutomationElement by using method ValuePattern.SetValue().
Everything works just fine until some dialog appears. When the dialog appears the code execution got stuck. No exception is thrown. After the dialog is confirmed, the code exection continues. Bellow is a sample of the code:
BasePattern basePattern = null;
ValuePattern valuePattern = null;
AutomationElement elementA = Window.GetElement(SearchCriteria.ByText(propertyName));
object patternObjectA = null;
elementA.TryGetCurrentPattern(ValuePattern.Pattern, out patternObjectA);
basePattern = (BasePattern)patternObjectA;
valuePattern = (ValuePattern)patternObjectA;
valuePattern.SetValue(optionToSet);
// Window.GetElement() is a method from TestStack.White framework
// The code execution got stuck on the last line until the dialog is confirmed
Is there any other way to set AutomationElement value?
Is somehow possible to avoid of getting stuck by dialog?
I'll by grateful for any help.
Thanks advance.
It could be that this dialog is not supporting UI Automation correctly or that you simply target the wrong element.
To verify that you may use Inspect.exe from Microsoft or similiar tools.
If it works, check if you really target the correct component with your code again.
If it does not work and:
if you are able to change the application
you can change the so called AutomationPeer of the UI component - here is a link for more infos
Or simply use another UI component that supports UI Automation correctly.
if you are not able to change the application, and also do not need to run in background, parallel, etc.. you might just focus the component (call setFocus() onto the AutomationElement, or expand it (via IsExpandCollapsePatternAvailable or simulated MouseClick onto the components coordinates)) and then use the SendKeys.SendWait("test") method.
EDIT: There is one more thing you should have a look at, and I wonder why I didn't mentioned it in the first place: Register to UI Automation Events
For example you could register a callback for the Structure change event type, and check if the dialog you talk about appeared.
If so --> click the confirmed button of the dialog.
Probably you will have to synchronize your execution, so that every further action in the UI Automation script waits until the registered callback got executed and the confirmed button got clicked.

Detect Wicket user inactivity

Does anybody have an idea on how I can accomplish this using Wicket?
I want to display a Wicket odal window automatically when no user activity has been detected for a certain amount of time. I'm thinking of using an AjaxSelfUpdatingBehavior in some way, but I have no clear ideas actually.
Is this possible with Wicket?
Also, you can use some js library not to catch all ajax calls and to be sure, that your user is really afk (even does not touching his mouse).
For example, see this free framework and it's demo.
And (if you using this js framework) in wicket you must handle
ifvisible.idle(function(){
Wicket.Ajax.get({u: '${callbackUrl}'})// This code will work when page goes into idle status
});
You must set ${callbackUrl} from wicket code to let js know what action to proceed in java code. It is not hard to do this. Look here.
This approach is more tricky, but if you implement this, you don't have to worry about users actions at all (he can read site's info and don't click any ajax links, but suddenly he will see modal window).
Yes you can, I use this as autologout function
public class MyTimer extends AbstractAjaxTimerBehavior {
public MyTimer(int seconds) {
this(Duration.seconds(seconds));
}
#Override
protected void onTimer(AjaxRequestTarget target) {
// show your window magic
}
}
Add this to you page (add(new MyTimer(300));) and this will be called after the number of seconds you specify. Make sure to replace the timer with a new one when doing ajax calls, or reset it.

Cancel button Icefaces with immediate=true

I have a form with save and cancel buttons, cancel button has immediate=true but it doesn't clear the submitted values in the form. I google it and I found this page http://jira.icefaces.org/browse/ICE-1343;jsessionid=2996E8791051E9D6775348E6CE1BC118, it says that the solution is to put an action listener in the cancel button that calls a function that clear the submitted values, it works partially because when I have other tags like panels it doesn't clear them.
Any solution? thanks
Check out the solution presented here : http://www.icefaces.org/JForum/posts/list/13807.page
I personally haven't found a good solution beside the two most obvious ones : manually traverse the UI components and nullify them
We used partialSubmit="true" without setting the immediate attribute to true. This works in Icefaces 1.8.2, but there is one drawback. If the validation failed once, it will be executed always.
With Icefaces 2.x, the suggested way is to use singleSubmit="true", but I haven't tried it.
I use immediate="true" and partialSubmit="true" on cancel and something like this for actionListener
public void cancelPopup(ActionEvent event) {
FacesContext.getCurrentInstance().renderResponse();
}

webView:shouldStartLoadWithRequest:navigationType: not always triggered

As can be seen in the screencast below, I'm having a devil of a time getting webView:shouldStartLoadWithRequest:navigationType: to be called consistently.
In the screencast below, you'll see a UIWebview with three size selectors. When clicking on any of these three, webView:shouldStartLoadWithRequest:navigationType: should be getting triggered. Unfortunately, that doesn't always seem to be happening. It doesn't event seem to happen consistently.
http://screencast.com/t/ww6uwP1Je
So what's causing this? Is there an error method of UIWebViewDelegate that I could hook into to pick up some of what's going on internally?
It seems like you aren't setting the UIWebViewDelegate properly. I noticed in the screencast that it worked once you clicked the 'L' (presumedly "large") button. Is that method setting the delegate? If not, please paste a code snippet that shows the issue.
Since the other two buttons generate calls to the delegate we know your web view delegate is properly assigned.
The simplest explanation for the failure is that S button is not configured in HTML properly and does not generate a actual request for the web view to load. With no request, the delegate methods are never called in the first place.
Ok, turns out I didn't provide anyone enough information for anyone to answer the question - I even removed the relevant parts from the webview gist given above. Sorry!
Here's the full template:
https://gist.github.com/521d17e0377133725d9a
Turns out there was an onclick handler on the li surounding the link (see the gist above - "#sizes_slider li"). Removing that onclick handler did the trick.

How to detect page change in UIWebView and do something before it starts loading?

I need to do something on each page change, before that page starts loading/executing.
First, I tried using -webView:shouldStartLoadWithRequest: but that won't work, because it's also called for XHR requests and iframe requests.
Second, I tried using -webViewDidStartLoad: and comparing webView.request to it's previous value, to see if it changed. This doesn't work, because webView.request is updated only some time after the call.
Any more ideas?
The request object in webView:shouldStartLoadWithRequest: has two properties,
BOOL iframe = ![request.URL isEqual:request.mainDocumentURL];
If the URL to load is not equal to the mainDocumentURL you are loading something other than main doc (probably an iFrame).
Have you tried using KVO to observe UIWebView.request?
Make a Category or extend UIWebview that overrides loadRequest, doing your operation first and then doing the standard loadRequest.