pretty faces jsf glassfish не работи за мен

Използвам GlassFishV3, JSF2, pretty faces 3

Опитах много комбинации за премахване на моето разширение *.xhtml или за украсяване на моя URL адрес, но не успях да го направя.

Моля, ако знаете друго решение, дайте ми ПРИМЕР как да го направя или ако решението ми е правдоподобно, моля, кажете ми дали съм сгрешил:

Следвах урока на http://ocpsoft.org/prettyfaces/ и създадох тривиално приложение само с един индекс .xhtml и аз поставих връзка към home.xhtml (и двете са в WebContent).

  • Запазих буркана (не използвам Maven) и го поставих в WEB-INF/lib
  • според урока не е необходимо да променям моя web.xml, защото при използване на GlassFishv3
  • моят web.xml

    <?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app
    <pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.3 
    http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd ">
    
    <url-mapping id="home">
        <pattern value="/home" />
        <view-id value="/home.xhtml"/>
    </url-mapping> </pretty-config>
    
    5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app
    <!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"><ui:composition template="">
    <ui:define name="header">
        Add your header here or delete to use the default
    </ui:define>
    <ui:define name="content">
       <a id="home" href="/bghome.xhtml">Home</a>
    </ui:define>
    <ui:define name="footer">
        Add your footer here or delete to use the default
    </ui:define></ui:composition>
    
    0.xsd" id="WebApp_ID" version="3.0"> <display-name>extension</display-name> <welcome-file-list> <welcome-file>index.xhtml</welcome-file> </welcome-file-list> <context-param> <param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name> <param-value>true</param-value> </context-param> <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>*.xhtml</url-pattern> </servlet-mapping></web-app>
  • моят pretty-config.xml

    <pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.3 
    http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd ">
    
    <url-mapping id="home">
        <pattern value="/home" />
        <view-id value="/home.xhtml"/>
    </url-mapping> </pretty-config>
    
    • with this configuration I keep getting java.lang.StackOverflowError (with others or my app doesn`t compile or I get a different error) the loop is

    на com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:308) на com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:367) на com.sun.faces.facelets .impl.DefaultFacelet.include(DefaultFacelet.java:346) в com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199) в com.sun.faces.facelets.tag.ui.CompositionHandler.apply (CompositionHandler.java:155) в com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93) в com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)

    • моят index.xhtml работи, но когато щракна върху връзката, се появява горната грешка
    • Нямам никакви зърна (друг въпрос би бил дали трябва да поставя някакви пояснения към картографираните зърна, ако успея да направя красиви лица)

    Благодаря ви много за отделеното време!

Модификациите:

  • Направих тривиално уеб приложение, за да видя как работи скриването на разширението. index.xhtml

    <!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"><ui:composition template="">
    <ui:define name="header">
        Add your header here or delete to use the default
    </ui:define>
    <ui:define name="content">
       <a id="home" href="/bghome.xhtml">Home</a>
    </ui:define>
    <ui:define name="footer">
        Add your footer here or delete to use the default
    </ui:define></ui:composition>
    

and the home.xhtml

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="">
    <ui:define name="header">
        Add your header here or delete to use the default
    </ui:define>
    <ui:define name="content">
        home#######
    </ui:define>
    <ui:define name="footer">
        Add your footer here or delete to use the default
    </ui:define>
</ui:composition>
</html>

сега, ако стартирам приложението 127.0.01:8080/myapp, моментално има грешка java.lang.StackOverflowError

но ако просто сложа index.xhtml

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:body>
       <a id="home" href="/bghome.xhtml">Home</a>
</h:body>
</html>

и в home.xhtml

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:body>
HOME
</h:body>
</html>

работи, но разширението е представено, стартирано с 127.0.0.1:8080/myapp/ и след това щракнете върху връзката и 127.0.0.1:8080/myapp/home.xhtml

Искам да го направя като първия индекс и начало с шаблона, защото работя върху уеб приложение, което вече има шаблони. Id="home" в тага "a href" неt know if it is necesary, the id its използвах от CSS, за да го форматирам, но започвам да се отчайвам :))

Всяка помощ ще бъде оценена. Благодаря ти!

### MODIFICATIONS
  • така че започнах отново с тривиално уеб приложение, за да видя как работят красивите лица
  • сега неt get any errors but I still canне променям URL адреса си
  • какво направих досега:

  • Сложих pretty-faces-jsf-3.3.3.jar в WEB-INF/lib

  • Сложих WEB-INF pretty-config.xml

    <?xml version="1.0" encoding="UTF-8"?><pretty-config xmlns="http://ocpsoft.com/prettyfaces/3.3.3" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xsi:schemaLocation="http://ocpsoft.com/prettyfaces/3.3.3
                                        http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">
    
    <url-mapping id="home">
        <pattern value="/home" />
        <view-id value="/home.xhtml" />
    </url-mapping>
    

  • my web.xml

    <?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>test</display-name>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    <context-param>
        <param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
        <param-value>true</param-value>
    </context-param>
    <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>*.xhtml</url-pattern>
    </servlet-mapping></web-app>
    
  • в WEB-INF имам index.html, home.xhtml и template.xhtml

index.html

    <!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<h:body>
    <a href="/bghome.xhtml">HOME</a>
</h:body>
</html>

home.xhtml

<!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="/tempate.xhtml">
    <ui:define name="header">
        Add your header here or delete to use the default
    </ui:define>
    <ui:define name="content">
     ########################
    </ui:define>
    <ui:define name="footer">
        Add your footer here or delete to use the default
    </ui:define>
</ui:composition>
</html>

template.xhtml

    <!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:ui="http://java.sun.com/jsf/facelets">
<head>
  <title><ui:insert name="title">Default title</ui:insert></title>
</head>

<body>

<div id="header">
    <ui:insert name="header">
        Header area.  See comments below this line in the source.
        <!--  include your header file or uncomment the include below and create header.xhtml in this directory -->
        <!-- <ui:include src="header.xhtml"/> -->
    </ui:insert>
</div>


<div id="content">
  <ui:insert name="content">

                <ui:include src="home.xhtml" />

  </ui:insert>
</div>

<div id="footer">
  <ui:insert name="footer">
        Footer area.  See comments below this line in the source.
        <!--  include your header file or uncomment the include below and create footer.xhtml in this directory -->
        <!--<ui:include src="footer.xhtml"/>  -->
  </ui:insert> </div> </body></html>

Не съм променил моя web.xml с

    <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"><filter>
      <filter-name>Pretty Filter</filter-name>
      <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
      <async-supported>true</async-supported>
   </filter>

   <filter-mapping> 
      <filter-name>Pretty Filter</filter-name> 
      <url-pattern>/*</url-pattern> 
      <dispatcher>FORWARD</dispatcher> 
      <dispatcher>REQUEST</dispatcher> 
      <dispatcher>ERROR</dispatcher>
      <dispatcher>ASYNC</dispatcher>
   </filter-mapping></web-app>

защото използвам Glassfishv3

Както казах, това е тривиално уеб приложение, само за да видим как работи. Моля, помогнете ми да разбера защо имам затруднения...


person CyberGriZzly    schedule 23.11.2012    source източник
comment
Бихте ли споделили xhtml файла?   -  person chkal    schedule 24.11.2012
comment
Редактирах първоначалния си въпрос.   -  person CyberGriZzly    schedule 24.11.2012
comment
Какви са основните стъпки за настройка на красиви лица? Правя нещо определено грешно... Където и да погледна, пише, че е наистина лесно...   -  person CyberGriZzly    schedule 24.11.2012
comment
Наистина е лесно и е описано в документацията. Бихте могли да разгледате архетипите на Maven като бърз старт: github.com/chkal/prettyfaces- архетипи/уики   -  person chkal    schedule 27.11.2012
comment
С последната си модификация трябва да видите началната страница, ако въведете localhost:8080/myapp/home във вашия браузър. Вашият въпрос е доста объркващ с всички секции за модификация. Ако не работи, моля, публикувайте на ocpsoft.org/support и прикачете вашето примерно приложение. Сигурен съм, че ще можем да ви помогнем там.   -  person chkal    schedule 01.12.2012


Отговори (1)


Не мисля, че този проблем има нещо общо с PrettyFaces. Stacktrace показва само някои неща, свързани с Facelets:

at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:308)
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:367) 
at com.sun.faces.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:346) 
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:199) 
at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:155) 
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:93) 
at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:86)

Видях, че използвате празен атрибут template:

<ui:composition template="">

Вашата страница няма да работи без препратка към основен шаблон. Мисля, че това може да причини грешката, която получавате.

Между другото: Можете да тествате PrettyFaces без да използвате шаблони Facelets. PrettyFaces не знае нищо за шаблоните. Така че, ако работи без шаблони, ще работи и с шаблони. :)

person chkal    schedule 25.11.2012
comment
Някакви новини? Ако все още не работи, моля, публикувайте във форумите на PrettyFaces. Сигурен съм, че можем да ви помогнем там, ако качите вашето примерно приложение. ocpsoft.org/support - person chkal; 27.11.2012
comment
Наистина съжалявам за неудобството, но който и да ми даде отговор, който започва с Можете да опитате следното: Връзката от index.xhtml трябва да бъде пренаписана в pretty-config, могаt see your answer anywhere, Iполучих имейл, който казва, че Ive got an answer for my question on Nov 29. The email is as follows: The following items were added to your Stack Exchange global inbox since you last checked it on 2012-11-15: Nov, 29 pretty faces jsf glassfish doesnне работи за мен отговор: Можете да опитате следното: Връзката от index.xhtml трябва да бъде пренаписана в pretty-config.... - person CyberGriZzly; 30.11.2012