Re: Tiles and JSF Wiki entry
Awesome. Thanks Robert. ( By the way the above URL is really http://wiki.apache.org/myfaces/Tiles_and_JSF )On 9/18/05, Robert Taylor [EMAIL PROTECTED] wrote: It was recommended by a few users that a wiki entry be created for myrecent adventures in learning how to use Tiles with MyFaces. See thethread subject [newbie] Forward to launch page if you want all the gory details. You can find the wiki entry here:http://wiki.apache.org/myfaces/Tiles_and_JSF%2eIt's my first wiki entry, so if you find some mistakes or ways to improve it, feel free to jump right in or let me know.Thanks again for all who helped me and I hope this helps others./robert-- Rick
Re: [newbie] Forward to launch page
Robert, I haven't figured out Tiles yet with JSF. I got frustrated trying too many things at once, so I backed out my Tiles stuff and just tried to get a simple app working first. My next step is to learn tiles. I have the feeling using Tiles might really complicate the learning process. On 9/17/05, Robert Taylor [EMAIL PROTECTED] wrote: Wow! I feel like I'm in left field here.Let me back up and tell you what I want to accomplish.I have an existing Struts application which I want to convert to usingJSF. That application uses tiles and prefix mapping. I have the Struts application set up such that when the user invokes /app/launch, theStruts controller is invoked (prefix mapping for Struts servlet is/app/*), looks up the corresponding action mapping,TilesRequestProcessor resolves the tiles definition then builds my page. So far, the examples I have provided on this thread use extesionmapping. This is because I started having so much trouble with prefixmapping, that I thought if I could get my example working usingextension mapping, I could simply change the mapping and I would be okay. So before I waste more bandwidth, I'm going to do some more research,because I obviously don't understand the life cycle.Thanks for all who have helped so far./robertVolker Weber wrote: Hi, as i mentioned before: your has to made the redirect/forward link relative. I just check this out with the redirect in my application. Prefixing the redirect url with a '/' results in a HTTP Status 404 - /faces/overview/intro.jsp ! If you use absolute url you has to add the application path also. If you know the url you has to type in your browser to get your launch page, this is exactly the url to must redirect/forward to! The navigation-rules of your faces-config.xml are not needed for this, just for inner application navigation. Regards Rick Reumann wrote:Well I believe your index page of:jsp:forward page=/launch.faces/Is going to try to find /launch.jsp in the root but you don't have launch there so make it:jsp:forward page=/pages/launch.faces/ and you should be all set.Also this rule:navigation-rule navigation-caseto-view-id/pages/launch.jsp/to-view-id /navigation-case/navigation-ruleI don't think will do anything since you don't have a from-outcome defined, so I'm not sure what the above will ever do. I think you areexpecting the to-view-id to fire based on the forward set up in yourindex, but that's not the case since that forward is going to try to resolve to a jsp (which doesn't exist in your root).-- Rick
Re: [newbie] How to pass a parameter from one page to another
Martin Marinschek wrote the following on 9/17/2005 12:12 PM: Very good entry, the one thing missing IMHO in the end is mentioning setting preserveDataModel to true on your t:dataTable element. With that, you can even omit using the t:saveState tag. Does that only preserve it for the next request? I don't want it preserved in Session. If it acts just like saveState, that would be great. -- Rick
Re: [newbie] Forward to launch page (w/Tiles) [SOLVED]
Yea Robert, PLEASE put your findings in the wiki. An entry on how to get started using Tiles with JSF would be extremely helpful. I'm going to be tapping you for tiles help now:) On 9/17/05, Martin Marinschek [EMAIL PROTECTED] wrote:I think something like this belongs onto the Wiki if you can spare the time! would be great to have this info there ;)regards,Martin
Re: commandLink with action inside Table
Christian Froelich wrote the following on 9/16/2005 5:31 AM: h:column id=columnBrowsTab1 rendered=#{foo.secondBoolean} x:saveState id=listenerObid value=#{listener.obid}/ x:saveState id=fooObid value=#{foo.obid}/ h:commandLink id=TMIL action=#{listener.sort} value=#{foo.obid == 'obid'} rendered=#{foo.obid == 'obid'} / I'm stabbing in the dark here since this is all new to me also. It doesn't look ilke you need to saveState of listener since your rendered is only concerned with foo.obid == 'obid'. Try leaving off the first saveState and just put: x:saveState id=foo value=#{foo}/ Maybe you can have more than one saveState on a page and only the first one is getting called? Also make sure the bean backed by foo is serializable (at least I think it needs to be for saveState to work). -- Rick
Re: [newbie] How to pass a parameter from one page to another
Martin Marinschek wrote the following on 9/16/2005 8:25 AM: A cool MyFaces specific feature is the t:updateActionListener tag - you can set a value onto a backing bean if a command has been executed. I'm very interested in seeing this tag used or some docs on it. I looked under the UpdateActionListenerTag docs http://myfaces.apache.org/javadoc/tomahawk/ and http://myfaces.apache.org/tlddoc/tomahawk/ but didn't find anything. Does one of the MyFaces examples show how it's used? -- Rick
Re: [newbie] Forward to launch page
Robert Taylor wrote the following on 9/15/2005 6:12 PM: Greetings, I'm a current Struts user interested in learning and using MyFaces and JSF. My dev. env. consists of Tomcat 5.5.9, MyFaces 1.0.9, JDK 1.4.2, Win2K. I've configured MyFaces to use Tiles for view-handler. What I want to do is to have my welcome page (index.jsp), forward to a launch page for the application. In Struts, I would simply use a jsp:forward page=/app/launch/. In my struts-config.xml file I has an action mapping for action path=/launch forward=launch.tile/ which forwarded to a tiles configuration which builds the page. I'm trying to do something similar with JSF, but have been unsuccessful. I removed the tiles complexity just to see if it would display a non-tiles .jsp. My wecome page consists of a single line: jsp:forward page=/app/launch/. My faces-context.xml file is as follows: ?xml version=1.0? !DOCTYPE faces-config PUBLIC -//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN http://java.sun.com/dtd/web-facesconfig_1_0.dtd; faces-config navigation-rule from-view-id/launch/from-view-id navigation-case to-view-id/pages/launch.jsp/to-view-id /navigation-case /navigation-rule /faces-config How's it going Robert. Good to see you here:) I'm not totally sure of the interaction/effects of using .faces (assuming you have in you web.xml: servlet-mapping servlet-nameFaces Servlet/servlet-name url-pattern*.faces/url-pattern /servlet-mapping ) but what should work is jsp:forward page=/app/launch.faces/ navigation-rule navigation-case from-outcomeapp/launch/from-outcome to-view-id/pages/launch.jsp/to-view-id /navigation-case /navigation-rule Someone please correct if what I'm doing above is the wrong approach (as I'm using it in the online example I wrote and I want to be doing the correct thing http://www.reumann.net/reumann/jsf/jsf_employees/ )
Re: [newbie] How to pass a parameter from one page to another
Thomas Spiegl wrote the following on 9/16/2005 10:14 AM: If your bean is Serializable use t:saveState value=#{yourBean} / That's not what I'm asking though. I'm asking about how to use the t:updateActionListener tag. I'm thinking the tag would be used inside of a commandLink or commandButton tag and when the action is fired that the link or button represents, it will automatically set and bean properties of the backing bean backing that action? If so, this would be a SUPERBLY nice feature. Currently, for example if you pass in parameters with a commandLink you need to do the following in the resulting action (assuming foo is the f:param): FacesContext context = FacesContext.getCurrentInstance(); Map map = context.getExternalContext().getRequestParameterMap(); String foo = (String) map.get(foo); I'm assuming that possibly t:updateActionListener would avoid this construct and that if you had a property in the Action called foo it would be automagically populated using the tag. This would be very nice - so nice, that I think it should be part of standard JSF. to make yourBean available on next page. regards, Thomas On 9/16/05, *Rick Reumann* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Martin Marinschek wrote the following on 9/16/2005 8:25 AM: A cool MyFaces specific feature is the t:updateActionListener tag - you can set a value onto a backing bean if a command has been executed. I'm very interested in seeing this tag used or some docs on it. I looked under the UpdateActionListenerTag docs http://myfaces.apache.org/javadoc/tomahawk/ and http://myfaces.apache.org/tlddoc/tomahawk/ but didn't find anything. Does one of the MyFaces examples show how it's used? -- Rick -- Rick
Re: [newbie] How to pass a parameter from one page to another
Thomas Spiegl wrote the following on 9/16/2005 11:08 AM: Rick, My answer was related to Esther Leimbeck's question. When using the updateActionListener nested inside a commandLink, the backing bean will automatically be updated. Have a look at the Master-Detail example: http://irian.at/myfaces/masterDetail.jsf http://irian.at/myfaces/masterDetail.jsp.source Awesome! Thanks Thomas! That tag is so cool. This really is the answer I think to all the questions on this list that come up when people are concerned about using request params in command links and then having to pull them out of the faces Context. Instead, this tag should be used imo. Saves lot of time is much cleaner. -- Rick
Re: [newbie] How to display dynamic content from a database
On 9/16/05, Esther Leimbeck [EMAIL PROTECTED] wrote: I would like to write a JSF-application that displays a data-list from a database. The amount of entries in that list, however, differs. My question is: I assume I have to place that data into the backing bean BEFORE the page is rendered. How do I do that? I actually have two use cases: Case 1: Upon its first call, a page has to display such a data list (so somehow I need to be able to place the data from the database into the backing bean BEFORE the page is displayed) Have a backing bean hold on to a Collection (or maybe a bean holding a Collection). You call a method in that backing bean that populates the collection when you click on a link or button. The resulting page you go to then just uses this Collection for the dislay. Case 2: A page is called by another page which passes a "key" to the new page. The new page has to then use that "key" to query the database (Key can be a search criteria or such. It is usually an integer) How can that be done? A couple ways. The cleanest solution seems to be using the updateActionListener tag that Thomas just introduced me to. So for example I have a link in a table that looks like... t:dataTable var=emp t:commandLink action=""> h:outputText value=#{msgs.edit} / t:updateActionListener property=#{employeeAction.employee.id} value=#{emp.id} / /t:commandLink In the backing bean employeeAction there is an employee reference. Clicking on the link above will set the Id of employee in my EmployeeAction's 'prepareForEdit' method. It's very nice.
Re: [newbie] Forward to launch page
Well I believe your index page of: jsp:forward page=/launch.faces/ Is going to try to find /launch.jsp in the root but you don't have launch there so make it: jsp:forward page=/pages/launch.faces/ and you should be all set. Also this rule: navigation-rule navigation-caseto-view-id/pages/launch.jsp/to-view-id /navigation-case/navigation-rule I don't think will do anything since you don't have a from-outcome defined, so I'm not sure what the above will ever do. I think you are expecting the to-view-id to fire based on the forward set up in your index, but that's not the case since that forward is going to try to resolve to a jsp (which doesn't exist in your root).
Re: [newbie] How to pass a parameter from one page to another
On 9/16/05, Martin Marinschek [EMAIL PROTECTED] wrote: If you like it,you might want to document it ;) Created a wiki entry here on it, plus some other techniques. I'm sure I made some mistakes so any corrections welcome. http://wiki.apache.org/myfaces/ExecutingMethodsFromLinkButtonParameters -- Rick
Re: commandLink with action inside Table
Mike Kienenberger wrote the following on 9/15/2005 12:18 PM: Take a look at this thread for both a discussion on the situation and solutions. Note that the earlier part of the thread didn't address the real issue, so I started you somewhere in the middle. http://mail-archives.apache.org/mod_mbox/myfaces-users/200509.mbox/[EMAIL PROTECTED] Rick was going to write a wiki entry on the situation, but I don't think he's done so yet. Basically, you need to preserve the value of rendered to the next request. Using the t:saveState component is one way to do this. Yes, I am going to make a wiki entry this. The reason I didn't reply immediately is that he mentioned he was using session scope for his backing bean. I'm guessing now that both the foo bean and listener bean both aren't in session scope. Christian, I'm guessing that listener is not being preserved so if you preserve listener or listener you should be all set: t:saveState id=listener value=#{listener}/ (just perserving obid of listener should work also: t:saveState id=obid value=#{listener.obid}/) If foo isn't being preserved (I think you said it was in Session scope), you'll need to save that state also. I haven't looked into using t:saveState for more than one object though. -- Rick
Looking at CarSort example.. will it work with ListDataModel?
I currently have a DataTable built from a ListDataModel that takes my List. I want to implement column sorting, so I'm just beginning to look at the Car sort example of MyFaces. Will the sort work on the front end if you use a ListDataModel vs a direct List in your DataTable? -- Rick
t:column width issue, was: Re: Looking at CarSort example.. will it work with ListDataModel?
Mathias Brökelmann wrote the following on 9/13/2005 11:32 AM: Yes it should work. This is odd. I'm using the nightly build of myfaces-all, but when the table resorts it doesn't produce the 'width' attribute on the td: t:column width=280 Before clicking on a column to sort, the table correctly generates a td width=280, after clicking on a column to sort, the width is no longer present in the generated source. Any ideas what could be going wrong? -- Rick
Re: Looking at CarSort example.. will it work with ListDataModel?
Mathias Brökelmann wrote the following on 9/13/2005 11:32 AM: Yes it should work. Things are also getting really screwed up after a sort takes place and then I try to get a handle the row selected by doing... this.employee = (EmployeeVO)getEmployeesListBean().getEmployeesModel().getRowData(); After a sort takes place, I am no longer able to get the correct row that is selected. I am even using two methos now in my EmployeesListBean: public ListDataModel getEmployeesModelSorted() { log.debug(getEmployeesModelSorted); sort(getSort(), isAscending()); return model; } public ListDataModel getEmployeesModel() { log.debug(getEmployeesModelUnsorted); //don't sort here since this method gets called from EmployeeAction return model; } The JSP is using: t:dataTable var=emp value=#{employeesListBean.employeesModelSorted} the sort method, sorts just like it does in the car example, but I also am reinitializing the Model... Collections.sort(employees, comparator); //repopulate DataModel, since we just sorted model = new ListDataModel( employees ); The regular getEmployeesModel() method doesn't call the sort method so I thought that would mean I'd be able to get a handle to the correct row selected by the user, but something isn't working correctly. -- Rick
Re: Looking at CarSort example.. will it work with ListDataModel?
Rick Reumann wrote the following on 9/13/2005 2:57 PM: Mathias Brökelmann wrote the following on 9/13/2005 11:32 AM: Yes it should work. Things are also getting really screwed up after a sort takes place and then I try to get a handle the row selected by doing... this.employee = (EmployeeVO)getEmployeesListBean().getEmployeesModel().getRowData(); Narrowing this down a bit more. I notice the above is always grabbing the 'last row' in the DataModel, regardless of which one is selected. So after a sort and you click on the edit button on the row, it will bring back the last row regardless of which one is clicked on from... h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ prepareForEdit() has the this.employee = (EmployeeVO)getEmployeesListBean().getEmployeesModel().getRowData(); After a sort takes place, I am no longer able to get the correct row that is selected. I am even using two methos now in my EmployeesListBean: public ListDataModel getEmployeesModelSorted() { log.debug(getEmployeesModelSorted); sort(getSort(), isAscending()); return model; } public ListDataModel getEmployeesModel() { log.debug(getEmployeesModelUnsorted); //don't sort here since this method gets called from EmployeeAction return model; } The JSP is using: t:dataTable var=emp value=#{employeesListBean.employeesModelSorted} the sort method, sorts just like it does in the car example, but I also am reinitializing the Model... Collections.sort(employees, comparator); //repopulate DataModel, since we just sorted model = new ListDataModel( employees ); The regular getEmployeesModel() method doesn't call the sort method so I thought that would mean I'd be able to get a handle to the correct row selected by the user, but something isn't working correctly. -- Rick
Re: Looking at CarSort example.. will it work with ListDataModel?
Removing preserveState='true' from the DataTable seemed to fix the problem. Rick Reumann wrote the following on 9/13/2005 3:08 PM: Rick Reumann wrote the following on 9/13/2005 2:57 PM: Mathias Brökelmann wrote the following on 9/13/2005 11:32 AM: Yes it should work. Things are also getting really screwed up after a sort takes place and then I try to get a handle the row selected by doing... this.employee = (EmployeeVO)getEmployeesListBean().getEmployeesModel().getRowData(); Narrowing this down a bit more. I notice the above is always grabbing the 'last row' in the DataModel, regardless of which one is selected. So after a sort and you click on the edit button on the row, it will bring back the last row regardless of which one is clicked on from... h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ prepareForEdit() has the this.employee = (EmployeeVO)getEmployeesListBean().getEmployeesModel().getRowData(); After a sort takes place, I am no longer able to get the correct row that is selected. I am even using two methos now in my EmployeesListBean: public ListDataModel getEmployeesModelSorted() { log.debug(getEmployeesModelSorted); sort(getSort(), isAscending()); return model; } public ListDataModel getEmployeesModel() { log.debug(getEmployeesModelUnsorted); //don't sort here since this method gets called from EmployeeAction return model; } The JSP is using: t:dataTable var=emp value=#{employeesListBean.employeesModelSorted} the sort method, sorts just like it does in the car example, but I also am reinitializing the Model... Collections.sort(employees, comparator); //repopulate DataModel, since we just sorted model = new ListDataModel( employees ); The regular getEmployeesModel() method doesn't call the sort method so I thought that would mean I'd be able to get a handle to the correct row selected by the user, but something isn't working correctly. -- Rick
Re: Looking at CarSort example.. will it work with ListDataModel?
Rick Reumann wrote the following on 9/13/2005 3:47 PM: Removing preserveState='true' from the DataTable seemed to fix the problem. However I'm still having the problem where t:column width=280 is not being preserved after the resort (attribute width not shoing up in source code) -- Rick
Possible Bug in nightly build - t:column width attribute?
Not sure if this is a bug or something odd with my code.. Using the nightly myfaces-all build from 9/11, if I have: t:column width=300 and t:column style=width:300px; Both will render correctly on the first display of the page. However, I've impelemented some column sorting, similar to the MyFaces Car sort example, and when the page reloads after clicking on a column heading, the style attribute is generated just fine, but the width attribute is not generated at all. Seems odd that the style attribute works but the width does not. This seems like a bug, doesn't it? -- Rick
How to set the width of just one column in dataTable
Say I have 10 columns in a table. I need to set the width of just the 5 column. It seems like I'd have to make up classes for each column (or at least the first 4) just so that I can define a style for the 5th column to give it a width? Shouldn't h:column except a style attribute so I can manually set a particular column's style? According to the spec for columnClasses on dataTable: Comma-delimited list of CSS style classes that will be applied to the columns of this table. A space separated list of classes may also be specified for any individual column. If the number of elements in this list is less than the number of columns specified in the columns attribute, no class attribute is output for each column greater than the number of elements in the list. If the number of elements in the list is greater than the number of columns specified in the columns attribute, the elements at the posisiton in the list after the value of the columns attribute are ignored. -- Rick
Re: How to set the width of just one column in dataTable
Mathias Brökelmann wrote the following on 9/12/2005 4:47 PM: Use t:datatable and a for the 5th column t:column width=xyz You have to use the latest nightly to work with t:column. You can also define style or styleClass for t:column Awesome Mathias! Exactly what I was hoping to be able to do. Be great when this make into the release build as well. -- Rick
How to setup and display non-error messages
I'm looking in the section of Core JSF on messages but I don't see how to create a typical Your update of John Doe was Successful type of message to be used on a JSP. How do you accomplish this with JSF/MyFaces? It seems like h:message and h:messages is really only geard for error type messages, but what about standard success type message? Actually, I don't even see how to set up error messages. For example if I make a call to some backend procedure and want to display a failure message, how do I do this? TIA, -- Rick
Re: How to setup and display non-error messages
Mike, could you explain more the concept of the optionalRelatedComponentReference - what would be an example of its usage? Since I'm new, I haven't run across using the ComponentReference.getClientId construct yet. (note: gmail might be adding my gmail address as the reply-to address instead of the list, and I have no idea why - so if someone replies to this make sure it has the list address. Anyone else besides Mike and I noticing gmail doing this?) On 9/9/05, Mike Kienenberger [EMAIL PROTECTED] wrote: h:messages globalOnly=true showDetail=true/ h:message for=optionalRelatedComponentId showDetail=true/ FacesContext facesContext = FacesContext.getCurrentInstance(); facesContext.addMessage(optionalRelatedComponentReference.getClientId(facesContext), new FacesMessage(FacesMessage.SEVERITY_WHATEVER, messageSummary, messageDetail)); optionalRelatedComponentReference.getClientId(facesContext) can be replaced with null if you want a global message. On 9/9/05, Rick Reumann [EMAIL PROTECTED] wrote: I'm looking in the section of Core JSF on messages but I don't see how to create a typical Your update of John Doe was Successful type of message to be used on a JSP. How do you accomplish this with JSF/MyFaces? It seems like h:message and h:messages is really only geard for error type messages, but what about standard success type message? Actually, I don't even see how to set up error messages. For example if I make a call to some backend procedure and want to display a failure message, how do I do this? TIA, -- Rick -- Rick
Re: render based on user and his/her roles
Why don't you have your backingBean also have a handle to some kind of Session based object that has the userRoles etc. Then when you call backingBean.render() , render could then just check what it needs from that bean? On 9/9/05, Dave [EMAIL PROTECTED] wrote: Hello, In a page, I need to render a UICompont based on user and his/her roles. For example, h:commandLink value=Edit action=Edit rendered=#{backingBean.render} / In the backingBean boolean render() method, user/roles can be obtained from request. But it needs to know the command id or name to figure out(based on authorization policy) if the user is allowed to perform the action. If not, the commandLink should not be rendered. The backing bean method is not allowed to pass parameters. It is not ideal for each command to have one backing bean method such as boolean renderEdit(). What is the way to accomplish this? Thanks for ideas! Dave __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- Rick
[OT] testing gmail reply-to. Ignore.
Just a test to see how gmail is setting up the reply-to address. Please ignore. -- Rick
understanding the impact of 'rendered'
I am trying to use the rendered attribute to decide whether to display an insert button or a save button (in reality they will end up both saying just save, but the action associated with them is different). Here is how I have the buttons set up: h:commandButton type=submit id=insert value=INSERT THIS EMPLOYEE action=#{employeeAction.insertAction} rendered=#{not employeeAction.editMode}/ h:commandButton type=submit id=update value=#{msgs.save} action=#{employeeAction.updateAction} rendered=#{employeeAction.editMode}/ The buttons render exactly as expected - Insert button shows up when it's an insert being done, save being shown when it's an update. The poblem is I have no idea why the insertAction method is not firing when I use the rendered attribute! If I remove rendered so that I have... h:commandButton type=submit id=insert value=INSERT THIS EMPLOYEE action=#{employeeAction.insertAction} / inertAction will fire just fine. What has me more stumped is that the updateAction *does* work fine with the rendered attribute. What is causing the insertAction to be messed up when I use 'rendered' ? -- Rick
Re: understanding the impact of 'rendered'
CONNER, BRENDAN (SBCSI) wrote the following on 9/9/2005 3:28 PM: It would be interesting to see whether reversing the order of your buttons results in the reverse outcome. In other words, if you specify: then it would be interesting to see if that makes the update action inoperable. If that is the case, then something is being rendered even for the unrendered button that is somehow messing up how the page gets submitted for the rendered button. It's just so weird. I pasted the form I have here: http://rafb.net/paste/results/vYp8Zi19.html I removed all buttons so that I only have this one: h:commandButton type=submit id=insert value=INSERT THIS EMPLOYEE action=#{employeeAction.insertAction} rendered=#{!employeeAction.editMode}/ Click on above button, page just reloads. insertAction not reached. If I remove the rendered: h:commandButton type=submit id=insert value=INSERT THIS EMPLOYEE action=#{employeeAction.insertAction}/ Click on above button, insertAction *is* reached. I'm baffled. -- Rick
Re: understanding the impact of 'rendered'
CONNER, BRENDAN (SBCSI) wrote the following on 9/9/2005 4:00 PM: Can you take out the globalOnly attribute in your h:messages tag in your JSP? Maybe it's getting some error which is causing the form to be redisplayed. I commented that out and still not getting insertAction to be hit. Doesn't 'rendered' just decide whether or not to display the component? I can't see why using the rendered attribute would cause the action event to not fire when the button is clicked? Unless maybe like Mike was possibly eluding to - that when the form submits it tries to see if the rendered value is still true (and possibly in this case it isn't?). If that's the case I don't really understand the logic behind implementing it that way. But I'm not sure that's the problem though. - Brendan -Original Message- From: Rick Reumann [mailto:[EMAIL PROTECTED] Sent: Friday, September 09, 2005 2:56 PM To: MyFaces Discussion Subject: Re: understanding the impact of 'rendered' CONNER, BRENDAN (SBCSI) wrote the following on 9/9/2005 3:28 PM: It would be interesting to see whether reversing the order of your buttons results in the reverse outcome. In other words, if you specify: then it would be interesting to see if that makes the update action inoperable. If that is the case, then something is being rendered even for the unrendered button that is somehow messing up how the page gets submitted for the rendered button. It's just so weird. I pasted the form I have here: http://rafb.net/paste/results/vYp8Zi19.html I removed all buttons so that I only have this one: h:commandButton type=submit id=insert value=INSERT THIS EMPLOYEE action=#{employeeAction.insertAction} rendered=#{!employeeAction.editMode}/ Click on above button, page just reloads. insertAction not reached. If I remove the rendered: h:commandButton type=submit id=insert value=INSERT THIS EMPLOYEE action=#{employeeAction.insertAction}/ Click on above button, insertAction *is* reached. I'm baffled. -- Rick
Re: understanding the impact of 'rendered'
Mike Kienenberger wrote the following on 9/9/2005 4:26 PM: Yes, that's exactly what I'm saying. At the start of every phase for every component, the result of isRendered() is computed. If it's false, nothing happens during that phase. Ok thanks, I'll have to play around with that and figure out then how I make sure rendered=#{!employeeAction.editMode} remains true. Personally I don't find that behavior that diserable but I'm sure there is a reason for it. When you see rendered, I would think one is simply going to think Here's the condition to decide whether this component is visible or not, but obviously there is more to it than that. -- Rick
Re: understanding the impact of 'rendered'
CONNER, BRENDAN (SBCSI) wrote the following on 9/9/2005 5:03 PM: I think the key here is that the rendered condition is checked *after* the button has been clicked, and, if you haven't saved the state of the bean that contains the boolean value, it will get re-initialized with null values (and false values) when it is referenced and the decision is made to create the action button component. Yes. Agreed that is what is happening. I'm curious, however, to learn *why* this is the behavior (checking the rendered condition after the click) for actions on buttons. The recommended way to decide whether to display a button or not seems to be to use the 'rendered' condition, yet now you also have to remember to save the state. I have a serious question, if you didn't have MyFaces saveState how in the world would one deal with this? I wouldn't want to be forced to give my whole backing bean session scope just to be able to hide or show a button on a form based on some condition. I'll have to add this to the wiki. I'm sure someone else is going to get burned on this 'rendered' behavior. Thanks for all your help (and patience:) Mike and Brendan. You've kept me somewhat sane throughout this learning process. -- Rick
Re: Best way to use object properties from a List to create Select Items?
On 9/8/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: BTW, the List (or, more generally, the Collection) is assumed to contain SelectItem instances. Ok, I guess I'll have to make methods to covert my Collections to new Collections/Maps or probably just convert them to a SelectItem[] array. This is one area that I believe will/should need to be addressed moving forward. Often times Collections are brought back from backend methods that are already in place and the developers are forced to use. It's now pretty a much a pain to have to call dackend.getAnimals(), backend.getEmployees(), backend.getCollectionOfFooBars(), only to have to then convert that Collection into something that can be used nicely by the front end for select options. When I finally get up to speed with this stuff, I'll see if I can help contribute a tag to help.
I'm also having trouble with commandLink within dataTable
My commandLink will work when it's outside of the dataTable, but when it's within the dataTable it is not working (it just refreshes the same page, minus the model data, and doesn't even hit the action method in the backing bean). I have... x:saveState id=employeesListBean value=#{employeesListBean}/ f:view h:form h:dataTable var=emp value=#{employeesListBean.employeesModel} //stuff h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ /h:dataTable /h:form /f:form If I also add h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ outside of the dataTable the prepareForEdit method is hit. What do I need to do to get my commandLink working from within the dataTable without using a Session scoped bean or preserveDataModel ? I thought the x:saveState would do the trick? -- Rick
Re: I'm also having trouble with commandLink within dataTable
It's inside a column: h:column h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ nbsp;nbsp; h:commandLink value=#{msgs.delete} action=#{employeeAction.deleteAction}/ /h:column On 9/7/05, Mike Kienenberger [EMAIL PROTECTED] wrote: It's probably the case, but is your h:commandLink is inside a column or facet? I don't think it can be a direct child of dataTable. On 9/7/05, Rick Reumann [EMAIL PROTECTED] wrote: My commandLink will work when it's outside of the dataTable, but when it's within the dataTable it is not working (it just refreshes the same page, minus the model data, and doesn't even hit the action method in the backing bean). I have... x:saveState id=employeesListBean value=#{employeesListBean}/ f:view h:form h:dataTable var=emp value=#{employeesListBean.employeesModel} //stuff h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ /h:dataTable /h:form /f:form If I also add h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ outside of the dataTable the prepareForEdit method is hit. What do I need to do to get my commandLink working from within the dataTable without using a Session scoped bean or preserveDataModel ? I thought the x:saveState would do the trick? -- Rick -- Rick
Re: I'm also having trouble with commandLink within dataTable
By the way, when I give my emloyeeListBean session scope things work fine, so I'm guessing maybe it's the way I'm using x:saveState? x:saveState id=employeesListBean value=#{employeesListBean}/ Does it matter where that x:saveState is located? I have it directly beneath my imports... %@ taglib uri=http://java.sun.com/jsf/core; prefix=f % %@ taglib uri=http://java.sun.com/jsf/html; prefix=h % %@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c % %@ taglib uri=http://myfaces.apache.org/extensions; prefix=x% x:saveState id=employeesListBean value=#{employeesListBean}/ On 9/7/05, Rick Reumann [EMAIL PROTECTED] wrote: It's inside a column: h:column h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ nbsp;nbsp; h:commandLink value=#{msgs.delete} action=#{employeeAction.deleteAction}/ /h:column On 9/7/05, Mike Kienenberger [EMAIL PROTECTED] wrote: It's probably the case, but is your h:commandLink is inside a column or facet? I don't think it can be a direct child of dataTable. On 9/7/05, Rick Reumann [EMAIL PROTECTED] wrote: My commandLink will work when it's outside of the dataTable, but when it's within the dataTable it is not working (it just refreshes the same page, minus the model data, and doesn't even hit the action method in the backing bean). I have... x:saveState id=employeesListBean value=#{employeesListBean}/ f:view h:form h:dataTable var=emp value=#{employeesListBean.employeesModel} //stuff h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ /h:dataTable /h:form /f:form If I also add h:commandLink value=#{msgs.edit} action=#{employeeAction.prepareForEdit}/ outside of the dataTable the prepareForEdit method is hit. What do I need to do to get my commandLink working from within the dataTable without using a Session scoped bean or preserveDataModel ? I thought the x:saveState would do the trick? -- Rick -- Rick -- Rick
Error message stating something other than Value..
At one point when I first looked at MyFaces I remember seeing a way to provide an arg so that a required message wouldn't read: name:Value is required. Instead I want to see Name is required Instead of age: Specified value is not a valid number. I'd like to see... Age must be a valid number Does MyFaces have a way to provides this? I couldnt' find anything here http://wiki.apache.org/myfaces/MyFacesComponents but might just be overlooking it. Thanks -- Rick
MyFaces equivalent of using JSTL 'if' and choose/when within JSF compoents?
If I'm using a DataTable or any of the other JSF/MyFaces components that iterate over a collection, how do I do custom logic based on info in some other backing bean (for example a backinBean in session scope)? I'm looking for what gives me the nice c:if c:choose/when logic from within JSF components? Thanks, -- Rick
Re: looking for a little crud sample
Interesting, notice how the approach in the tutorial uses commandLink with the parameters being passed in the link. It makes a lot of sense to me to do it this way, but it seems that JSF doesn't really encourage the applications to be designed this way. Notice how you have to do this kind of stuff... /* * Get the session map of the external context */ Map session = FacesContext.getCurrentInstance().getExternalContext().getSessionMap(); /* * Find the UIParameter component by expression */ UIParameter component = (UIParameter) event.getComponent().findComponent(deleteId); On 9/2/05, Rick Reumann [EMAIL PROTECTED] wrote: Thanks! I look foward to checking this out. On 9/2/05, hicham abassi [EMAIL PROTECTED] wrote: There is what i need : http://www.laliluna.de/first-java-server-faces-tutorial.html For others who need to begin with crud app ;) 2005/9/2, hicham abassi [EMAIL PROTECTED]: Hello, I have problems to design a little crud into jsf. I don't know how to pass from listPage to editPage. Can someone explain the best way to pass id from a datatable to another page for editing, or give me url for a little crud. Thanks. -- hicham ABASSI [EMAIL PROTECTED] -- Rick -- Rick
Re: saveState confusion/question
On 8/31/05, Mike Kienenberger [EMAIL PROTECTED] wrote: How's it breaking? The little info that you've provided seems fine. What's not working is when I get to the 'saveAction' method of my backingBean the 'id' of the Employee object in my backingBean (EmployeeAction) is null. I would think that if I did saveState on the whole EmployeeAction class on the JSP that the id would be there in the same Employee object that is able to output the id fine in a hidden field. However, you might find it more efficient to do this since you're doing the same thing with an hidden field. x:saveState id=employee value=#{employeeAction.employee.id}/ But what if I potentially wanted to prreserve a bunch of properties, not just id? Wouldn't it make sense to saveState on the whole backingBean? -- Rick
Re: more on architecture really confused on something (shocker:)
On 9/1/05, Zhong Li [EMAIL PROTECTED] wrote: Back to the topic, the key thing is if you want use JSF, you have to keep database operation far from JSF beans. I agree totally, but this doesn't help much with this question too much. I'm using a ListDataModel just to display the stuff in the the table since everyone seemed to agree that using DataModel and getting out the selected row is better than my initial plan to simply pass the id/primary key from a commandLink on the row you want to click on. Zhong, I'm confused what you are stating, do you not use the DataModel approach? How do you get from your master list of items to the edit detail page?
Thanks and a best practice question in regard to set up of backing bean Actions
Thanks everyone for your help with the crud demo app I've been working with. (Special thanks to Brendan for his fine Car example code that he posted in another thread). I want to start out on the right foot doing things in a 'correct' way before I get into some bad practices. Currently, I have a list of employees in a table you click on the employee and a backing bean method gets the correct row, grabs the id, gets the true larger Employee object back, then forwards to an Employee form where you can edit the employee info. What I'm debating about his how to best set up the backing bean that supports the 'save' of this form. Currently it's part of an EmployeeAction object and the pertinent code looks like: EmployeeAction.java -- private EmployeeVO employee = new EmployeeVO(); private EmployeesListBean empListBean; public EmployeesListBean getEmployeesListBean() { return empListBean; } public void setEmployeesListBean(EmployeesListBean empListBean) { this.empListBean = empListBean; } public EmployeeVO getEmployee() { return employee; } public void setEmployee(EmployeeVO employee) { this.employee = employee; } public String prepareForEdit() { log.debug(prepareForEdit); this.employee = (EmployeeVO)getEmployeesListBean().getEmployeesModel().getRowData(); //get Employee from backend this.employee = EmployeeService.getEmployee( employee.getId() ); log.debug(returned employee = +employee ); return success; } public String saveAction() { //need way to tell update vs insert ? log.debug(In saveAction ); EmployeeService.updateEmployee(employee); return success; } The prepareForEdit method is called from a link next to the name of each employee on the employees.jsp. After clicking the link the success result will navigate you to emloyeeForm.jsp... The part I'm not so sure about is the setup of the EmployeeAction.. I'm having to initialize EmployeeVO employee = new EmployeeVO(); because if I don't have this, I'll end up with conversion errors since the employee is null when the form submits. Is it better to not create this new instance and maybe use saveState on the form instead? Also on the form I'm doing... h:inputText value=#{employeeAction.employee.name}/ I like the above since it saves me from having to add extra set/gets in my EmployeeAction class to deal with the EmployeeVO nested inside of EmployeeAction.However maybe there are some major drawbacks to doing it that way I've implemented it? Thanks for any comments.
Re: url query string parameters as input to JSF action - not possible??
On 8/30/05, Craig McClanahan [EMAIL PROTECTED] wrote: Why, out of curiousity, do you insist on getting your hands dirty with low level HTTP protocol details like dynamically constructing URL patterns? Why, out of curiousity, do you insist on using GET queries (and thereby throw away nearly the entire JSF lifecycle)? For the record it was Mirek who was proposing that, I'm too new to claim that is what needs to be done. I only concern myself with it because I haven't received a reply on how to deal with this question that I asked a couple of times: I'm still a bit confused on how you deal with links that go to backing bean methods for standard links/buttons. As an example, imagine the header on a page... John Doe[edit user] [logs for user] [user summary] [look up company] 1455 some address[edit address] Somewhere, state, 12456 The example above is a bit exaggerated, but the point is the links(or even buttons) would have to access methods in all different kinds of backing beans. I'm curious how to handle the above with JSF? I'm not trying to be difficult and I'm working dilligently at trying to grasp the concepts, but most of the examples do not address these common issues. You see links on 99.999% of the sites out there - from products you click on, to going to other sections of web sites. I don't think I'm that off base to expect the issue to be addressed a bit - maybe the wiki addresses it, and I missed it? I'm sure I'm missing a simple basic JSF concepts, but I know I'm not the only one that is confused on the issue. It's not that I or probably the others want to use get parameters - we are probably just too ignorant to know of the correct JSF way to do it. I think all we are doing is asking for how to best handle the situation with JSF, not that we truly want to force a square peg into a round hole. Let the application deal with application level things like components (hidden or not as need be), not implementation details. Like any other technology, JSF will be intuitive if you use it the way it's intended -- and it won't be if you don't. snip Isn't more intuitive semantically meaningless, if we all can't even agree on what intuitive means? :-) Fair enough. I should have qualified. One of the problems I'm realizing quite quickly with JSF is that it really tries to remove the user from having to deal with the whole servlet model and I understand how that could be a great thing. By intuitive I should have clarified that I meant in regard to the frame-of-reference coming from standard servlet/JSFprogramming. With Struts, once you realize that an Action class is really just a Servlet, you are back in the realm of dealing with Request/Session etc. With Struts you also seem to be able to ease into the process more gradually. Other than using the struts html:form tag, you can skip using most tags if you wanted. You could just standard html input tags. As you get more comfortable with the framework you can add more and more features. With Struts, viewing the html source generated also is pretty easy to see if things 'look as you'd expect.' With JSF, looking at the generated source code doesn't seem to help me very much. I'm all for learning JSF though. I'm by no means saying that Struts is better, or JSF is better, or .NET is better. I'm going to plug away to learn this technology. -- Rick
Concerning DataModel usage plus overhead?
I haven't really used the DataModel class yet, but as described by Brendan in another thread, I have a couple of questions about the concepts behind it... First a simple example... Want to display on a page a list of employees. User should be able to click on employee and brought to an edit page to edit the employee. My question in a previous thread was how to best accomplish this. I figured a simple link passing in an ID would make the most sense, but it seems like there was recommendations to use a dataModel. But say my initial ist was... Fred John Billy Questions: 1) I want to click on one of those names and edit the user. This initial collection of employees shouldn't contain the full employee info - its just name and ID. It's way too much overhead to pull back the full employee information at this stage, so all I have as a name and an ID. 2) Why would I want to really save the state of this tableData in this case using t:saveState since I really don't care about this list anymore once the name is clicked. I'm going to be brought to a totally new editEmployee screen and no longer need this collection around. When I want the updated list I should get it from the backend again. Please someone help me understand how to best accomplish what I want to do. It seems like such an easy concept but yet I haven't seen a good explanation or an example (granted I don't have the O'Reilly book, from what seems to be described I'm not certain that example will be what I want either). Thanks so much. -- Rick
Re: url query string parameters as input to JSF action - not possible??
On 8/28/05, Sverker Abrahamsson [EMAIL PROTECTED] wrote: Hi I'm new to JSF so this may be a stupid question but I've been reading a lot of tutorials and parts of the spec and come to the conclusion that JSF only support forms with method=post. The only motivation for that I've seen is that its unpure to let a HTTP GET request change server state. Strictly follwing that means however that it's not possible to make url's that uses query string to send data directly into an JSF action, something which is very common today. I.e. look at the JCP site which uses url's like this: http://www.jcp.org/en/jsr/detail?id=252(which leads to JSR 252 which is forJSF 1.2). I guess maybe I'm running into the same question. I'll repost my question which I think is related to the above: I'm still a bit confused on how you deal with links that go to backing bean methods for standard links/buttons. As an example, imagine the header on a page... John Doe [edit user] [logs for user] [user summary] [look up company] 1455 some address [edit address] Somewhere, state, 12456 The example above is a bit exaggerated, but the point is the links would have to access methods in all different kinds of backing beans. If I use commandLink for those links and provide f:param with the appropriate vars, will the backing bean called automatically be populated with those vars (assuming the backing bean has the same matching member variables)? ( Similar to the same way in Struts calling an action from a link with get params attached will populate the backing ActionForm?) or do I need to manually pull these params from the request? Sounds like from what you are stating Sverker that JSF doesn't support the above very well?
Re: url query string parameters as input to JSF action - not possible??
On 8/29/05, Craig McClanahan [EMAIL PROTECTED] wrote: That is indeed a GET request.You can fire a GET request at a JSPpage just fine (including query parameters) ... the thing you give upis state restoration, since your request won't include any stateinformation. But what's the most efficient way to handle this in a JSF backing bean? In other words are you forced to have to do... FacesContext context = FacesContext.getCurrentInstance(); Map reqParams = context.getExternalContext().getRequestParameterMap(); String fooBar = (String)reqParams.get(fooBar); Isn't there a way to make sure the property of my backingBean, in this case fooBar, is populated automatically after clicking on a link that is to handle this Request where fooBar is passed as a parameter of the URL? (In a similar way an ActionForm property is set that backs an Action in Struts?) -- Rick
Re: Concerning DataModel usage plus overhead?
On 8/29/05, Kevin Galligan [EMAIL PROTECTED] wrote: If you use the standard dataTable, you have tokeep your values in session between the time you show the list and whenthey click on the value.If you get the values from the db each time,you open the possibility that the index will have changed, and the selected value will be incorrect.If you keep the values in session,its keeping a lot of data around, and you need to explicitly code a refresh. To me the above is just really goofy. Unless, there are security constraints to me it makes sense to get the item you want back based on some key. Maybe for example you are looking at a list of care models on a page, then you want to see the details of the car. It makes most sense to me to click on the car model passing the id of the model you want, you look up the model and you pass it back. When you need the list of cars back, get a fresh set from the backend. If you need caching, cache at the persistence layer. I don't see the advantage of saving the state of a DataModel, but I'm new to all of this, so maybe I'll see the light at some point. -- Rick
Re: Concerning DataModel usage plus overhead?
On 8/29/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: Yes, you could do your own parameter passing. It's just that JSF offers the DataModel abstraction such that, whenthe userclicks on your link, your program just has to askDataModel for rowIndex to locate the row that was selected. It's designed to simplify your coding. Where should I look for a good of this? Also does it work when you need access to the DataModel from a different backing bean that created the DataModel? For example... h:dataTable var=emp value=#{employees.employees} !-- employees is a backing bean that will generate a DataModel of 'employees' -- Now I want a link in on row that will call employee.edit that will go to Employee.java backing bean and enter the 'edit' method where I can pull out the 'id' that is is found in the bean for the current row of my DataModel. How do I get a handle to this DataModel from a totally different backing bean then the one that created the DataModel? thanks for the help -- Rick
using browser back button with MyFaces examples creates problems..
Example... Load up exmaples http://localhost:8080/myfaces-examples/home.jsf , click on examples -- components -- Master Detail example. click Austria use browser back button Select another menu option like Selectboxes use browser back button Click on Master Detail example --- result ugly error:(-- Rick
Re: Concerning DataModel usage plus overhead?
On 8/29/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: You set up employee to have a managed reference toemployees. Then, once control reaches Employee.edit(),its reference to employees will have been set up already by JSF. But employee has its managed bean reference to employee (EmployeeAction.java). The edit is a method in EmployeeAction.java not in EmployeesAction.java (EmployeesAction is the one that generated the initial DataModel).. Are you saying 'employee' can have a managed reference to both EmployeesAction AND EmployeeAction? I didn't know you could have a single reference with more than one backing bean associate to it? -- Rick
Re: Concerning DataModel usage plus overhead?
On 8/29/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: I probably just got confused by your naming convention. Can you repeat your question with clearer names? Sure. Let me change the names and concepts.. First page you come to is a list of cars on cars.jsp. Cars is populated as DataModel from CarsListAction.java There is a managed bean reference for the name cars to CarsListAction.java. CarsListAction has a method getCars which returns this DataModel. On cars.jsp you have... h:dataTable var=car value=#{carsListAction.cars} Another managed bean: CarAction.java has CRUD methods. In this case getCar which is supposed to get a Car back from the backend based on 'carID. I want to be able to click on car from the list on cars.jsp and hit the getCar' method in my CarAction.java bean and forward to a carForm.jsp that lets me edit the car. If I use a DataModel with this I'm assuming I'll need to get a handle to the DataModel from my CarAction.java... but the DataModel was set up in CarsListAction.
Re: Concerning DataModel usage plus overhead?
Actually, the MyFaces master/detail example source code is shedding some light on some things. Rather than me waste more of your valuable time, let me fart around with that code and see if I can tweak mine to use a similar concept. Thanks for your help and patience so far. On 8/29/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: Can you send a snippet of your faces-config.xml showing your managed bean definitions and your navigations, just to make sure I have the picture right? - Brendan -Original Message- From: Rick Reumann [mailto:[EMAIL PROTECTED] Sent: Monday, August 29, 2005 3:24 PM To: MyFaces Discussion Subject: Re: Concerning DataModel usage plus overhead? On 8/29/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: I probably just got confused by your naming convention. Can you repeat your question with clearer names? Sure. Let me change the names and concepts.. First page you come to is a list of cars on cars.jsp. Cars is populated as DataModel from CarsListAction.java There is a managed bean reference for the name cars to CarsListAction.java. CarsListAction has a method getCars which returns this DataModel. On cars.jsp you have... h:dataTable var=car value=#{carsListAction.cars} Another managed bean: CarAction.java has CRUD methods. In this case getCar which is supposed to get a Car back from the backend based on 'carID. I want to be able to click on car from the list on cars.jsp and hit the getCar' method in my CarAction.java bean and forward to a carForm.jsp that lets me edit the car. If I use a DataModel with this I'm assuming I'll need to get a handle to the DataModel from my CarAction.java... but the DataModel was set up in CarsListAction. -- Rick
Re: Concerning DataModel usage plus overhead?
Thanks Brendan! This below looks wonderful. At home now and no time to try it, but will tomorrow from work. By the way, does the O'Reilly book present something like the below? This is the exact kind of example that I think would be very useful to see in a mini-demo-app. On 8/29/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: Sounds good. Judging from what I understand about your e-mail, I'd define something like: managed-bean managed-bean-namecarListBean/managed-bean-name managed-bean-classcom.mycompany.CarListBean/managed-bean-class managed-bean-scoperequest/managed-bean-scope /managed-bean managed-bean managed-bean-namecarAction/managed-bean-name managed-bean-classcom.mycompany.CarAction/managed-bean-class managed-bean-scoperequest/managed-bean-scope managed-property property-namecarListBean/property-name value#{carListBean}/value /managed-property /managed-bean (I'm calling your data bean carListBean, rather than carListAction, just for my own clarity.) Then, as you point out, you'd have a dataTable entry like h:dataTable value=#{carListBean.carModel} var=car h:column h:commandLink action={carAction.getCar} ... h:commandLink h:column ... /h:dataTable Then, in your getCar() method, you'd have something like: public String getCar() { Car selectedCar = (Car) getCarListBean().getCarModel().getRowData(); ... } Hope that helps. - Brendan -Original Message- From: Rick Reumann [mailto:[EMAIL PROTECTED] Sent: Monday, August 29, 2005 4:02 PM To: MyFaces Discussion Subject: Re: Concerning DataModel usage plus overhead? Actually, the MyFaces master/detail example source code is shedding some light on some things. Rather than me waste more of your valuable time, let me fart around with that code and see if I can tweak mine to use a similar concept. Thanks for your help and patience so far. On 8/29/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: Can you send a snippet of your faces-config.xml showing your managed bean definitions and your navigations, just to make sure I have the picture right? - Brendan -Original Message- From: Rick Reumann [mailto:[EMAIL PROTECTED] Sent: Monday, August 29, 2005 3:24 PM To: MyFaces Discussion Subject: Re: Concerning DataModel usage plus overhead? On 8/29/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: I probably just got confused by your naming convention. Can you repeat your question with clearer names? Sure. Let me change the names and concepts.. First page you come to is a list of cars on cars.jsp. Cars is populated as DataModel from CarsListAction.java There is a managed bean reference for the name cars to CarsListAction.java. CarsListAction has a method getCars which returns this DataModel. On cars.jsp you have... h:dataTable var=car value=#{carsListAction.cars} Another managed bean: CarAction.java has CRUD methods. In this case getCar which is supposed to get a Car back from the backend based on 'carID. I want to be able to click on car from the list on cars.jsp and hit the getCar' method in my CarAction.java bean and forward to a carForm.jsp that lets me edit the car. If I use a DataModel with this I'm assuming I'll need to get a handle to the DataModel from my CarAction.java... but the DataModel was set up in CarsListAction. -- Rick -- Rick
Re: Dealing with links/buttons to fire off an action? confusion on how to set this up
Thanks Brendan, the description of using t:saveState sounds great. I look forward to trying it out shortly. I'm still a bit confused on how you deal with links that go to backing bean methods for standard links/buttons. As an example, imagine the header on a page [..]=links... John Doe [edit user] [logs for user] [user summary] [look up company] 1455 some address [edit address] Somewhere, state, 12456 The example above is a bit exaggerated, but the point is the links would have to access methods in all different kinds of backing beans. If I use commandLink for those links and provide f:param with the appropriate vars, will the backing bean called automatically be populated with those vars (assuming the backing bean has the same matching member variables)? ( Similar to the same way in Struts calling an action from a link with get params attached will populate the backing ActionForm?) or do I need to manually pull these params from the request? Thanks for all your help.On 8/26/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: t:saveState is trivially simple to use, but it's a Godsend. Wherever you want the state of a bean to be maintained across requests, just declare the bean with request scope andput a t:saveSave value=#{myBean} on the pages that use it. The bean's state will be maintained until control reaches a page that doesn't have a t:saveState declared for it, at which point it will go away automatically. So wherever you need to maintain the state of a bean for more than one request (but don't need it for the entire session), stick in a t:saveState tag for all pages that use it, and you're set. If you do this, and you follow Mike Kienenberger's suggestion to access the DataModel object that backs the dataTable component(illustrated in the O'Reilly book JavaServer Faces, pp. 175 - 179), you're all set; you don't need to pass any parameters through the request. Using the DataModel object also is explained in the book CoreJavaServer Faces (Geary, Horstmann), pp. 185 - 201. - Brendan -Original Message-From: Rick Reumann [mailto:[EMAIL PROTECTED]] Sent: Friday, August 26, 2005 4:41 PMTo: MyFaces DiscussionSubject: Re: Dealing with links/buttons to fire off an action? confusion on how to set this up On 8/26/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: However, I believe that, using this mechanism, there's no real way to get around usingsomething liket:saveState or having a session-scoped bean. Just out of curiosity, what is the objection to using t:saveState? Well I haven't gotten that far in my learning to have touched upon t:saveState. Was actually just more curious in general of how you deal with cases where you would typically want to use requestParams attached to a url link. -- Rick -- Rick
Re: How to call a method in the backing bean from a JSF page
I did it by just making the managedBean name the same as the jsp. So in your case: managed-bean managed-bean-namefooBar/managed-bean-name On 8/26/05, Saul Qunming Yuan [EMAIL PROTECTED] wrote: This sounds like it may work for me. I never used Shale, so how do I mapthe backingbean from fooBar to fooBar.jsp as you mentioned below? inface-config.xml?thanks. On 8/24/05, Saul Qunming Yuan [EMAIL PROTECTED] wrote: Thanks for your response. I guess I didn't make me clear here. My question is how to call a method in the backing bean from a JSF page without rendering out anything to the screen. I would suggest using Shale with JSF. Use the Shale jars and then have your backing bean implement a ViewController (I just extend AbstractViewController), and then you'll have several nice methods you can override. One is called prerender(). So if you map this backingbean to the correct path, for example fooBar, when fooBar.jsp is called the prerender method is invoked. That's the ultra simplified explanation and since I'm new to this, others (Craig) will probably elaborate more. It's really useful though for exactly what you want. -- Rick-- Rick
Dealing with links/buttons to fire off an action? confusion on how to set this up
I was wondering how to d something that I would think would be a common situation, yet I'm not finding any examples at the moment... scenario:... list of employees. You want to be able to click on one of the employees and go to an editEmployee backing bean method that would retrieve the employee based on the id of the employee in the list. I'm used to doing this with a simple link John Doe a href="" /setUpForEdit?employeeID=4355Edit/a With JSF I'm not so sure about how to do this. My JSF book mentions briefly about passing in f:param in commandLink but doesn't show how to retrieve this param. As a side note I find this very interesting, I was testing by using a DataTable and providing a commandLink next to each employee for each row... h:commandLink value=Edit action=""> f:param name=empID value=#{emp.id}/ /h:commandLink One of the odd/interesting things is that when I cycle through and print out the Request parameters I noticed that I'm getting a single parameter (assuming a map) that actually has the Employee info that I'm concerned with (2nd one): 8/26/05 02:28:55 PM DEBUG net.reumann.Employee editAction - param = [EMAIL PROTECTED] 08/26/05 02:28:55 PM DEBUG net.reumann.Employee editAction - param = id: 3, name: Rachel, age: 26 08/26/05 02:28:55 PM DEBUG net.reumann.Employee editAction - param = /employees.jsp That second enry *does* correspond to the button I clicked but not sure how I'm supposed to get a handle to the id (actually I'm not even sure how the heck that got into the request based on the commandLink I set up)? Also the f:param empID is *not* seen as a request parameter when I loop over them. What is the typical procedure for providing a link or button to click on that isn't part of a form but should fire off an action method that will look up something based on parameter(s) ?
Re: Dealing with links/buttons to fire off an action? confusion on how to set this up
On 8/26/05, Patel, Hitesh (Exchange) [EMAIL PROTECTED] wrote: You can pass the parameter as you have done and get the value of the parameter as follows FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(empID); I would guess this common to have to use? I would think it would be, and find it a bit odd that there isn't a more convenient way to get the params. Granted I can probably make a helper method to do the above. I know that in many of my apps I have cases where you'll click on a link or button in order to get to a different populated screen based on an id or some other var(s). For example in one app there are a lot of page that on the top of the page it displays the user you are looking at and provides a few convenience buttons next to the name for viewing 'summary' 'user logs' etc - which are just links that execute actions and the appropriate information is pulled back based on some params passed through the link. -- Rick
Re: Dealing with links/buttons to fire off an action? confusion on how to set this up
On 8/26/05, Mike Kienenberger [EMAIL PROTECTED] wrote: You can also use dataTable.getRowData(), provided your model data isconsistent, and then you don't need to create or pass a parameter.public void editRecord(ActionEvent event){dataStore.editRecord (dataTable.getRowData());} Can you explain this a bit more? For example will it matter if another user ends up going to the same JSP and has a 'different' view of the dataTable while I'm working with it in the editRecord method above? I would think that it wouldnt' matter but just double checking. -- Rick
Re: Dealing with links/buttons to fire off an action? confusion on how to set this up
On 8/26/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: However, I believe that, using this mechanism, there's no real way to get around usingsomething liket:saveState or having a session-scoped bean. Just out of curiosity, what is the objection to using t:saveState? Well I haven't gotten that far in my learning to have touched upon t:saveState. Was actually just more curious in general of how you deal with cases where you would typically want to use requestParams attached to a url link. -- Rick
Re: How to call a method in the backing bean from a JSF page
On 8/24/05, Saul Qunming Yuan [EMAIL PROTECTED] wrote: Thanks for your response. I guess I didn't make me clear here. My questionis how to call a method in the backing bean from a JSF page withoutrendering out anything to the screen. I would suggest using Shale with JSF. Use the Shale jars and then have your backing bean implement a ViewController (I just extend AbstractViewController), and then you'll have several nice methods you can override. One is called prerender(). So if you map this backingbean to the correct path, for example fooBar, when fooBar.jsp is called the prerender method is invoked. That's the ultra simplified explanation and since I'm new to this, others (Craig) will probably elaborate more. It's really useful though for exactly what you want. -- Rick
I know annoying when someone posts a stacktrace, but any help ?
I feel stupid posting this, but his stack trace doesn't seem to help me pinpoint why my navigation to a follow up page after a backingbean method is invoked is not working. (I've checked the spelling this time, and the employeeForm.jsp is in the root dir)... navigation-rule navigation-case from-outcomesuccess/from-outcome to-view-id/employeeForm.jsp/to-view-id /navigation-case /navigation-rule Method that is' being called: public String retrieveEmployeeAction() { log.debug(in retrieveEmployeeAction()); //get Employee from backend this.name = Rover; this.age = new Integer(25); return success; } After the above method fires, I get the nice 500 errorI have no idea why. (Couple notes... the backing bean method first called is returning success and employeeForm.jsp is spelled correctly and does exist)... 2005-08-24 18:05:27 StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception javax.faces.FacesException: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:83) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:109) snip Caused by: javax.faces.el.EvaluationException: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:206) at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154) at org.apache.shale.faces.ShaleViewHandler.setupViewController(ShaleViewHandler.java:224) at org.apache.shale.faces.ShaleViewHandler.createView(ShaleViewHandler.java:122) at org.apache.shale.clay.faces.ClayViewHandler.createView(ClayViewHandler.java:111) at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:135) at org.apache.shale.dialog.faces.DialogNavigationHandler.handleNavigation(DialogNavigationHandler.java:184) at ... snip Caused by: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:78) at org.springframework.web.jsf.DelegatingVariableResolver.getWebApplicationContext(DelegatingVariableResolver.java:134) at org.springframework.web.jsf.DelegatingVariableResolver.resolveVariable(DelegatingVariableResolver.java:112) at org.apache.shale.spring.WebApplicationContextVariableResolver.resolveVariable(WebApplicationContextVariableResolver.java:86) at org.apache.shale.faces.ShaleVariableResolver.resolveVariable(ShaleVariableResolver.java:99) at com.sun.faces.el.impl.NamedValue.evaluate(NamedValue.java:125) at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243) at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173) ... 43 more -- Rick
Re: I know annoying when someone posts a stacktrace, but any help ?
On 8/25/05, David Haynes [EMAIL PROTECTED] wrote: Rick Reumann wrote: I feel stupid posting this, but his stack trace doesn't seem to help me pinpoint why my navigation to a follow up page after a backingbean method is invoked is not working. (I've checked the spelling this time, and the employeeForm.jsp is in the root dir)... navigation-ruleDon't you need a from-view-id here? I've tried it with that and without it. Same problem. (I thought you don't have to use from-view-id - at least the book I'm using it shows it both ways? Concept of global forwards) -- Rick
Re: I know annoying when someone posts a stacktrace, but any help ?
Currently I'm just trying to see if I can get to a blank page without errors so I just have... %@ taglib uri=http://java.sun.com/jsf/core prefix=f % %@ taglib uri=http://java.sun.com/jsf/html prefix=h % %@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c % f:view h:form /h:form /f:view But I've tried other things.. just blank, just one word, just f:view /f:view and tried with my actual form that I wanted between the h:form tags. I'm wondering if the problem is because I'm using all the shale jars from the struts-shale-usecases example but I'm not setting up a bunch of the other configs I see under web-xml that are in that example (ie chain-config.xml, dialog-config.xml, etc). I wasn't sure what the minimal jars I needed to use Shale and the ViewController were so I just included them all (I tried removing the Spring ones and the application wouldn't start up).On 8/25/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: Did you wrap your JSF code in f:view.../f:view? - Brendan -Original Message-From: Rick Reumann [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 25, 2005 9:01 AMTo: MyFaces DiscussionSubject: I know annoying when someone posts a stacktrace, but any help ?I feel stupid posting this, but his stack trace doesn't seem to help me pinpoint why my navigation to a follow up page after a backingbean method is invoked is not working. (I've checked the spelling this time, and the employeeForm.jsp is in the root dir)...navigation-rule navigation-case from-outcomesuccess/from-outcome to-view-id/employeeForm.jsp/to-view-id /navigation-case /navigation-rule Method that is' being called:public String retrieveEmployeeAction() { log.debug(in retrieveEmployeeAction()); //get Employee from backend this.name = Rover; this.age = new Integer(25); return success; }After the above method fires, I get the nice 500 errorI have no idea why. (Couple notes... the backing bean method first called is returning success and employeeForm.jsp is spelled correctly and does exist)...2005-08-24 18:05:27 StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception javax.faces.FacesException: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:83) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:109) snip Caused by: javax.faces.el.EvaluationException: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:206) at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:154) at org.apache.shale.faces.ShaleViewHandler.setupViewController(ShaleViewHandler.java:224) at org.apache.shale.faces.ShaleViewHandler.createView(ShaleViewHandler.java:122) at org.apache.shale.clay.faces.ClayViewHandler.createView(ClayViewHandler.java:111) at com.sun.faces.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:135) at org.apache.shale.dialog.faces.DialogNavigationHandler.handleNavigation(DialogNavigationHandler.java:184) at ... snip Caused by: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:78) at org.springframework.web.jsf.DelegatingVariableResolver.getWebApplicationContext(DelegatingVariableResolver.java:134) at org.springframework.web.jsf.DelegatingVariableResolver.resolveVariable(DelegatingVariableResolver.java:112) at org.apache.shale.spring.WebApplicationContextVariableResolver.resolveVariable(WebApplicationContextVariableResolver.java:86) at org.apache.shale.faces.ShaleVariableResolver.resolveVariable(ShaleVariableResolver.java:99) at com.sun.faces.el.impl.NamedValue.evaluate(NamedValue.java:125) at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:243) at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:173) ... 43 more -- Rick -- Rick
Re: I know annoying when someone posts a stacktrace, but any help ?
I do have the shale fliter in place and it is working because the prerender is being called in my backingBean that extends AbstractViewController. I did have the clay.jar in my lib and no config set up for it, but I removed that jar and I'm still getting the same error:( The current jars I have in my web app lib are: commons-beanutils.jar commons-chain.jar commons-collections.jar commons-digester.jar commons-el.jar commons-logging.jar commons-validator.jar jsf-impl.jar jstl.jar log4j-1.2.7.jar myfaces.jar shale-core.jar shale-spring.jar spring-beans.jar spring-context.jar spring-core.jar spring-web.jar standard.jar struts.jar On 8/25/05, Gary VanMatre [EMAIL PROTECTED] wrote: Make sure that you have the ShaleApplicationFilter in your web deployment descriptor (web.xml). This guy registers theShalePhaseListener that fires some of the livecycle events on the view controller. !-- Shale Application Controller Filter -- filter filter-nameshale/filter-name filter-class org.apache.shale.faces.ShaleApplicationFilter /filter-class /filter !-- Shale Application Controller Filter Mapping -- filter-mapping filter-nameshale/filter-name url-pattern/*/url-pattern /filter-mappingYou might not need the shale-clay.jar archive. It is optional and you won't need this stuff if you are not using it (in your web.xml). !-- Clay Configuration Resources -- context-param param-nameclay-config-files/param-name param-value/WEB-INF/clay- config.xml/param-value /context-param !-- Clay template suffix override, default is .clay -- context-param param-nameclay-template-suffix/param-name param-value.html/param-value /context-param !-- Clay Configuration Listener -- listener listener-classorg.apache.shale.clay.config.ClayConfigureListener /listener-class /listener servlet-mapping servlet-namefaces/servlet-name url-pattern*.html/url-pattern /servlet-mapping Gary-- Forwarded message --From:Rick Reumann [EMAIL PROTECTED]To:MyFaces Discussion users@myfaces.apache.orgDate:Thu, 25 Aug 2005 15:22:57 +Subject:Re: I know annoying when someone posts a stacktrace, but any help ?Currently I'm just trying to see if I can get to a blank page without errors so I just have... %@ taglib uri=http://java.sun.com/jsf/core prefix=f % %@ taglib uri=http://java.sun.com/jsf/html prefix=h % %@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c % f:view h:form /h:form /f:view But I've tried other things.. just blank, just one word, just f:view /f:view and tried with my actual form that I wanted between the h:form tags. I'm wondering if the problem is because I'm using all the shale jars from the struts-shale-usecases example but I'm not setting up a bunch of the other configs I see under web-xml that are in that example (ie chain-config.xml, dialog-config.xml, etc). I wasn't sure what the minimal jars I needed to use Shale and the ViewController were so I just included them all (I tried removing the Spring ones and the application wouldn't start up).On 8/25/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: Did you wrap your JSF code in f:view.../f:view? - Brendan -Original Message-From: Rick Reumann [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 25, 2005 9:01 AMTo: MyFaces DiscussionSubject: I know annoying when someone posts a stacktrace, but any help ?I feel stupid posting this, but his stack trace doesn't seem to help me pinpoint why my navigation to a follow up page after a backingbean method is invoked is not working. (I've checked the spelling this time, and the employeeForm.jsp is in the root dir)...navigation-rule navigation-case from-outcomesuccess/from-outcome to-view-id/employeeForm.jsp/to-view-id /navigation-case /navigation-rule Method that is' being called:public String retrieveEmployeeAction() { log.debug(in retrieveEmployeeAction()); //get Employee from backend this.name = Rover; this.age = new Integer(25); return success; }After the above method fires, I get the nice 500 errorI have no idea why. (Couple notes... the backing bean method first called is returning success and employeeForm.jsp is spelled correctly and does exist)...2005-08-24 18:05:27 StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception javax.faces.FacesException: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered? at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:83) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:109) snip Caused by: javax.faces.el.EvaluationException: java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener registered
Re: I know annoying when someone posts a stacktrace, but any help ?
Thanks Craig. That was the problem.On 8/25/05, Craig McClanahan [EMAIL PROTECTED] wrote: On 8/25/05, Craig McClanahan [EMAIL PROTECTED] wrote: On 8/25/05, Rick Reumann [EMAIL PROTECTED] wrote: I do have the shale fliter in place and it is working because the prerender is being called in my backingBean that extends AbstractViewController. I did have the clay.jar in my lib and no config set up for it, but I removed that jar and I'm still getting the same error:( See my response on the Struts user list. ContextControllerLIstener is a Spring Framework thing, used to initialize the Spring BeanFactory (in a webapp, that's a WebApplicationContext).If you're using the Spring integration you need to register this listener in web.xml (like the use cases app does).If you're not using the Spring integration, you shouldn't need to -- that's a Shale bug if it blows up in that case. CraigOne more note -- if you're not using the Spring integration, you'llwant to remove shale-spring.jar and all the other Spring related jars. Craig-- Rick
Any implementations of DataTable let you use a Map?
Are there any components that let me build a DataTable from a Map? (currently it's sort of a pain having to covert my Map to a List to be used by the DataTable). -- Rick
Re: confusion on best practices in regard to a VO in BackingBean
On 8/24/05, Sean Schofield [EMAIL PROTECTED] wrote: You could also use a facade pattern.We have one in our Struts appand we're planning on keeping the facade when we move to JSF.Before you had ...Facade::getInvoiceInvoiceForm::setInvoice, etc. InvoiceAction::executeNow you have ..Facade::getInvoiceInvoiceBacker::getInvoice I'm a bit confused about what you mean in the above. Are you registering more than one managed bean in reference to an Invoice? My concern is that getInovice can either mean 'perform some business action to retrieve an invoice (maybe based on an id) OR getInvoice can me simply get the existing reference to an invoice for use on a form. I'm not sure how your facade pattern here addresses the issue. I think I'm going to try the getInvoiceAction getInvoice and use one backing bean with an InvoiceVO nested inside although I like the idea of keeping the backing bean and vo as separate managed beans. I don't really know enough about how managed beans work in order to accomplish this later approach. I'll ask my question in reply to that e-mail vs asking it here.
Re: confusion on best practices in regard to a VO in BackingBean
On 8/24/05, David Haynes [EMAIL PROTECTED] wrote: Rick Hightower does this in his Clearing the FUD about JSFhttp://www-128.ibm.com/developerworks/java/library/j-jsf1/He has the XyzBeand and XyzController with the controller containing: XyzBean xyzBean = new XyzBean();and then supporting the methods etc. via xyzBean.method() calls. HisController is your Action.See his extremely fine articles for more details. No offence, but I've looked at that article and it doesn't even remotely address what this thread is asking about My question was in reference to using two managed beans one as your typical action/controller and one as your value object. Even discarding this question and going back to the original question, Hightower's article does not address the issue at hand. In case some have lost the initial thread question... Imagine you need to perform tasks on an Employee - saveEmployee, getEmployee, etc. Yet, after getting an employee from the backend, you will then also need a reference to this employee object that you returned from the backend for use on your page. Someone previously mentioned use getEmployeeAction (does the business delegate call) and getEmployee (returns the instance of the Employee object from your backing bean). Hightower's example is dealing with a calculator and performing calculator operations - not returning a cacluator for use in the view.. I really wish there was a simple example dealing with CRUD stuff. I'm in the process of writing one, but I'm surprised there isn't one out there already. -- Rick
Re: confusion on best practices in regard to a VO in BackingBean
On 8/24/05, David Haynes [EMAIL PROTECTED] wrote: I'm confused here. If the EmployeeBean object is embedded in theEmployeeController and all the methods of EmployeeBean are available viathe EmployeeController, why do you need the EmployeeBean directly? Well for example after you used your backing bean to get an employee (getEmployee method?), you would then want to display the employee name on the page.. so you might have... employeeBackingBean.employee.name But that above would attempt to call 'getEmployee' which, if where my initial confusion on 'best practice' came from since 'getEmployee' could either mean 'get me the instance of the employee object from my backing bean' or 'call some backend method to get me an instance of the employee from the backend.' -- Rick
Re: confusion on best practices in regard to a VO in BackingBean
On 8/24/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: Our CalculatorBean would be a simple JavaBean containing firstNumber,secondNumber, and result.Our CalculatorAction class would have a field called calcBean (and itsgetter and setter), which is set by JSF, plus the methods add() and multiply().(Note that, since the reference to calcBean is a managedreference, CalculatorAction does *not* instantiate calculatorBeanitself.)The JSP would then refer to #{calcBean.firstNumber},#{calcBean.secondNumber }, #{calcBean.result}, #{calcAction.add}, and#{calcAction.multiply}. Ok, I really like this, but help me out with trying to understand a totally noob concept... to help me relate, lets change the above to an Employee and an EmloyeeAction... First what I want to accomplish... I'm on a JSP and I'm viewing a list of employees. I click on a button next to the employee that should bring me to an 'editEmployee' screen after looking up the employee from backend based on id. Clicking on the button should call the EmployeeAction backing bean and retrieve an Employee (which using your scenario would also be a managed bean). The Employee object is returned from the EmployeeAction's 'getEmployee' method. We now foward on to the 'employeeForm.jsp' *Which backing bean am I now to use on this employeeForm.jsp* and how does it manage to get a handle to the Employee that we just returned from our EmployeeAction if we are using request scoped managed beans? There seems to be black-box stuff going on that I'm unclear about. I'm used to stuffing the Employee object into the request in my Action (struts terms), so I'm having trouble grasping how my resulting page is going to have access to this employee object that was just returned in my managed EmployeeAction bean? Thanks so much for the help so far.
Re: confusion on best practices in regard to a VO in BackingBean
On 8/24/05, David Haynes [EMAIL PROTECTED] wrote: [in employeeBackingBean]...EmployeeBean eb = new EmployeeBean();...public String getName() {return eb.getName();}...So, all the elements of the EmployeeBean are available via the employeeBackingBean in an unambiguous way. Or am I still missing the point? Funny, I was just going to reply that I bet that is the way to handle this (when using the combined action/value object wrapped up into one managed bean concept). Thanks for clarifying this. I will, however, be interested in the other replies on how you this gets handled when you keep them as separate managed beans ( EmployeeAction and Employee ). Thanks again for your patience with me on this. It's 'slowly' starting to click. I feel like an old dog trying to learn new tricks:) -- Rick
Does a doc exist describing the MyFaces features?
Someone mentioned using x:dataList in place of JSTL for each. I'm curious, is there a document that shows a list of all the different features MyFaces supplies? I know the MyFaces example app shows a lot (maybe all?), but it would be nice to see all these features and a quick example of usage in a single pdf or doc. (Trust me not complaining if one doesn't exist, was just curious if there was one floating around somewhere). Thanks.-- Rick
Re: confusion on best practices in regard to a VO in BackingBean
On 8/24/05, David Haynes [EMAIL PROTECTED] wrote: So, if you have already created an instance of employeeBackingBean (andit is defined as having a session scope), it should be available for allsubsequent pages in the session. Correct. But I wouldn't think I'd need to have to give my backing bean session scope in order to accomplish this. Using Struts as an example, if I'm in my Action responsible for getting an Employee from the backend and I then shove it request scope, the Employee is now available on the resulting page that I forward to. I'm still a bit stumped how this is accomplished with JSF without using Session scoped backing beans. To reiterate the flow ... employees.jsp - user clicks on edit employee link (passing in employee id) backing bean getEmployeeAction method called returning an employee object from backend. (For simplicity lets just assume Employee object is in this EmployeeBackingBean). navigation rule has us now forward to the employeeForm.jsp which should be autopopulated with the Employee information we returned in our backing bean. Can all of this be done with Request scope? I would think it should since it's pretty basic CRUD UI flow in applications. -- Rick
was Re: confusion on best practices in regard to a VO in BackingBean
On 8/24/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: (BTW, if you need something more than request scope but less than session scope, use the handy t:saveState tag that MyFaces gives you to carry along the bean for as many pages as you need to. Then you can simply declare it with request scope. Wow! That sounds like a killer tag! I look forward to checking that out. Thanks everyone for your help. -- Rick
Any idea what I'm doing wrong here?
I'm sort of stumped since the error logs aren't revealing much to me. I'm just working on page flow test and I'm on 'emloyees.jsp' and I'm clicking on a button that should access another managed bean and then forward me to 'employeeForm.jsp'. Error first then some relevant souce code to follow: 2005-08-24 16:29:05 StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception javax.faces.FacesException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Unrecognized Content Type. at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:327) at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130) snip Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspException: Unrecognized Content Type. at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821) at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758) at org.apache.jsp.employees_jsp._jspService(employees_jsp.java:83) faces config - faces-config navigation-rule from-view-id/empoloyees.jsp/from-view-id navigation-case from-outcomegetEmployeeSuccess/from-outcome to-view-id/empoloyeeForm.jsp/to-view-id /navigation-case /navigation-rule managed-bean managed-bean-nameemployees/managed-bean-name managed-bean-classnet.reumann.EmployeesBacking/managed-bean-class managed-bean-scoperequest/managed-bean-scope /managed-bean managed-bean managed-bean-nameemployee/managed-bean-name managed-bean-classnet.reumann.EmployeeBacking/managed-bean-class managed-bean-scoperequest/managed-bean-scope /managed-bean /faces-config index.jsp - jsp:forward page=/employees.faces/ employees.jsp --- //dataTable listing employees h:commandButton value=test action=""> EmployeeBacking //the retrieveEmployeeAction below is getting hit since the log message is showing up public String retrieveEmployeeAction() { log.debug(in retrieveEmployeeAction()); //get Employee from backend this.name = Rover; this.age = new Integer(25); return getEmployeeSuccess; } employeeForm.jsp - never getting here.
Re: Any idea what I'm doing wrong here?
How embarrassing:) It's been a long day. I wonder how much time I've lost of my life based on stupid typos:) Sad thing is I must have starred at the code a million times. On 8/24/05, Matt Blum [EMAIL PROTECTED] wrote: Did you copy and paste out of those files? If so, you have several typos: empoloyees.jsp and empoloyeesForm.jsp in the faces-config. -MattOn 8/24/05, Rick Reumann [EMAIL PROTECTED] wrote: I'm sort of stumped since the error logs aren't revealing much to me. I'm just working on page flow test and I'm on 'emloyees.jsp' and I'm clicking on a button that should access another managed bean and then forward me to 'employeeForm.jsp'. Error first then some relevant souce code to follow: 2005-08-24 16:29:05 StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception javax.faces.FacesException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Unrecognized Content Type. at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:327) at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130) snip Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspException: Unrecognized Content Type. at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:821) at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758) at org.apache.jsp.employees_jsp._jspService(employees_jsp.java:83) faces config - faces-config navigation-rule from-view-id/empoloyees.jsp/from-view-id navigation-case from-outcomegetEmployeeSuccess/from-outcome to-view-id/empoloyeeForm.jsp/to-view-id /navigation-case /navigation-rule managed-bean managed-bean-nameemployees/managed-bean-name managed-bean-classnet.reumann.EmployeesBacking/managed-bean-class managed-bean-scoperequest/managed-bean-scope /managed-bean managed-bean managed-bean-nameemployee/managed-bean-name managed-bean-classnet.reumann.EmployeeBacking/managed-bean-class managed-bean-scoperequest/managed-bean-scope /managed-bean /faces-config index.jsp - jsp:forward page=/employees.faces/ employees.jsp --- //dataTable listing employees h:commandButton value=test action=""> EmployeeBacking //the retrieveEmployeeAction below is getting hit since the log message is showing up public String retrieveEmployeeAction() { log.debug(in retrieveEmployeeAction()); //get Employee from backend this.name = Rover; this.age = new Integer(25); return getEmployeeSuccess; } employeeForm.jsp - never getting here. -- Rick
Re: confusion on best practices in regard to a VO in BackingBean
On 8/24/05, Slawek [EMAIL PROTECTED] wrote: but Rick says in his article that:view is only jsp page, controler is backing bean and model has businesslogic I take it by article you mean 'e-mail post' ? I don't think I posted any comments on JSF architecture since I obviously am just learning it myself. -- Rick
Re: Populating a web page?
I think this is where something like Shale will help - having your backingBean implement ViewControlloer http://struts.apache.org/shale/features.html#view You would use the prerender() method to populate your form with what you needed. I'm new to all of this (JSF/Shale) but in the process of trying to get something like this to work.On 8/23/05, albartell [EMAIL PROTECTED] wrote: The way I do it is to have page1.jsp make a call to a backing bean methodthat fills global variables with data. Note that my backing beans that do this are defined in the session scope. Another way to do it would be to passthe necessary information via the f:param tag.You can imbed that tagwithin a commandLink, for instance, and when the user clicks the button the appropriate action method will be executed, and in that action method youcan retrieve the value passed on f:param.HTH,Aaron Bartell-Original Message-From: Bjørn T Johansen [mailto: [EMAIL PROTECTED]]Sent: Tuesday, August 23, 2005 3:27 AMTo: users@myfaces.apache.orgSubject: Populating a web page?In Struts I can use the action method to call some method to get the data and populate the form, but what is the best way of doing this in myfaces(JSF)?I.e I am on one page and going to another, but before rendering the otherpage I need to get some data from a database... Regards,BTJ-Bjørn T Johansen[EMAIL PROTECTED] ---Someone wrote:I understand that if you play a Windows CD backwards you hear strangeSatanic messagesTo which someone replied:It's even worse than that; play it forwards and it installs Windows - Rick
Having trouble with JSTL inside JSF
I understand the below won't work as is without the backing bean put in scope with a useBean construct...but I'm more curious why I can not get c:out to evaluate (or really I should also just be able to use ${..} without the c:out since using tomcat5). What I end up getting is the literal text ${status.index} being displayed. I've tried with commons-el.jar and without and the same result:( %@ taglib uri=http://java.sun.com/jsf/core prefix=f % %@ taglib uri=http://java.sun.com/jsf/html prefix=h % %@ taglib uri=http://java.sun.com/jsp/jstl/core prefix=c % f:view h:form c:forEach items=${employeeBacking.employees} var=emp varStatus=status c:out value=${status.index}/br/ /c:forEach /h:form /f:view
confusion on best practices in regard to a VO in BackingBean
For sake of this discussion imagine a case where user needs to click on a button to get and invoice based off an invoice ID. Now coming from struts I'm used to going to a 'getInvoice' dispatch method which would return to me an Invoice object (after making a backend call) and then that Invoice would be stuffed into the request for use on the page we forward to. With JSF, I'm assuming you'd typically want an InvoiceBackingBean and nested in there possibly an Inovice value object? So then on a JSP you could have invoiceBackingBean.invoice.id This would obviously mean your InvoiceBackingBean would need a getInvoice method that would return the instance of the Invoice object in the backing bean. Where I'm now confused is what do you call the actual action method in your BackingBean that would do the true get (dao/service/delegate call) that would populate the Invoice object in the backing bean. Aren't you going to run into some odd naming conventions? Do you make another method called retrieveInvoice ? So looking at the backingBean you'll have getInvoice - returns the invoice object in backing bean, and then you'll also have retrieveInvoice - which is what your forms will call when submitted to populate the actual invoice in the backing bean? How do you gurus handle this?-- Rick
Re: confusion on best practices in regard to a VO in BackingBean
On 8/23/05, CONNER, BRENDAN (SBCSI) [EMAIL PROTECTED] wrote: As another alternative, the practice we've been following is to have anXyzAction class and a separate XyzBean class.The Action class has amanaged reference to the Bean class and has all the logic in it.The Bean class is just a straight JavaBean and contains all the data neededby the JSF page. In the above case wouldn't you need to end up registering both XyzAction and XyzBean as managed beans? It would seem like you would have to. I guess not a big deal, but you'd end up with double the number of typical backing beans. -- Rick
feel like an idiot... basic tiles question
Man, this is annoying since I know this has to be simple. I'm looking at both the Core JSF book and the MyFaces tiles example application. Question... How is the definition name in your tiles defiition related to your 'to-view-id'? I don't see this documented anywhere. For example in the MyFaces tiles example a to-view-id looks like: to-view-id/page2.jsp/to-view-id And for a tile definition I see: definition name=/page2.tiles extends=layout.example What are the rules in how this tile definition is picked up? I see other examples (ie Geary's book) he doesn't use *.tiles in his definition, so I'm missing the logic in how this definition gets picked up? In Struts it's easy since that definition name must match the String in mapping.findForward that I call from my Actions. Thanks. -- Rick
Re: scope for backing beans
Craig McClanahan wrote the following on 2/11/2005 11:45 AM: My recommendation is to use request scope for backing beans in a JSF application, storing stuff in session and appiication scope only where it's needed: * Session scope for per-user state that changes, or for passing data across requests (as an alternative to having to save and restore the data yourself). * Application scope for caching things like arrays of SelectItems that back a dropdown list, but are shared across all users. I haven't had much luck with the later situation for application scope. I do use Application scope for such things as having a Constants Map in scope that the front end might need access to, but for drop down lists unless it's 'definitely' not going to change I don't like application scope since any changes to the backend database aren't going to be picked up until the server restarts. I tend to opt now for making calls to the persistence layer to re-get my Lists that I need again. This lets the persistence layer worry about caching if it needs to. Sure a method call will be more expensive than using a list or array already in applicaiton scope, but to me it's a fair trade off. I've been burned too many times thinking this list of options will never change and sure enough someone makes a change to the backend and it's not reflected by your app and then you get the annoying phone calls:) -- Rick
Re: scope for backing beans
Sean Schofield wrote the following on 2/14/2005 11:23 AM: With the application scope beans in JSF I have been toying with the idea of using them instead. I was thinking that it might be possible to invalidate the bean (by setting the value to null) whenever a new item is added. I haven't worked out the details yet but thread safety is an issue that jumps to mind. Also, you'd have to have make sure that you were listening to every possible point where the list might change. That last part is the tricky part. It's super easy if you know the data will only be altered by your web application. If that is the case you can forget even using application scoped items and simply use iBATIS for your persistence framework (uses regular SQL). It has some great caching mechanisms to handle the issues you are concerned with. For example whenever an update operation is performed (by calling your defined update procedure in an xml doc) you could set a flag in the udpate procedure that will clear the cache of other queries. The bottom line, though, is this is all nice, but everywhere I have worked the data often changes from some other point other than your web app. This is where it gets very ugly. What are you going to do when some other external procedure updates your backend data? Accounting for those entry points can be a royal pain. -- Rick
Re: Plans to include at least parts of MyFaces into JSF?
Sean Schofield wrote the following on 1/12/2005 11:12 AM: There is also a JSF mailing list on Sun's java forums that seems to have some of the spec people lurking around. It still amazes me that there is no regular mailing list for JSF. I hate those forum approaches. Email is so much more conveinient. I almost decided to give up on JSF because of what I thought were unworkable omissions. At the last minute, the folks on this list persuaded me that we could try and meet the short comings through the myfaces implemenation. So that's what I'm doing now and I'm encouraged by what I am learning about JSF as I go. Its very powerful and very extensible. So yes, there will be lots of things in myfaces that are not supported elsewhere, but JSF does make it easy to provide these add ons. True, but had you not been diligent enough to look elsewhere (MyFaces) you mention you might have given up. I was in the same boat. JSF might lose some good people that just don't have the time or energy to look elsewhere. -- Rick
Re: Tiles Performance
Martin Marinschek wrote the following on 1/11/2005 11:40 AM: Interesting - we just got an OutOfMemoryException and sluggish performance in our application when we were rendering 4000+ Data rows in a datatable. Just a heads-up, do NOT use SiteMesh in it's current state if you are going to return very large pages that have to be decorated. I switched from using Tiles to Sitemesh and overall I really like Sitemesh, but I had to chuck it out since there is the potential for very large pages to cause out of memory issues. The problem is the whole output is stored in a buffer before it's decorated and then flushed. Storing a huge amount of data in even a StringBuffer could cause a problem if you don't have a lot of RAM. -- Rick