Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-25 Thread netsql
Rick, consider trying Faclets (from Java.net) w/ Struts Ti (from Dev 
List) combo; that may be more powerfull and more teachable.


.V


Rick Reumann wrote:

David Haynes wrote the following on 8/22/2005 4:19 PM:


I'm just fumbling my way through like most others...



Trust me you don't want me as your 'JSF running back' 
right now in JSF Fantasy Football. I've been fumbling in all my 
pre-season attempts at carrying the ball:) I think I'm averaging -20 
yards/carry.





--
thx,
.V

Broadband interface (RIA) + mail box saftey = Roomity.com
http://roomity.com/demo.jsp
*Your* clubs, no sign up to read, ad supported; try broadband internet.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Craig McClanahan
On 8/22/05, Rick Reumann [EMAIL PROTECTED] wrote:
 I'm looking in my Core JSF book and I can seem to find out how to do
 something that I would think would/should be pretty simple...
 
 How do I use a jsp:forward to trigger a method in my backing bean?
 
 jsp:forward page=/mybackingbean.faces??{call fooBar method}???/
 
 I see how JSF uses h:commandLink for it's link but not sure how this
 helps with JSP forwards.
 

It doesn't ... if you want to fire the standard request processing
lifecycle, you need to actually submit the request.  Using
jsp:forward page=/foo.faces/ will cause /foo.jsp to be rendered
(assuming you are using the standard extension mappings), entering the
JSF lifecycle at the Render Response phase.

What problem are you trying to solve with jsp:forward that can't be
solved a different way?

Craig

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Rick Reumann

Craig McClanahan wrote the following on 8/22/2005 12:50 PM:


It doesn't ... if you want to fire the standard request processing
lifecycle, you need to actually submit the request.  Using
jsp:forward page=/foo.faces/ will cause /foo.jsp to be rendered
(assuming you are using the standard extension mappings), entering the
JSF lifecycle at the Render Response phase.

What problem are you trying to solve with jsp:forward that can't be
solved a different way?


What I'm trying to figure out is the best way to handle setting up an 
initial page when someone goes to the welcome page defined in web.xml 
(ie index.jsp). What's the best way to handle this? On page 20 of Core 
JSF they give the example of doing something like jsp:forward 
page=/index.faces/ but I don't see how this would ever trigger a 
method in my backing bean?


For example, in this sample CRUD app I was wanting to load a list of 
employees right away that would show up on employees.jsp  I'm keeping 
this simple and will make this call to getEmployees in my 
EmployeeBacking bean, but I'm unclear about the best using JSF to fire 
this method and forward to the appropriate page when the user simply 
goes to foobarApp/index.jsp ?


Thanks for the help

--
Rick

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Michael Jouravlev
David Geary advised me to use rendered attribute of view of subview,
like this:
  f:subview id=step1 rendered=#{wizardBean.step1} 
You can stick whatever code you want into the method, and simply
return true. I don't know is there a better way to do this.

Michael.

On 8/22/05, Rick Reumann [EMAIL PROTECTED] wrote:
 What I'm trying to figure out is the best way to handle setting up an
 initial page when someone goes to the welcome page defined in web.xml
 (ie index.jsp). What's the best way to handle this? On page 20 of Core
 JSF they give the example of doing something like jsp:forward
 page=/index.faces/ but I don't see how this would ever trigger a
 method in my backing bean?
 
 For example, in this sample CRUD app I was wanting to load a list of
 employees right away that would show up on employees.jsp  I'm keeping
 this simple and will make this call to getEmployees in my
 EmployeeBacking bean, but I'm unclear about the best using JSF to fire
 this method and forward to the appropriate page when the user simply
 goes to foobarApp/index.jsp ?

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Rick Reumann

Michael Jouravlev wrote the following on 8/22/2005 2:41 PM:

David Geary advised me to use rendered attribute of view of subview,
like this:
  f:subview id=step1 rendered=#{wizardBean.step1} 
You can stick whatever code you want into the method, and simply

return true. I don't know is there a better way to do this.


So you would stick something like this on the index.jsp page? Ok I'll 
try that, thanks.


Maybe too soon for one, but is there a JSF 'best practices' out there 
somewhere?


--
Rick

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread David Haynes

Rick Reumann wrote:


Craig McClanahan wrote the following on 8/22/2005 12:50 PM:


It doesn't ... if you want to fire the standard request processing
lifecycle, you need to actually submit the request.  Using
jsp:forward page=/foo.faces/ will cause /foo.jsp to be rendered
(assuming you are using the standard extension mappings), entering the
JSF lifecycle at the Render Response phase.

What problem are you trying to solve with jsp:forward that can't be
solved a different way?



