Detect when users click on links in custom WebKit window - cocoa

In my OSX/Cocoa application, I'd like to detect when users are clicking on a link in my WebKit (WebView) view. I tried setting the UI delegate and implementing "webView:createWebViewWithRequest" however, the request object is ALWAYS nil when this method is called.
The link used is valid. When used with an external web browser it will lead to a valid page.

You want to make a WebPolicyDelegate and implement the decidePolicyForNavigationAction and decidePolicyForNewWindowAction methods.

Related

It's possible to trigger an action in my Air app, from a link in a webview?

I'm planning on create a desktop app for a customer, which will be basically a webview (displaying some page only accessible in this app), and two widgets.
But this page needs to have a couple of links/buttons that will trigger some events (outside the webview, obviously) in the app, calling the widgets.
It is possible? How?
I've made a little research and didn't found any resource on that.
Thanks in advance!
You can use JavaScript to call Action Script 3 (and also you can call JS methods from AS3) methods using ExternalInterface (http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7cb2.html).

Spring/GWT :Permission control on UI side

I am writing a simple web page, which shows some widgets based on user permission. If user has EDIT permission, the page renders EDIT widget else EDIT widget doesn't shows up.
What is the best way to achieve this?
I, first called a service to get logged in user's permission and then set visibility: none or block based on the permission. But, I see that user can "inspect element" on browser and set visibility accordingly. However, on server-side, I am using #PreAuthorize annotation on DAO to control the user actions.
How to control visibility of UI widgets without user being able to make changes, maybe from server side?
Update : I am looking for JSTL equivalent in GWT
AFAIK there is no JSTL equivalent for GWT.
However there are some 3rd party (i.e. ArcIS) libraries that make display/hiding UI elements based on user permissions more convenient.
However no matter whether you do it manually or using a library you should make sure that you properly secure your backend side (as far as I can tell you are doing that by using method level security).
One important thing to remember when dealing with client side permissions/security:
You should never trust input/actions from the client/browser, because you are not in control of it. So you must always do security on the backend
In my opinion, it really does not matter if the user could theoratically inspect the edit button for example using Browser Dev Tools and make it visible, as long as the the edit action on the backend is properly secured. If you are really that concerned you can remove the elements (i.e edit button) from the DOM instead of hiding it, but it won't make it more secure.
I, first called a service to get logged in user's permission and then
set visibility: none or block based on the permission.
Well instead of setting the visibility none or block, assuming you are using JSP, use JSTL tag
<c:if test="${if the user has permission}">Show widget UI code</c:if>
If the page has n widgets for which the user doesn't has permission, why would you load the code for all the n widgets. It's non performant.
write a panel that shows it's contents based on security settings in the client code
add the widgets to be controlled inside the security panel
the panel will now control the appearance of the children based on security in your client code
As has been mentioned before, and has been recognized by you, client security is only visibility control and thus not sufficient to protect the app.

Attach TargetWithoutContext to an AppBarButton

I have a Conductor<MyItem>.Collection.OneActive ViewModel and try to attach the application bar buttons to methods of MyItem with cal:Action.TargetWithoutContext="{ Binding ActiveItem }". My view is a Pivot, if someone wonders why am I trying to attach the application bar to a child ViewModel. The compiler says "Property 'TargetWithoutContext' is not attachable to elements of type 'AppBarButton'." Though it works with normal buttons elsewhere in the view.
How can I get it work? Or maybe any workaround?
The AppBar functionality that Caliburn.Micro provides is a hack due to the flaws in the underlying framework, which doesn't allow arbitrary binding. Unfortunately, we can't support TargetWithoutContext. For AppBars the target will always be the page's view model and messages can only be directed to it. If the page's view model is a conductor, and you want a child to receive the message, you could have the conductor receive it and then forward it on to its ActiveItem.
Unfortunatly the ApplicationBar is not bindalbe as it is not Part of the Silverlight Framework.
You can only interact with the Application via the Code Behind File of the Page which uses the ApplicationBar.
You have to register the Click Event and invoke the Action form the code Behind.
The WP7 ApplicationBar is just a simple wrapper around the native shell and doesn't support data binding at all. However, there are a couple of workarounds available.
http://caliburnmicro.codeplex.com/discussions/232742

Why Webview prevent showing a webpage when click a swf?

Now I show a swf from web in my webview , but when I click the url address in the swf to show another page with my default web browser, I found the webveiw prevent to do it , Why ? How to allow it ?Thank you very much!
You should look at the WebUIDelegate protocol, specifically this delegate method:
- (WebView *)webView:(WebView *)sender createWebViewWithRequest:(NSURLRequest *)request;
If you've got an object registered as the WebView's UI delegate then this method is called when the Flash plug-in sends a URL change request. You can then do what you want with the request. By default, the WebView just ignores it.

Can I trigger a webcontrol panel's OnInit event without a page?

I am working with someone else's code. The code was originally designed so that data would dynamically create controls (and sub-controls of those controls...) on the OnInit event on numerous web control panels. And then later validation methods would check those dynamically created controls for valid data. This continues to work just fine for my web site. However, I need to be able to validate that data without my website (as in this will just be server side). The simpilist solution appeared to be to just have the panels initialize and then run the validation methods. That'd be great...if I could figure out how to initialize those panels server side without a web page.
Can this be done? Is there any way to get a panel to initialize without having a page to display that panel?
That way lies madness - you could use reflection to call the control's InitRecursive method, but it needs a Page (among other things) to run correctly.
You should extract the validation code into a new class that you can call from your server code an change your WebControl to use that class as well.
Try RenderControl.

Resources