Get home page from template

04 Feb '14, 11:37 PM
34,444 Views
Forum Forum Expert - Level 5

Hello

I want to get the name of the page you are as a home page on the site to view my project from a template. This to redirect this page in error case. My used code is:

#?delimiters [%, %], [%=, %]
[% def homePage = getHomePage(getHomeSiteView())
   if(homePage != null && homePage["customURLName"] != ""){
      homePage = getWebAppPath(homePage)
   } else {
      homePage = homePage["id"]
   }
%]
<%response.sendRedirect(response.encodeRedirectURL("[%= homePage%].do"));%>

But I have another url

 

Thanks

 

 
x 3
Follow
Answer Answer at this question and get points!
Forum Hero - Level 9

Hi, other option could be:

#?delimiters [%, %], [%=, %]
[% def homePage = getHomePage(getHomeSiteView())
   if(homePage != null && homePage["customURLName"] != ""){
      homePage = getWebAppPath(homePage)
   } else {
      homePage = homePage["id"]
   }
%]
<script type="text/javascript">
window.location="[%=homePage%].do";
</script>

   
x 0
Forum Expert - Level 5

Try with <wr:Id context="homePage"/>.do

 
x 1
No Forum Badges

Good solution Guillermo.... It´s very simple

 
x 0
Forum Hero - Level 9

Hi,

you can use this code 

#?delimiters [%, %], [%=, %]
[% def homePage = isProtectedAncestorOrSelf(page) ? getById(page.selectSingleNode("ancestor::SiteView")?.attributeValue("homePage")) : getHomePage(getHomeSiteView())
    homePage = (homePage != null) ? (homePage["id"] + ".do") : "#"
%]


<%response.sendRedirect(response.encodeRedirectURL("[%= homePage%]"));%>

Also works!

 
x 0
Forum Expert - Level 5

Thanks Guillermo

But I am using Login.login.page with code <wr:Id context="homePage"/> do, I get the following error:

No se puede compilar la clase para JSP: Ha tenido lugar un error en la línea: 3 en el archivo jsp: /ApisStyle_Login.login.jsp The method encodeRedirectURL(String) in the type HttpServletResponse is not applicable for the arguments (String, String) 1: <!DOCTYPE html> 2: 3: <%response.sendRedirect(response.encodeRedirectURL("<wr:Id context="homePage"/>.do"));%> 4: 5: <%@ page contentType="text/html; charset=UTF-8" %> 6: <%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %> Ha tenido lugar un error en la línea: 3 en el archivo jsp: /ApisStyle_Login.login.jsp Syntax error on token "homePage", , expected 1: <!DOCTYPE html> 2: 3: <%response.sendRedirect(response.encodeRedirectURL("<wr:Id context="homePage"/>.do"));%> 4: 5: <%@ page contentType="text/html; charset=UTF-8" %> 6: <%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %> Stacktrace:

 

 
x 0
Forum Expert - Level 5

Thanks Verónica

With your code in the template Login.login.page, I can not compile so you always get the url

http://localhost:8080/Proyecto/[%=%20homePage%]

Thanks for the help

 
x 0
Forum Expert - Level 5

Thanks Veronica

 

Slds

 
x 0
Answer at this question and get points!

Related questions

2 grids inside one/same cell result in non-selectable 2nd grid Access page variable in a page template add html Ajax is not working in own style project Ajax web app with javascript history object using the WebRatio Alimentar graficas con base de datos Alternate way to get current User Oid in layout template groovy script? Any way to localize the Tab Grid Template (Webratio Store)? Applicare un template ad un Web Project Ayuda Simple List Component Layout personalizado Bootstrap Style Button to go on another page Cambiare dimensioni bottoni - Change button size Can I inject html into custom unit template?! Change color template bootstrap style Change Style Changing the login page does not work ckeditor - change directory for the browser Colore Attributi index unit Dinamico - Index unit dynamic attribute color Como abrir una ventana en ajax desde una master page Como embeber un video subido desde archivo ? Como mostrar una imagen de portada arriba del menu? Como mostrar una imagen en una lista o en la componente detalles? Confirm Dialog Customize layout mobile platform Custom Tooltip Position Default error pages default login page Display contents of a URL Dynamic link labelling for Custom Unit Error in Excel Unit - Font size Export to a HTML/CSS/JS project Field as link soruce File CSS non considerato in generazione Form element Form template Get date pattern Google map is not shown properly in the tab grid Guardar Saltos de LINEA HelloWorld Unit sample code Hiding landmarks (or flows) when the user is logged in How can i create pagemenu or landmarkmenu with multiple levels. How can I modified the htmls files to perform my style How to add an image in a modal/pop-up window? How to include a template into other template? How to localize AJAX waiting dialog? How to localize the multi message unit in the notification layout How to modify template? How to modify the FertileEnviroment Default page How to remove default Linked Resources? How to use LandmarkMenu as AJAX navigation how to use the landmark menu as AJAX navigation integrate framework to webratio mobile Integrazione javascript Javascript and html javascript history object Localize "Welcome..." and "Process details" logo webratio meaning of each tag in the XML code (Show XML/Show Layout XML) modify field html Modify html generated by wr:NavigationBar Pages Problem After Project Generation pass template variable Problem Login Form only if user not logged Problem print Problems with the page refresh (Tab Grid) Problem with adding templates query unit who to hide fields that are used in a link Recursive Hierarchical Index Unit Style Tree Redirect to the default module Remove default BPM css import for all templates Responsive Bootstrap Grid Responsive Layout Manager Set context parameter Simple Static Page Standard confirm dialog replacement Style hierarchical unit help!! Supoort for Mobile and Desktop display Target tabs in Tab Grid Control Tooltip on a field Too much layout parameters = no scroll in parameters config window Uppercase Use image as interaction flow Vista de diferentes Site Views Webratio Add-ons no permite login wr-ajaxDivs break layout on ajax pages.