spring - primefaces treetable expand not working if jsf page location is changed -


primefaces treetable expands if xhtml webpage in webcontent folder doesn't expand if move same webpage web-inf/views/jsf folder. i'm new jsf , don't know , change.

if webpage in web-inf/views/jsf folder root node visible. it's not expanding if click it.

html code

<?xml version="1.0" encoding="utf-8" ?> <html xmlns="http://www.w3.org/1999/xhtml"     xmlns:ui="http://java.sun.com/jsf/facelets"     xmlns:h="http://java.sun.com/jsf/html"     xmlns:f="http://java.sun.com/jsf/core"     xmlns:p="http://primefaces.org/ui"> <h:head>     <f:facet name="first">         <meta http-equiv="x-ua-compatible" content="ie=9" />      </f:facet> </h:head> <h:body class="page">     <h:outputstylesheet name="philos.css" />     <h:outputstylesheet name="primefaces.css" />     <h:form>         <p:treetable value="#{treeview.newroot}" var="document" id="treetable" >             <p:column headertext="name">                 <h:outputtext value="#{document.name}" />             </p:column>             <p:column headertext="size">                 <h:outputtext value="#{document.size}" />             </p:column>             <p:column headertext="type">                 <h:outputtext value="#{document.type}" />             </p:column>         </p:treetable>     </h:form> </h:body> </html> 

managed bean