What I'm trying to figure out is the best way to handle setting up an 
initial page when someone goes to the welcome page defined in web.xml 
(ie index.jsp). What's the best way to handle this? On page 20 of Core 
JSF they give the example of doing something like jsp:forward 
page=/index.faces/ but I don't see how this would ever trigger a 
method in my backing bean?


For example, in this sample CRUD app I was wanting to load a list of 
employees right away that would show up on employees.jsp  I'm 
keeping this simple and will make this call to getEmployees in my 
EmployeeBacking bean, but I'm unclear about the best using JSF to fire 
this method and forward to the appropriate page when the user simply 
goes to foobarApp/index.jsp ?


Thanks for the help

If I understand you correctly, you have something like: index.jsp does a 
jsp:forward to foo.faces (a jsf page).
If so, then I think the backing bean is invoked in foo.faces when the 
jsp:useBean is referenced. So, the backing store bean is already 
created *before* the foo.faces is rendered to the browser. At least, 
that's the way it is working for me...


As a quick test, you could create a test foo.faces that contains:
body
jsp:useBean id=foo class=com.foo.FooBean
   jsp:getProperty name=foo property=*/
/jsp:useBean

The bean has this: jsp:getProperty name=foo property =string/
/body

and have the bean something simple like:

public class FooBean {
   priviate String string = foo;

   public FooBean() {
  super();
   }

   public String getString() {
  return string;
   }

   public void setString(String string) {
  this.string = string;
   }
}


-david-


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Craig McClanahan
On 8/22/05, Rick Reumann [EMAIL PROTECTED] wrote:
 Craig McClanahan wrote the following on 8/22/2005 12:50 PM:
 
  It doesn't ... if you want to fire the standard request processing
  lifecycle, you need to actually submit the request.  Using
  jsp:forward page=/foo.faces/ will cause /foo.jsp to be rendered
  (assuming you are using the standard extension mappings), entering the
  JSF lifecycle at the Render Response phase.
 
  What problem are you trying to solve with jsp:forward that can't be
  solved a different way?
 
 What I'm trying to figure out is the best way to handle setting up an
 initial page when someone goes to the welcome page defined in web.xml
 (ie index.jsp). What's the best way to handle this? On page 20 of Core
 JSF they give the example of doing something like jsp:forward
 page=/index.faces/ but I don't see how this would ever trigger a
 method in my backing bean?
 

It won't.  Only a form submit will trigger those method calls.

 For example, in this sample CRUD app I was wanting to load a list of
 employees right away that would show up on employees.jsp  I'm keeping
 this simple and will make this call to getEmployees in my
 EmployeeBacking bean, but I'm unclear about the best using JSF to fire
 this method and forward to the appropriate page when the user simply
 goes to foobarApp/index.jsp ?

Grab Shale.  Make your backing bean implement ViewController.  Stick
the list setup logic in the prerender() method.  Smile, knowing that
this technique works not only for the welcome page, but for *any* page
to which you navigate (in Struts Classic terms, this is the kind of
thing that you use a Controller for in Tiles).  :-)

If you wanted to do it the hard way, you could set things up to
register a phase listener, and call your list setup logic in a before
render response event handler ... but that's the part Shale takes
care of for you.

 
 Thanks for the help
 
 --
 Rick

Craig

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread David Haynes

Craig McClanahan wrote:


On 8/22/05, Rick Reumann [EMAIL PROTECTED] wrote:
 


Craig McClanahan wrote the following on 8/22/2005 12:50 PM:

   


It doesn't ... if you want to fire the standard request processing
lifecycle, you need to actually submit the request.  Using
jsp:forward page=/foo.faces/ will cause /foo.jsp to be rendered
(assuming you are using the standard extension mappings), entering the
JSF lifecycle at the Render Response phase.

What problem are you trying to solve with jsp:forward that can't be
solved a different way?
 


What I'm trying to figure out is the best way to handle setting up an
initial page when someone goes to the welcome page defined in web.xml
(ie index.jsp). What's the best way to handle this? On page 20 of Core
JSF they give the example of doing something like jsp:forward
page=/index.faces/ but I don't see how this would ever trigger a
method in my backing bean?

   



It won't.  Only a form submit will trigger those method calls.
 

Sorry to hi-jack this thread a bit, but I am confused. Can't the getter 
methods be enhanced to call the data population methods to do what Rick 
wants? By that I mean something like getList()  containing a List which 
is populated by a call to, say, populateList(). Sort of:


public List getList() {
   List list = populateList();
   return list;
}

The getList would be invoked during the jsp:useBean wouldn't it?

I'm probably missing something obvious here, but this seems so much simpler.

-david-


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Rick Reumann

Craig McClanahan wrote the following on 8/22/2005 3:38 PM:


Grab Shale.  Make your backing bean implement ViewController.  Stick
the list setup logic in the prerender() method.  Smile, knowing that
this technique works not only for the welcome page, but for *any* page
to which you navigate (in Struts Classic terms, this is the kind of
thing that you use a Controller for in Tiles).  :-)

