• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Subview

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am working on an app that is using subviews. I have a menu subview at the top of the page. the lower half is the main content area. To track navigation I have a navigation bean which keeps track of what the next page should be.

I can't get my subviews to display JSF components.

I initialy get my currentPage like this



then I load the subview with



the subview is a file saved as filename.jspf

and is within an <f:subview>

The page loads alright but isn't displaying any components.

Can anyone shed any light on this?

Thanks
 
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're doing JSF right.

Why aren't you using the JSF subview tag

<f:subview id="subview">
<%@ include file="your file" %>
</f:subview>

Maybe this helps
 
Peter Stewart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes JSF.

if I use <%@ include file="myFile"%>

how can I reference currentPage as per my example?

Cheers.
 
Remko Strating
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could define a backingbean within JSF which provides a value for myFile
 
Peter Stewart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I am pretty new at this, and appreciate the help.

Does my code...


...not do this?
I instansiated the bean like that because as I understand it a bean with session scope is not instansiated automaticaly till requested.

I did try


But that doesnt seem to be working
 
Remko Strating
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In JSF backingbeans are defined in a file called faces-config.xml as a standard name. The name could be different. The working is explained in the following manual

JSF tutorial

One of the reasons for using JSF is that you separate the definition of your backingbeans from the JSP so that maintenance is improved. And if you want to change your backingbean there is one single point of entry.

In this file you can also define your navigationrules.

I hope this helps
 
Peter Stewart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The backingBean was defined in facesconfig.xml"

The navigation is a bit different than normal because its a subview. IF you define a rule in fc.xml a subview will just load the destination page as a regular page.

When a backingbean is defined in fc.xml you still need to instansiate it before you do anything with it.

Normaly a value binding will cause it to be instansiated but obvioulsy that wont do in this case.

Anyway never mind, thanks for the help.

Peter.
 
Remko Strating
Ranch Hand
Posts: 893
Tomcat Server Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry that I can't help you. I try to understand your problem. If what I understand now is that the standaard way of navigating isn't helping you and that you have defined your own way. The problem with this is as my experience that you will encounter a lot of different problems because your are leaving a working of core-element of a framework.

But if you have a name binding in your <f:subview> the backingbean will be instantiated.

My JSF-applications I mostly also use a menu in a separate subview, but I don't experience any problems with the default navigation. Do you want to have different menu's visible depending on the page?

Also if you define a navigationrule on the mainform of the view where you include the subview. Only the mainform with the subview will be shown.

But now it's difficult for me to help you, because I don't know your exact problem.
 
Peter Stewart
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found the answer!

When using a <jsp:include...

you must use a jsp extension rather than jspf. No Idea why, found the answer from another message board where the reason is not known either.

Using jspf will work only if the included page does not contain JSF components.

BTW, for future readers of this thread. Using <jsp:include page="myfile.jsp" > rather than <%@ include file="myfile.jspf"%> is not as uncommon as some of the replies above would suggest.

"Mastering JavaServer faces" uses this syntax for working with subviews as does the JAVA EE tutorial on Sun's website.
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic