JSF PostConstruct Exception Handling - Redirect - exception

I'd like to handle a JSF #PostConstruct exception by redirecting to another page. I'm using FacesContext.getCurrentInstance().getExternalContext().dispatch("page.jsf"); which works great but since the page uses 2 backing beans it continues to load the other backing bean (and if it encounters an error on the other backing bean it never gets to that dispatch/redirect). My question is.. is there a way to force that dispatch to happen right away and not load everything else?

Look at this similar question:
JSF navigation redirect to previous page
According to BalusC you can use the following instead of dispatch:
FacesContext.getCurrentInstance().getExternalContext().redirect(url);
Or, in order to stop rendering the current page, put
FacesContext.getCurrentInstance().responseComplete();
Regards

Related

How to get arguments from LaunchApp NFC tag (when NavigationPage is not set in manifest)? WP8

Answer from this question works fine if you have NavigationPage set for your default task in WMAppManifest.xml (it's set by default).
Unfortunately in my current application the start page depends on whether a user is logged in in the application. I determine this and then manually navigate to a required page in Application_Launching. Because I do navigation to the start page myself I don't have ms_nfp_launchargs argument in a QueryString.
Is there any other way to get arguments from LaunchApp NFC tag?
Ok, there are several solutions to this.
One is to use a temporary start page and renavigate to the real one from there.
Another option is to write some code word (like "startPage") in NavigationPage in manifest, and then to catch this code word in a custom UriMapper on a RootFrame and navigate to the required page.

MVVMCross MvxImageView not displaying picture

I use MvxImageView with a binding to ImageUrls with the following format:
http://mysite/service/service.svc/rest/Image/flag/<picture size>/country/<Country ID>
an example would be:
http://mysite/service/service.svc/rest/Image/flag/48/country/104
http://mysite/service/service.svc/rest/Image/flag/48/country/141
which returns a 48x48 pixel image of the Swiss flag in png format for the first link and a Spanish flag for the second link.
Does MvxImageView or any of its helpers depend on a unique filenames including an file extension?
Or could even the "service.svc" be the problem and be interpreted as the filename?
According to the webserver logs the App doesn't even open the Url. When I tried with another picture from another server it worked perfectly fine.
EDIT:
On further investigation I've found out that the Accept Header of the request isn't accepted by my webservice. Can I add it somewhere?
So my Question transforms to: How can I override the MvxFileDownloadRequest class to add an accept header?
How can I override the MvxFileDownloadRequest class to add an accept header?
The only way to do this is to implement your own IMvxHttpFileDownloader implementation and to register it with IoC in place of the default one.
The source for the default one is https://github.com/MvvmCross/MvvmCross/blob/v3.1/Plugins/Cirrious/DownloadCache/Cirrious.MvvmCross.Plugins.DownloadCache/MvxHttpFileDownloader.cs and this question was similar - MvvmCross HTTP DownloadCache with authentication - if this is a common request, then happy to see this pushed back into MvvmCross core.

How can I get access to the request url from a ServiceStack.Razor layout template?

I have defined a layout template .cshtml for my site using the following method:
#{ Layout = "InsideLayout"; }
I am now trying to grab the request url to figure out what navigation menu item should be marked as active at any point in time. It however looks like the Request object is null (however unable to get a break point in the view, so not 100% that's the issue, but pretty sure).
To me, it seems that the current Request object should be populated properly in a Layout view, so it can some context sensitive markup in it, but as is this doesn't seem possible. Is there a specific class that the layout must inherit from to enable this, or is what I'm seeing the expected behavior?
Another option I was thinking might work, is to create a custom service to back the layout view. I tried this, however I wasn't able to get the service code to execute when a page using the layout was loaded. Is this even possible?
Normally you should have access to the Request inside the view. But a better way to do that is to pass it in the model. Simply add the information as a property to the model that you are passing to this view and have the service populate it.

Automatically tidy up JSP/JSF files

I am working on a webapplication and I do most of the XHTML stuff in an editor.
Every once in a while I froget to close a tag or mess up the nesting (we all get distracted sometimes ;-)).
So I commpile, package and run my webapp (using maven mvn clean package jetty:run-war only to notice that displaying the view (where I messed up the jsp) fails with an exception while trying to render.
So I wondered:
Is there some tool that I can include into my build-cycle that automatically catches and rectifies those careless mistakes?
There is the Maven CheckStyle plugin that looks at certain style rules in Java and other languages. It is customisable so you can add other rules. I can't say for sure that it will catch unclosed tags but this may be the place to start.
Using an IDE like Ecplipse or Netbeans will highlight any invalid code also. So you can actually see a red mark on the page as you type. That may be even more effective.
Maybe a regular xml checker would do the trick. After all a JSP file is if properly written valid xml.

How can I post data (form) to html page and hijacking the data in the middle?

the site addres: http://www.ynet.co.il/YediothPortal/Ext/TalkBack/CdaTalkBack/1,2497,L-3650194-0-68-544-0--,00.html
fill the form with rubbish.
Hit 'Send'
the form post the data to another HTML without any parsing of the data i've just added
How do they do it?
A likely option is that they are using a content management system where "html" on the URL doesn't actually mean it's a static html file.
This may be out of left field, but I've certainly used the occasional JS function to grab everything in the header and either parse it or pass it to another script using AJAX.
I'll sometimes use this method in a 404.html page to grab the headers of the previous page, parse them out to see where someone was trying to go and redirect them.
That is, as annakata said, one of the numerous options available.
Edit based on clarified question:
Numerous frameworks can be configured to intercept an html request - for instance asp.net can be set to handle any given extension and an HTTPModule could do anything with that. It's really up to web server configuration what it decides to do with any request.
also: you don't really want to be saying "hijack"