Reply To: Need help with Navigation

Splash Forums PrettyFaces Users Need help with Navigation Reply To: Need help with Navigation

#26644

Andreu
Participant

Good day! Update links (now google disk) and add code on post.
Now have another problem πŸ™‚
One of pages don’t do URL rewriting and don’t see a parameter.

pretty-config.xml

    <url-mapping id="home">
        <pattern value="" />
        <view-id value="/faces/index.xhtml" />
    </url-mapping>
    
    <url-mapping parentId="home" id="viewCategory">
        <pattern value="/#{ category : categoryBean.categoryName }"/>
        <view-id value="/faces/somethingList.xhtml"/>
    </url-mapping>
    
    <url-mapping  parentId="viewCategory" id="viewProduct">
        <pattern value="/#{ product : productBean.id }/"/>
        <view-id value="/faces/product.xhtml"/>
    </url-mapping>

First page – list categories (View)
First page – list categories (Code)

        <h:form>
            <p:dataGrid var="category" value="#{categoryController.categories}" columns="4" layout="grid"
                        rows="16" id="cars">
                <f:facet name="header">
                    CATEGORIES
                </f:facet>
                <h:link outcome="somethingList">
                    <p:panel header="#{category.id}" style="text-align:center">
                        <h:panelGrid columns="1" style="width:100%">
                            <h:outputText value="#{category.categoryName}" />
                        </h:panelGrid>
                    </p:panel>
                    <f:param name="category" value="#{category.categoryName}" />
                </h:link>
            </p:dataGrid>
        </h:form>

Second page – list products (View)
Second page – list products (Code)

        <h:form>
            <p:dataGrid var="product" value="#{productController.getProductsByCategory(categoryBean.categoryName)}" columns="4" layout="grid"
                        rows="16" id="cars">
                <f:facet name="header">
                    PRODUCTS
                </f:facet>
                <h:link outcome="product">
                    <p:panel header="#{product.id}" style="text-align:center">
                        <h:panelGrid columns="1" style="width:100%">
                            <h:outputText value="#{product.autoMark}" />
                        </h:panelGrid>
                    </p:panel>
                    <f:param name="product" value="#{product.id}" />
                </h:link>
            </p:dataGrid>
            <h:outputFormat value="Hello from SomethingList categoryName = {0}.">
                <f:param value="#{categoryBean.categoryName}" />
            </h:outputFormat>
        </h:form>

Problem on Third page
Third page – product page (View)
Third page – product page (Code)

    <h:body>
        <h:outputFormat value="Hello from Product id = {0}. categoryName = {1}">
            <f:param value="#{productBean.id}" />
            <f:param value="#{categoryBean.categoryName}" />
        </h:outputFormat>
    </h:body>

in URL must be
/shop/car/1 and productBean.id = 1
but have
/shop/faces/product.xhtml?product=1 and productBean.id = null

if change configuration like this
pretty-config.xml

    <url-mapping  parentId="home" id="viewProduct">
        <pattern value="/#{ product : productBean.id }/"/>
        <view-id value="/faces/product.xhtml"/>
    </url-mapping>

or this

pretty-config.xml

    <url-mapping id="viewProduct">
        <pattern value="/#{ product : productBean.id }/"/>
        <view-id value="/faces/product.xhtml"/>
    </url-mapping>

Third page have normal URL and parameters

Why don’t work and what change to have URL – /shop/car/1?

  • This reply was modified 7 years, 1 month ago by  Andreu.
  • This reply was modified 7 years, 1 month ago by  Andreu.