package com.maintechnicalframework.sa.controller;  import java.io.serializable; import java.util.arraylist; import java.util.list;  import javax.annotation.postconstruct; import javax.faces.bean.managedbean; import javax.faces.bean.viewscoped; import javax.servlet.http.httpservletrequest;  import org.primefaces.model.defaulttreenode; import org.primefaces.model.treenode; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.controller; import org.springframework.ui.modelmap; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.sessionattributes;  import com.maintechnicalframework.common.constants.mainconstants; import com.maintechnicalframework.common.controller.maincontroller; import com.maintechnicalframework.common.model.loginuserdetails; import com.maintechnicalframework.sa.contants.systemattributeconstants; import com.maintechnicalframework.sa.model.document; import com.maintechnicalframework.sa.service.systemattributeservice; import com.maintechnicalframework.sa.validator.systemattributevalidator; @controller @requestmapping("/faces") @managedbean(name="treeview") @viewscoped @sessionattributes({ mainconstants.current_instance, mainconstants.login_user_details, mainconstants.request_param} ) public class systemattributemanagedbean extends maincontroller implements serializable{     @autowired     private systemattributeservice systemattributeservice;     @autowired     private systemattributevalidator systemattributevalidator;     private list<string> samplelist = new arraylist<string>();      @requestmapping("/showtree")     public string showtree( httpservletrequest httprequest, modelmap model ){         mainerror.clearerrors();         model.put(mainconstants.error_obj, mainerror);         validatesso(model, systemattributevalidator, true );        if( loginuserdetails == null ){           model.addattribute( mainconstants.invalid_info, mainconstants.invalid_sso_info );           return mainconstants.invalid_sso_page;       }else{           return systemattributeconstants.edit_tree;       }      }     private treenode root;     treenode newroot;     private document selecteddocument;      @postconstruct     public void init() {         createdocuments();     }     public treenode createdocuments() {         newroot = new defaulttreenode(new document("files", "-", "folder"), null);          treenode documents = new defaulttreenode(new document("documents", "-", "folder"), newroot);         treenode pictures = new defaulttreenode(new document("pictures", "-", "folder"), newroot);         treenode movies = new defaulttreenode(new document("movies", "-", "folder"), newroot);          treenode work = new defaulttreenode(new document("work", "-", "folder"), documents);         treenode primefaces = new defaulttreenode(new document("primefaces", "-", "folder"), documents);          //documents         treenode expenses = new defaulttreenode("document", new document("expenses.doc", "30 kb", "word document"), work);         treenode resume = new defaulttreenode("document", new document("resume.doc", "10 kb", "word document"), work);         treenode refdoc = new defaulttreenode("document", new document("refdoc.pages", "40 kb", "pages document"), primefaces);          //pictures         treenode barca = new defaulttreenode("picture", new document("barcelona.jpg", "30 kb", "jpeg image"), pictures);         treenode primelogo = new defaulttreenode("picture", new document("logo.jpg", "45 kb", "jpeg image"), pictures);         treenode optimus = new defaulttreenode("picture", new document("optimusprime.png", "96 kb", "png image"), pictures);          //movies         treenode pacino = new defaulttreenode(new document("al pacino", "-", "folder"), movies);         treenode deniro = new defaulttreenode(new document("robert de niro", "-", "folder"), movies);          treenode scarface = new defaulttreenode("mp3", new document("scarface", "15 gb", "movie file"), pacino);         treenode carlitosway = new defaulttreenode("mp3", new document("carlitos' way", "24 gb", "movie file"), pacino);          treenode goodfellas = new defaulttreenode("mp3", new document("goodfellas", "23 gb", "movie file"), deniro);         treenode untouchables = new defaulttreenode("mp3", new document("untouchables", "17 gb", "movie file"), deniro);          return newroot;     }     public treenode getnewroot() {         return newroot;     }     public treenode getroot() {         return root;     }     public list<string> getlistofstring(){         loginuserdetails loginuserdetails = (loginuserdetails)getsessionobj(mainconstants.login_user_details);         samplelist.add("one");samplelist.add("two");samplelist.add("three");samplelist.add("four");         return samplelist;     }    /* public void actionhandler(actionevent event)throws exception{         system.out.println("jjjj");     }*/     public document getselecteddocument() {         return selecteddocument;     }      public void setselecteddocument(document selecteddocument) {         this.selecteddocument = selecteddocument;     } } 

my -servlet.xml

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:p="http://www.springframework.org/schema/p"     xmlns:context="http://www.springframework.org/schema/context"     xmlns:mvc="http://www.springframework.org/schema/mvc"     xsi:schemalocation="     http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans.xsd     http://www.springframework.org/schema/context     http://www.springframework.org/schema/context/spring-context.xsd     http://www.springframework.org/schema/mvc     http://www.springframework.org/schema/mvc/spring-mvc.xsd     ">      <!-- enable annotation driven controllers, validation etc... -->     <mvc:annotation-driven content-negotiation-manager="contentnegotiationmanager"/>     <bean id="contentnegotiationmanager" class="org.springframework.web.accept.contentnegotiationmanagerfactorybean">         <!-- turn off working out content type based on url file extension, should fall looking @ accept headers -->         <property name="favorpathextension" value="false" />     </bean>     <context:annotation-config />     <context:component-scan base-package = "com.mycompany.ondemand,com.oracle.ondemand.crm,com.maintechnicalframework"/>     <context:property-placeholder location="/web-inf/properties/config.properties"/>      <bean id="applicationcontextprovider" class="com.oracle.ondemand.crm.framework.context.applicationcontextprovider"/>      <bean id="viewresolver"         class="org.springframework.web.servlet.view.internalresourceviewresolver">          <property name="prefix">             <value>/web-inf/views/</value>         </property>     </bean>      <mvc:interceptors>         <bean id="localechangeinterceptor" class="org.springframework.web.servlet.i18n.localechangeinterceptor" depends-on="localemap">             <property name="paramname" value="language" />             <property name="localemap" ref="localemap" />         </bean>     </mvc:interceptors>     <bean id="localeresolver" class="org.springframework.web.servlet.i18n.sessionlocaleresolver" />      <bean id="messagesource"         class="org.springframework.context.support.reloadableresourcebundlemessagesource">         <!-- <property name="basename" value="file:/c:/xxxxx/messages" /> -->         <property name="basename" value="classpath:messages" />         <property name="fallbacktosystemlocale" value="false"/>         <property name="defaultencoding" value="utf-8"/>     </bean>  </beans> 

web.xml

<web-app xmlns="http://java.sun.com/xml/ns/javaee"       xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"       xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"       version="3.0">   <context-param>     <param-name>contextconfiglocation</param-name>     <param-value>/web-inf/*-config.xml</param-value>   </context-param>   <context-param>     <param-name>javax.faces.default_suffix</param-name>     <param-value>.xhtml</param-value> </context-param> <filter>     <filter-name>setcharacterencodingfilter</filter-name>     <filter-class>org.springframework.web.filter.characterencodingfilter</filter-class>     <init-param>       <param-name>encoding</param-name>       <param-value>utf-8</param-value>     </init-param>     <init-param>       <param-name>forceencoding</param-name>       <param-value>true</param-value>     </init-param>   </filter>   <filter-mapping>     <filter-name>setcharacterencodingfilter</filter-name>     <url-pattern>/*</url-pattern>   </filter-mapping>   <!-- cert implementation start -->   <filter>     <filter-name>csrffilter</filter-name>     <filter-class>org.springframework.web.filter.delegatingfilterproxy</filter-class>     <async-supported>true</async-supported> </filter> <filter-mapping>     <filter-name>csrffilter</filter-name>     <url-pattern>/mycompany/*</url-pattern>  </filter-mapping> <!-- cert implementation end -->   <session-config>     <session-timeout>60</session-timeout>   </session-config>   <listener>     <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>   </listener>   <listener>     <listener-class>         org.springframework.web.context.request.requestcontextlistener     </listener-class>   </listener>     <display-name>systemattribute</display-name>     <servlet>         <servlet-name>systemattribute</servlet-name>         <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>     <servlet-mapping>         <servlet-name>systemattribute</servlet-name>         <url-pattern>/mycompany/*</url-pattern>     </servlet-mapping>     <servlet>         <servlet-name>faces servlet</servlet-name>         <servlet-class>javax.faces.webapp.facesservlet</servlet-class>         <load-on-startup>1</load-on-startup>   </servlet>   <servlet-mapping>         <servlet-name>faces servlet</servlet-name>         <url-pattern>/faces/*</url-pattern>     </servlet-mapping>     <servlet-mapping>         <servlet-name>faces servlet</servlet-name>         <url-pattern>*.jsf</url-pattern>     </servlet-mapping>     <servlet-mapping>         <servlet-name>faces servlet</servlet-name>         <url-pattern>*.faces</url-pattern>     </servlet-mapping>     <servlet-mapping>         <servlet-name>faces servlet</servlet-name>         <url-pattern>*.xhtml</url-pattern>     </servlet-mapping>     <welcome-file-list>         <welcome-file>index.jsp</welcome-file>         <welcome-file>index.xhtml</welcome-file>     </welcome-file-list>     <!-- cert implementation start -->   <error-page>     <error-code>403</error-code>     <location>/unauthorizedpage.jsp</location> </error-page> <!-- cert implementation end --> </web-app> 

i had issue. did resolve steps below: step 1: move xhtml files webcontent folder. step 2: since files in webcontent allowed public access, need add below entry in web.xml security reason.

please follow link security restrictions: prevent direct access composite components placing them inside /web-inf


Comments

Popular posts from this blog

Java 3D LWJGL collision -

methods - python can't use function in submodule -

c# - ErrorThe type or namespace name 'AxWMPLib' could not be found (are you missing a using directive or an assembly reference?) -