Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

template navigation problem

 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am reading a book in facelet (Facelets Essentials: Guide to JavaServerâ„¢ Faces View) trying faclet to get template
in navigation between pages i got message like this one (/index.xhtmlNo saved view state could be found for the view identifier: /index.xhtml)

while index.xhtml page applay template and include menu.xhtml but command hayberlink apper in run time like this

kindly some one help
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am making a guess that you're trying to set up a page template that serves as the container for different page implementations.

With facelets, you do this using the "ui:insert" tag in the container page and then define the contained page templates as ui:component objects which locate their container via the "template=" attribute of the ui:component element.

The URL that takes these resources (files) and assembles them into actual HTML is formed by stripping the "xhtml" off the ui component's filename and using the basename path as part of the web.xml-defined pattern. So, for example, since I like my JSF Facelets URLs to be in the form "basename.jsf", I could define uicomponents in "/forms/page1.xhtml", "/forms/page3.xhtml", "/forms/page3.xhtml". If these 3 components all used a common container template, I might put that in "/layouts/common.xhtml", and that's the value I'd code as the "template" attribute for the uicomponent tags in page1, page2, and page3.

Putting all that together, I could then visit page1 using the url http://myserver/mywebapp/forms/page1.jsf". To navigate to page2, I could then code the navigation pattern as "/forms/page2.jsf". Or, in JSF2, I could use the simplified forms: "/forms/page2" or even "page2" (since it's in the same directory as page1.
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very much



in conclusion i can not navigate in facelet like jsf
<h:commandLink value="click" action="success">
or
<h:commandLink value="click" action="bean.login">

it must be like <a href="yachts.faces">here</a>

is that right?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17995
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Facelets do not change how navigation, links or backing beans work. Nor do they change how J2EE sessions behave. Primarily, their function is to make it easier to lay out the geometry of JSF views for presentation in HTML.
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you


navigation does not effect by facelet becouse facelet job is to create template .

example in this book does not run navigation it create template and include menu
but
link display in run mode (< a href=# >)

why?
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you


navigation does not effect by facelet becouse facelet job is to create template . plays V in MVC

example in this book does not run navigation it create template and include menu
but

he puts links like

<h:commandLink value="Parrot" action="parrot" / >
<h:commandLink value="Eagle" action="eagle" />

and link display in run mode like this

<a href="#" onclick="return oamSubmitForm('j_id2','j_id2:j_id7');">Parrot</a>
<a href="#" onclick="return oamSubmitForm('j_id2','j_id2:j_id8');">Eagle</a>


why?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17995
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In WEB-INF/faces-config.xml:



This would allow you to create a template named "/birds/parrot.xhtml" and the commandLink would navigate to it. By using the action name instead of the actual URL in the commandLink, it is possible to change the View Definition location without having to change the Views that reference it. Instead you'd just update the to-view-id in faces-config.xml.

The <a href="#" onclick="return oamSubmitForm('j_id2','j_id2:j_id7');">Parrot</a> is the generated HTML, correct?

To make debugging easier, you should add an "id=" attribute to your <form> and commandLink elements.
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you i have add your syntext to faces-config.xml:
and run time syntex was
< a href="#" onclick="return oamSubmitForm('j_id2','j_id2:link1');" id="j_id2:link1"> Parrot < /a >


why?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17995
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hassan ali wrote:thank you i have add your syntext to faces-config.xml:
and run time syntex was
< a href="#" onclick="return oamSubmitForm('j_id2','j_id2:link1');" id="j_id2:link1"> Parrot < /a >


why?


Why not?
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

link does not redirect to page parrot.xhtml or parrot.jsf

but href=#


that gives me redirect to index.xhtml with save state error


why navigation error happend ?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17995
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. NOW I comprehend!

The "#" is just a placeholder. The real work is being done by the Javascript oamSubmitForm function supplied by JSF. Lack of saved state means that there's probably something wrong with how you specified how state is saved between pages. You have 2 options: client-side and server-side. Client-side is less secure and has more network overhead, server-side is more secure but has more server storage overhead.

In /WEB-INF/web.xml, you should have a statement like this:


Also check your server logs just in case you don't have enough memory allocated for your appserver.
 
hassan ali
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank sir


it works

good bless you .

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic