Como mostrar URL na pagina inicial

2 respostas
D
Ola pessoal, alguem sabe como mostar a url da pagina index ao iniciar o programa? Estou usando JSF com Facelets porem quando inicializo minha aplicação é mostrdo na url : http://localhost:8082/frameworkFacelets/ e não carrega meus css,mas minha pagina abre normalmente , porem se eu colocar na URL: http://localhost:8082/frameworkFacelets/faces/index.xhtml na mão o css da pagina carrega normalmente, alguem ja teve esse tipo de problema, não acho nada na net, Tem como eu carregar a pagina inicial com a url inteira ?
" URL: http://localhost:8082/frameworkFacelets/faces/index.xhtml"

Meu web.xml esta assim:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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_2_5.xsd">

    <description>Framework</description>
    <display-name>Estratege Framework</display-name>

     <filter>
        <display-name>RichFaces Filter</display-name>
        <filter-name>richfaces</filter-name>
        <filter-class>org.ajax4jsf.Filter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>richfaces</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
    </filter-mapping>


    <filter>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
        <init-param>
            <param-name>uploadMaxFileSize</param-name>
            <param-value>20m</param-value>
        </init-param>
    </filter>

<!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages  -->
    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
    <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

<!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.)  -->
    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>/faces/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>*.faces</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>MyFacesExtensionsFilter</filter-name>
        <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
    </filter-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>

   <context-param>
        <param-name>com.sun.faces.verifyObjects</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.validateXml</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>false</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>

    <!--<context-param>
        <param-name>org.ajax4jsf.SKIN</param-name>
        <param-value>#{backSkin.skin}</param-value>
    </context-param>-->

    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>

    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>

    <error-page>
        <error-code>500</error-code>
        <location>/errorPage.jsp</location>
    </error-page>

    <mime-mapping>
        <extension>html</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>

    <mime-mapping>
        <extension>txt</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>
    </web-app>
Tempalte.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:ui="http://java.sun.com/jsf/facelets">

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="../css/rodape.css" rel="stylesheet" type="text/css" />
        <link href="../css/top.css" rel="stylesheet" type="text/css" />
        <link href="../css/conteudo.css" rel="stylesheet" type="text/css" />
        <link href="../css/table.css" rel="stylesheet" type="text/css" />
        <link href="../css/buttons.css" rel="stylesheet" type="text/css" />
        <link href="../css/form.css" rel="stylesheet" type="text/css" />

        <title>Facelets Template</title>
    </head>

    <body>
        <!--Topo da pagina onde se encontra o baner e o menu-->
        <div id="top">
            <ui:include src="inc/topo.xhtml"/>
        </div>

        <!--Campo que representa o conteudo da pagina-->
        <div id="content" class="body">
            <br/><br/><br/>
            <ui:insert name="cont">This is Default cout </ui:insert>
        </div>

       <!--Rodape da Pagina-->
       <div id="bottom">
            <ui:include src="inc/rodape.xhtml"/>
        </div>

    </body>

</html>

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

    <body>
        <div id="conteudo">

        <ui:composition template="/newTemplate.xhtml">
            <ui:define name="cont">
                 
                My Home Page
                Clik no link para segunda pagina
                <h:panelGrid>
                    <h:panelGrid columns="2" width="400"
                                 headerClass="titulos">

                        <rich:simpleTogglePanel id="pic" switchType="client"
                                                width="200" height="200"
                                                label="Componentes Utilizados">
                            <ul>
                                <li>SQL Server 2000</li>
                                <li>Eclipselink</li>
                                <li>Facade</li>
                                <li>ConnectionFactory</li>
                                <li>Matriz e GenericBean</li>
                                <li>DAO e EntityManager</li>
                                <li>RichFaces da Seam JBoss</li>
                            </ul>

                        </rich:simpleTogglePanel>
                        <rich:simpleTogglePanel switchType="client"
                                                width="200" height="200"
                                                label="Padrões Utilizados">
                            <ul>
                                <li>JDBC</li>
                                <li>JPA</li>
                                <li>EJB</li>
                                <li>JDBC</li>
                                <li>Generics</li>
                                <li>Persistence</li>
                                <li>JSF</li>
                            </ul>
                        </rich:simpleTogglePanel>
                    </h:panelGrid>
                </h:panelGrid>
            </ui:define>
        </ui:composition>
        </div>
    </body>

</html>

Tudo funciona perfeitamente somento o css nao carrega ao inicializar a aplicação(somente ao inicializar), se eu entrar em outra tela o css funciona e quando volto para a index ele funciona normalmente..
Tem como mostrar a url no quando sobe a aplicação????

Desde ja agradeço a atenção..

2 Respostas

D

Eu estou usando a url :http://localhost:8082/frameworkFacelets/faces/index.xhtml" para chamar minha pagina, essa forma é a correta?ou tenho que chamar .jsf ? pois quando configuro no xml como .jsf não consigo carregar o css .

D

Resolvi o problema do css, configurei no web.xml

<servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>

e eu estava adicionando o css de forma errada, ficou assim

head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="./css/conteudo.css" rel="stylesheet" type="text/css" />
        <link href="./css/buttons.css" rel="stylesheet" type="text/css" />
        <link href="./css/table.css" rel="stylesheet" type="text/css" />
        <link href="./css/form.css" rel="stylesheet" type="text/css" />
        <link href="./css/top.css" rel="stylesheet" type="text/css" />

</head>

Css esta funcionando perfeitamente, porem o menu tomahowk não aparece na index.jsf, mas se eu colocar o caminho da index na mão ai ele aparece normalmente, alguem sabe me dizer se tem algum jeito de quando subir o programa aparecer o caminho inteiro da URL?

Criado 28 de maio de 2009
Ultima resposta 2 de jun. de 2009
Respostas 2
Participantes 1