jsf - POST http://localhost:8080/Languages/WEB-INF/inventory.xhtml 404 (No Encontrado) -


i using facelets in views jsf 2.0. have 2 backing beans, 2 xhtml view files , xhtml template file. when have second view in webapp directory , change language ok when put mi second view web-inf folder , change language have following error in chrome network console:

post http://localhost:8080/languages/web-inf/inventory.xhtml 404 (no encontrado) 

these backings beans:

languagebean.java:

package com.testapp;  import java.io.serializable; import java.util.linkedhashmap; import java.util.locale; import java.util.map;  import javax.faces.bean.managedbean; import javax.faces.bean.sessionscoped; import javax.faces.context.facescontext;  @managedbean(name = "language") @sessionscoped public class languagebean implements serializable {      private static final long serialversionuid = 1l;      private string localecode;     private static final string default_local_code = "es";      private static map<string, object> countries;     static {         countries = new linkedhashmap<string, object>();         countries.put("english", locale.english); // label, value         countries.put("français", locale.french);         countries.put("español", new locale("es"));     }      public map<string, object> getcountriesinmap() {         return countries;     }      public string getlocalecode() {         if(localecode == null) {             localecode = default_local_code;         }         return localecode;     }      public void setlocalecode(string localecode) {         this.localecode = localecode;     }      public void changelanguage() {          // loop map compare locale code         (map.entry<string, object> entry : countries.entryset()) {              if (entry.getvalue().tostring().equals(localecode)) {                  facescontext.getcurrentinstance().getviewroot().setlocale((locale) entry.getvalue());              }         }      }  } 

inventorybean.java:

package com.testapp;  import java.io.serializable; import java.util.locale;  import javax.faces.bean.managedbean; import javax.faces.bean.viewscoped; import javax.faces.context.facescontext;  import org.slf4j.logger; import org.slf4j.loggerfactory;  @managedbean(name = "inventory") @viewscoped public class inventorybean implements serializable {      private static final long serialversionuid = 4576404491584185639l;      logger logger = loggerfactory.getlogger(inventorybean.class);      // failing path private static final string inventory_main_view = "/web-inf/inventory"; // working path     // private static final string inventory_main_view = "/views/inventory";      public string findproducts() {          try {             system.err.println("in inventory backing bean");         } catch (exception exception) {         }          return inventory_main_view;      }      public void changelanguage() {         facescontext.getcurrentinstance().getviewroot().setlocale((locale.english));     }  } 

these view files:

default.xhtml

<?xml version="1.0" encoding="utf-8"?> <!doctype composition public "-//w3c//dtd xhtml 1.0 transitional//en"  "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml"     xmlns:f="http://java.sun.com/jsf/core"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:p="http://primefaces.org/ui"     xmlns:ui="http://java.sun.com/jsf/facelets"     template="/web-inf/header.xhtml">     <ui:define name="contentbody">         <f:view locale="#{language.localecode}">             <h:form id="contentform">                 <h:outputtext value="#{msg['internationalization.test']}" />                 <p:commandbutton id="gettingproducts"                     value="getting products..." action="#{inventory.findproducts}" />             </h:form>         </f:view>     </ui:define> </ui:composition> 

inventory.xhtml:

<?xml version="1.0" encoding="utf-8"?> <!doctype composition public "-//w3c//dtd xhtml 1.0 transitional//en"  "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml"     xmlns:f="http://java.sun.com/jsf/core"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:p="http://primefaces.org/ui"     xmlns:ui="http://java.sun.com/jsf/facelets"     template="/web-inf/header.xhtml">     <ui:define name="contentbody">         <f:view locale="#{language.localecode}">             <h:form id="contentform">                 <h:outputtext value="#{msg['internationalization.test']}" />             </h:form>         </f:view>     </ui:define> </ui:composition> 

and template xhtml file (header.xhtml):

<?xml version='1.0' encoding='utf-8' ?> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"     xmlns:f="http://java.sun.com/jsf/core"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:p="http://primefaces.org/ui"     xmlns:ui="http://java.sun.com/jsf/facelets"> <f:view contenttype="text/html">     <h:head>     </h:head>     <h:body>         <div id="content">             <h:form id="headerform">                 <h:panelgrid columns="2">                     <p:outputlabel value="language :" for="languages" />                     <h:selectonemenu required="true" id="languages"                         value="#{language.localecode}">                         <f:selectitems value="#{language.countriesinmap}" />                         <p:ajax event="change" update="@all"                             listener="#{language.changelanguage}" />                     </h:selectonemenu>                 </h:panelgrid>             </h:form>             <ui:insert name="contentbody" />         </div>     </h:body> </f:view> </html> 

what happening?

a http 404 error means "page not found". , indeed, files inside /web-inf folder not publicly accessible. put files intented publicly accessible outside /web-inf folder.

note has further nothing internationalization. you'd have had same problem when not doing regard internationalization (e.g. simple navigation).

see also:


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -