How to include another XHTML in XHTML with path info in URL - jsf-2

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.

Related

SAPUI5 Link sending two parameters

I have a SAPUI5 Link on my page and I want to use it to call another php file with two parameters. As far as I can see, I am formatting the XML properly but when I try to include the second parameter in the 'href' property, I get an error that the XML is not formatted properly.
Here is the XML for the link - I have modified the href to remove sensitive server information:
<Link id="pdfLink" xmlns="sap.m" text="PDF" href="https://../scripts/pdf/index.php?yr={/yr}&qtr={/qtr}" target="_blank"></Link>
When the URL is triggered, it should look similar to this in the browser:
https://../scripts/pdf/index.php?yr=2015&qtr=1
This will launch the index.php file with the parameters, if entered manually. If I remove the '&qtr={/qtr}' (or even just the &), then I don't get an error that the XML is invalid, but of course then the 'qtr' parameter is not sent.
I also tried switching the & with a ; which did not cause the invalid XML error, but the second parameter is not read in the php as being there. How can I send both parameters?
Well after I posted my question, I thought of something....the & wasn't being interpreted as a &, so I changed the Link to be:
<Link id="pdfLink" xmlns="sap.m" text="Create PDF" href="https://.../scripts/pdf/index.php?yr={/yr}&qtr={/qtr}" target="_blank"></Link>
(I changed the & to be &) This change worked!

struts2. add path to url

I'm working with struts2.
An external app calls to my app with url
http://localhost:8080/present/jsp/mi.action?cod=02021
But because of my JSP file system, my action result is in
http://localhost:8080/present/jsp/ALTE/mi.action?cod=02021
(note the difference in ALTE).
The JSP has some lines as
<%# include file="../comuns/comunCssyJs.jsp"%>
The first ../ is to go out ALTE.
If I access with first link the page is loaded but no include files are found. However, with second link there is no problem.
Does someone know what can I do? I know I can change my JSP-s dir-s, but I'd prefer to "add automatically" the ALTE path to the url. is that possible?
Thanks in advance.
Jon
Use Struts2 <s:include> tag http://struts.apache.org/2.x/docs/include.html with <s:url> tag http://struts.apache.org/2.x/docs/url.html.

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.

grails <g:link tag sometimes works and sometimes doesn't>

The
<g:link controller="foo" action="bar">foobar</g:link>
tag sometimes works, that is is renders as
foobar
and sometimes it doesn't. In this case I'll get a
foobar
Does anyone know what conditions cause this tag to fail to expand? Also is there any way to debug the tag expansion logic?
To debug - the file you need is at
$GRAILS_HOME\src\java\org\codehaus\groovy\grails\plugins\web\taglib\ApplicationTagLib.groovy
This might not solve your problem or everyone else's, but I had this same problem occur for me. I had a /mywebapp/session/login URL that I wanted to link to, but <g:link controller="session" action="login"> just resolved to /mywebapp/.
But it turns out that I had mapped my context root "/" to show the login page. I had thought it would redirect, but really it exposed the Session.login page at "/". So, when grails was told to create a link to go to Session.login, the simplest link it could come up with that would take me there was "/". So "/" was correct after all.
If you still can't get it working, but you still need a way to generate links relative to your context root, you can use <a href="${createLink(uri: '/foo/bar')}">
Only one remark which may be useful:
If you are in a file .gsp into the folder:
view
controller_name
your_view.gsp
This works fine: >> <a href="${createLink(uri: '/foo/bar')}">
If you are in a file .gsp into the src/template (for example to modify the list.gsp, create.gsp, etc.):
You have to add a backslash like this:<a href="\${createLink(uri: '/foo/bar')}">

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