If you wanted to do it the hard way, you could set things up to
register a phase listener, and call your list setup logic in a before
render response event handler ... but that's the part Shale takes
care of for you.


Ok, I'll try this with Shale, although I'm really surprised the 
framework (JSF) doesn't take care of this for you by default? In struts 
it's so simple, I simply forward to an Action that populates my 
employees. I'm still trying to get a handle on all of this and it seems 
like things are done so many different ways that's it's quite confusing. 
Complicating matters of course is every example I'm finding seems to 
deal with more advanced features that I don't care about at this time - 
I don't want the bells and whistles yet, just the meat:).


Making matter worse is that I do want to use Tiles. Bascially what I 
want is something very simple


User goes to

/webapp/index.jsp (or just /webapp - welcome file will be index.jsp)

This ends up bringing the user to a page...

/webapp/employees.jsp that looks like

--
  header (a tile)
-
  |
  |
menu  |
(tile)|  { display a list of employees }
  |  (body tile)
  |


What is the standard way of accomplishing this in JSF? I'm looking at 
Geary's example in Core JSF with Tiles but that doesn't seem to help 
much in this case and I've been looking over the MyFaces tiles example. 
The former deals with Tiles in a more advanced example (nothing in the 
faces config) and the later deals with tiles where no business logic in 
any classes needs to take place.


I guess I'll try all this first without using tiles.


--
Rick

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Rick Reumann

David Haynes wrote the following on 8/22/2005 3:57 PM:


public List getList() {
   List list = populateList();
   return list;
}

The getList would be invoked during the jsp:useBean wouldn't it?

I'm probably missing something obvious here, but this seems so much 
simpler.


I would think that I should be able to do this easily without having to 
use jsp:useBean? Heck, it seems like I'm taking two steps backwards 
now:) Funny how with Struts the goal was to move 'away' from making any 
calls to your business objects from the view.  JSF seems to encourage 
this? Trust me, I don't mind this - as long as it's clean and easy to 
maintain. Sort of funny, though, that if someone proposed this on the 
Struts list (having a JSP make a useBean call in order to get a List in 
scope) people would have a cow.


--
Rick

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread David Haynes

Rick Reumann wrote:


David Haynes wrote the following on 8/22/2005 3:57 PM:


public List getList() {
   List list = populateList();
   return list;
}

The getList would be invoked during the jsp:useBean wouldn't it?

I'm probably missing something obvious here, but this seems so much 
simpler.



I would think that I should be able to do this easily without having 
to use jsp:useBean? Heck, it seems like I'm taking two steps backwards 
now:) Funny how with Struts the goal was to move 'away' from making 
any calls to your business objects from the view.  JSF seems to 
encourage this? Trust me, I don't mind this - as long as it's clean 
and easy to maintain. Sort of funny, though, that if someone proposed 
this on the Struts list (having a JSP make a useBean call in order to 
get a List in scope) people would have a cow.


Hey! Don;'t take what I say a gospel. I'm just fumbling my way through 
like most others...


-david-


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Rick Reumann

David Haynes wrote the following on 8/22/2005 4:19 PM:

I'm just fumbling my way through 
like most others...


I can relate. Trust me you don't want me as your 'JSF running back' 
right now in JSF Fantasy Football. I've been fumbling in all my 
pre-season attempts at carrying the ball:) I think I'm averaging -20 
yards/carry.


--
Rick

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Craig McClanahan
On 8/22/05, David Haynes [EMAIL PROTECTED] wrote:

 
 Sorry to hi-jack this thread a bit, but I am confused. Can't the getter
 methods be enhanced to call the data population methods to do what Rick
 wants? By that I mean something like getList()  containing a List which
 is populated by a call to, say, populateList(). Sort of:
 
 public List getList() {
 List list = populateList();
 return list;
 }
 
 The getList would be invoked during the jsp:useBean wouldn't it?
 
 I'm probably missing something obvious here, but this seems so much simpler.
 

This would work (although you'd probably want to do some sort of
in-request caching so you don't call populateList() more than once),
but I tend to shy away from making getter and setter methods for
properties have side effects like this.  It's much clearer (well, to
me anyway :-) when pulling data from the model is explictly called out
in its own methods.

Craig

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [JSF] using a jsp:forward to get to backing bean method?

2005-08-22 Thread Rick Reumann

Wendy Smoak wrote the following on 8/22/2005 4:28 PM:

Consider that Struts added services on top of Servlets and JSP... and 
now Shale is adding services on top of JSF. 


True. I keep forgetting the separation. I keep thinking JSF is to 
servlets/JSP as Struts is to servlets/JSP but I remember another post 
explaining how that really isn't the case.


--
Rick

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]