Primefaces fileUpload change POST URI - post

I'm using PrimeFaces 6 fileUpload component along with a URL rewrite framework.
So that, http requests to: domain/URI/fileupload are routed to: domain/OTHER_URI/upload.xhtml
I submit this with a different commandButton as javascript PF('fileUploadWidget').submit();
When the file is POSTed to the server, it's using the wrong path (OTHER_URI/upload.xhtml) and failing.
I've tried locating and changing this in the javascript widgetvar object as well as the form on the page, but it still POSTs to the wrong URI. How can I change the URL where PrimeFaces fileupload submits?
Thank you

I was able to resolve my issue by changing the URL rewrite configuration.
I was mapping /fileUpload to a path in WEB-INF. This caused POSTs to an unreachable location. Instead of trying to change the POST URL, I mapped to an accessible path, outside of WEB-INF.

Related

Issue with prerender.io always rendering the default angular route for a list of client side routes

Just want to say I really like prerender.io, but I am currently having an issue with it and I am wondering if maybe I am doing something wrong and people with more experience with the service can help me out.
I am having the same issue with the prerender.io site and also with a Debian Linux box I setup with prerender for local execution.
My new site is a hybrid of ASP.Net MVC and angular, where angular represents workflows (or categories of content) within MVC routes on the server.
An example of a category of content is this:
http://[somesitename]/PublicContent/#!/news
http://[somesitename]/PublicContent/#!/welcome
The MVC server side route is:
http://[somesitename]/PublicContent
and #!/news and #!/welcome are the angular app routes and welcome is also the default route.
When I send my URL to the prerender.io service or my local instance:
http://service.prerender.io/http://[somesitename]/PublicContent/#!/news
The prerender service is only ever rendering:
http://[somesitename]/PublicContent
and is ignoring the client side route after the #!
so for all my pages for each MVC route I am merely getting the default route rendered multiple times...
Is this a bug with prerender.io? Or do I not have something not properly configurered?
I do have the:
<meta name="fragment" content="!">
in the head for all my pages if that would matter.
Talked with the guys over at prerender.io, and it appears that a modification I made to the Asp.Net MVC middleware where it was removing ?_escpaed_fragment_=/ completely was an incorrect modification to this code, which itself was incorrect (the base code removed ?_escpaed_fragment_=/ and replaced it with nothing, I modified the code to remove ?_escpaed_fragment_=/ and replace it with #!).
The prerender.io service expected ?_escpaed_fragment_=/ to exist in the URL and if it finds it it will replace it with #! before calling your website to cache the page. It doesn't expect to find the #!, so it won't properly process the URL if it is there.
So if you are using the Asp.Net MVC middleware you should comment out the following code from PrerenderModule.cs:
// Remove the _escaped_fragment_ from the URL if it exists!
var escapedFull = "?" + _Escaped_Fragment + "=/";
if (url.Contains(escapedFull))
{
url = url.Replace(escapedFull, string.Empty);
}

How to include another XHTML in XHTML with path info in URL

I will post some pictures to clarify my problem.... i WOULD post pictures but i am not allowed to -.-
If i use a url like
localhost:8080/SupervoteWeb/polls
everything works fine. The header is displayed correctly.
But for some sites i need the url for passing ids or other attributes.
I have checked if it is because of this parameter passing. This is not the case.
An URL like:
localhost:8080/SupervoteWeb/polls[/ enter anything here]
always leads to an error where the header is not displayed correctly.
This is the code of the header. It is placed on every site.
<ui:insert>
<ui:include src="/protected/header.xhtml" />
</ui:insert
By the way: I am using prettyfaces for clean urlmappings.
Can you tell me where this weird behaviour comes from?
If there is any code missing you may need i will post it.
The problem is solved!
The .css was not found - I had relative links to my css files.

JSF page in subfolder can't see template

I've got a template in WEB-INF/templates/standardTemplate.xhtml
In my "Web Pages" root, I've got an index.xhtml which uses the template via
<ui:composition template="/WEB-INF/templates/standardTemplate.xhtml">
The above works fine.
However I also have another page which uses the same template, but it's in a subfolder "Web Pages"/messageboard/list.xhtml
It uses exactly the same syntax/paths:
<ui:composition template="/WEB-INF/templates/standardTemplate.xhtml">
But it can't find the template and renders just the content of list.xhtml (none of the template's content).
Faces servlet is mapped to "/faces/*"
What am I doing wrong? Tried every variant I can think of but I can't get the right syntax.
Thanks
As per the comments, you're seeing <ui:composition> unparsed in the HTML output.
That can only mean that the request URL as you've in the browser address bar does not match the URL pattern of the FacesServlet. Make sure that it matches the URL pattern of the FacesServlet. You've mapped it on /faces/*, so the URL should contain the /faces path prefix right after the context path.
Better would be to map the FacesServlet directly on *.xhtml so that you never need to fiddle with virtual URLs.

Trying to set the right URL - Struts 2

I have a Struts2 app and I'm having a bit of a problem:
at the first page (index.jsp) I have a javascript line that sets the url to './admin/Search' like this:
window.location='./admin/Search';
that sends me to the login page and if I have access it will redirect me directly to the mentioned page. The problem is that, after that, all my actions keep this first namespace '/admin'. Other actions just do not have this '/admin' namespace, for example, they could have a '/users' namespace. In this cases the server can't locate the right action because it will look for /admin/myAction in the struts.xml file. It's like struts 2 doesn't change the whole namespace/action. It just replaces the action and that's it. I really need help on this guys! Thanks.
You need to change the package namespace specified in the in struts.xml files. That will help you redirect your namespace inside your application.

ASP.NET MVC 2 parameters throws JS error

My application works fine when I have only one parameter.
e.g.
/Product/Index/2
/Report/Sales/08-2009
But it failes when I add one more part to the url. Let's say I want to add the end month-year parameter to the url routing. Mow it becomes:
/Report/Sales/05-2009/09-2009
I do get both parameters in my action method. I parse it and retrieve the data and pass the Model to the View. With this scenario it throws the client side JS error when I try to access any of the form elements. I get "object expected" error. The same view works fine using just first parameter. What could be the issues here?
I also loose the CSS styles when this error occurs.
Thanks
well, without seeing any code at all this is difficult to troubleshoot, but I'd say it's likely because you are referencing your javascript and css files using a relative path like:
../content/scripts/myjavascript.js
Adding the second url parameter has caused the browser to be unable to find the urls because you have added what looks like an extra level of depth to the url.
You should provide absolute urls to your scripts and css files. An easy way to do this is to use the "ResolveUrl" method like so:
<%= ResolveUrl("~/Content/Scripts/myjavascript.css") %>

Resources