Dinamik Sayfa Yüklemede Sorun- ui:include

UI Components for JSF
Post Reply
kemalsekerci
Posts: 3
Joined: 11 Aug 2010, 22:21

12 Aug 2010, 21:57

Merhabalar,

primefaces ile navigasyon sayfası oluşturmaya çalışıyorum ama başaramadım. sayflarımı ui:include içerisinde bean den referans alarak menu değişikliklerinde yeni sayfayı yüklemek istiyorum... center kısmındaki h:outputtext güncellenmesine rağmen ui:include yeni sayfayı yüklemiyor.


netbeans 6.9.1
glassfish v3
jsf 2
primefaces 2.1



web.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <context-param>
        <description>DO NOT CHANGE State saving method: "client" or "server" (= default) See JSF Specification 2.5.2</description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</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>

    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>
        org.primefaces.resource.ResourceServlet
        </servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
    <context-param>
        <param-name>com.sun.faces.allowTextChildren</param-name>
        <param-value>true</param-value>
    </context-param>

    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>bundles/login/jsf/login.xhtml</welcome-file>
    </welcome-file-list>
</web-app>
template.xhtml

Code: Select all

<?xml version="1.0" encoding="ISO-8859-9" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      >
    <h:head>
        <title><ui:insert name="title" /></title>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1254" />
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-9" />
        <meta http-equiv="content-language" content="TR" />
        <meta http-equiv="cache-control" content="no-cache" />
        <link type="text/css" rel="stylesheet" href="/KuryeEAR-war/css/default.css" />
        <link type="text/css" rel="stylesheet" href="/KuryeEAR-war/css/skin.css" />
        <link type="text/css" rel="stylesheet" href="/KuryeEAR-war/css/syntax.css" />
        <script type="text/javascript">

        </script>
    </h:head>
    <h:body>
            <p:layout fullPage="true">

                <p:layoutUnit position="top" height="75">
                    <ui:insert name="top">
                        <h:outputText value="Top content." />
                    </ui:insert>
                </p:layoutUnit>

                <p:layoutUnit position="bottom" height="75" resizable="true">
                    <ui:insert name="bottom">
                        <h:outputText value="Bottom content." />
                    </ui:insert>
                </p:layoutUnit>

                <p:layoutUnit position="left" width="200" h:header="Left" resizable="true" closable="true" collapsible="true">
                    <ui:insert name="left">
                        <h:outputText value="Left content." />
                    </ui:insert>
                    
                </p:layoutUnit>

                <p:layoutUnit position="right" width="200" h:header="Right" resizable="true" closable="true" collapsible="true">
                    <ui:insert name="right">
                        <h:outputText value="Right content." />
                    </ui:insert>
                </p:layoutUnit>

                <p:layoutUnit position="center">
                    <ui:insert name="center">
                        <h:outputText value="Center content." />
                    </ui:insert>
                </p:layoutUnit>

            </p:layout>
    </h:body>
</html>
navigation.xhtml

Code: Select all

<?xml version="1.0" encoding="ISO-8859-9" ?>
<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:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="/templates/template.xhtml">

    <ui:define name="left">
        <h:form prependId="false">
            <p:commandLink value="Page1"  action="#{navigationBean.handleCommandLink}" oncomplete="alert(1);updateCenter()" update="@none">
                <f:param name="centerSrc" value="/bundles/admin/jsf/vehicleOperations.xhtml" />
            </p:commandLink>
            <br />
            <p:commandLink value="Page2" action="#{navigationBean.handleCommandLink}" oncomplete="alert(1);updateCenter()" update="@none">
                <f:param name="centerSrc" value="/bundles/admin/jsf/userOperations.xhtml" />
            </p:commandLink>

            <p:remoteCommand name="updateCenter" process="@none" update="center" />
        </h:form>
    </ui:define>

    <ui:define name="center">
        
            <p:outputPanel id="center" >
                <h:outputText value="#{navigationBean.centerSrc}" />
                <ui:include src="#{navigationBean.centerSrc}"  />
            </p:outputPanel>
       
    </ui:define>

</ui:composition>
navigationBean.java

Code: Select all

@ManagedBean(name = "navigationBean")
@ViewScoped
public class NavigationBean implements Serializable {

    public NavigationBean() {
        System.out.println("CONSTRUCTOR");
    }
    private String _centerSrc = "/bundles/kurye/jsf/mainPage.xhtml";

    public String getCenterSrc() {
       return _centerSrc;
    }

    public void setCenterSrc(String centerSrc) {
        this._centerSrc = centerSrc;
    }

    public String handleCommandLink() {
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        String centerSrct = request.getParameter("centerSrc");
        System.out.println("centerSrc" + centerSrct);
        setCenterSrc(centerSrct);
        return "";
    }
page1-page2 sayfaları sadece panel header alanı değişien sayfalar
pages.xhtml

Code: Select all

<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:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                >
    <p:panel header="User" >
        <h:outputLabel value="user"/>
    </p:panel>

</ui:composition>

kemalsekerci
Posts: 3
Joined: 11 Aug 2010, 22:21

12 Aug 2010, 22:39

Sorun beanimin @viewscope anatosyonu yüzündenmiş... @sessionscope yazınca düzeliyor. @viewscope yazmakla aptalca bir iş yaptım herhalde...

insanın kendi sorusuna cevap vermesi ne güzel... :)

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

13 Aug 2010, 10:26

:)

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 48 guests