Search code examples
javajsficefaces

Why is this Icefaces component not allowing my application to work?


I have a index.xhtml page listing books. Once a book is clicked it goes to book.xhtml to show the particular details of that book. It works. However for my project im meant to use Icefaces. When I add an Iceface component, a ice:panelTabSet, to book.xhtml clicking the links on the index.xhtml wont redirect to book.xhtml anymore. Could anyone shed any light on this?

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:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>BookShop</title>

    </h:head>
    <h:body>

        <h:form>
       <ul>
    <ui:repeat value="#{bookCatelogBean.books}" var="book">
        <li>
            <h:commandLink action="bookDetails">#{book.title}
                <f:param name="id" value="#{book.id}" />
            </h:commandLink>
        </li>
    </ui:repeat>
</ul>
        </h:form>

    </h:body>
</html>

book.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:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ice="http://www.icesoft.com/icefaces/component">
    <h:head>
        <title>BookShop</title>

    </h:head>
    <h:body>

        #{book.title}

        <h:graphicImage id="image1" value="#{book.coverImage}" /> 

        #{book.description}

        <ice:panelTabSet styleClass="tabSet" tabPlacement="bottom" align="right">
            <ice:panelTab label="label1"> 
                <ice:outputText value="Label" />
            </ice:panelTab>
            <ice:panelTab label="label2"> 
                <ice:outputText value="Label2" />
            </ice:panelTab>
            <ice:panelTab label="label3">
                <ice:outputText value="Label3" /> 
            </ice:panelTab>
        </ice:panelTabSet>
    </h:body>
</html>

Solution

  • The <h:commandLink> doesn't seem to point to any existing page. You've set it to bookDetails, but the target view ID is book (from book.xhtml). You also don't need POST here, it would only make the links uncrawlable by searchbots and unbookmarkable by endusers.

    Use <h:link> instead and set its outcome to book instead of bookDetails.

    <h:link value="#{book.title}" outcome="book">
        <f:param name="id" value="#{book.id}" />
    </h:link>
    

    Don't forget to remove the <h:form>.