-
1. Re: DataModelSelection property not set after using the back
mjek2 Feb 22, 2007 8:45 AM (in response to pnorman4)AFAIK it works fine in Seam examples (and I also use @DataModelSelection in my app, it works even after back button usage, I'm currently on Seam1.1.1). Do you have just one @DataModelSelection in your component? Could you show some more code (complete xhtml page and related java components)? StackTrace if any? Seam/JSF version?
-
2. Re: DataModelSelection property not set after using the back
pnorman4 Feb 22, 2007 11:18 AM (in response to pnorman4)Actually, I'm using four different @DataModel. Three of these have their own @DataModelSelection.
The page is composed of a page with a table (uses mainListItems). and a small list of selected items (populated by selectedListItems).
The page uses a facelet template, which contains a menu (populated by leftMenuList), and a special list (populated by oPoolItems).
The main table looks like this (i'm not sending complete xhtml listings for all 6 files yet):<h:dataTable value="#{mainListItems}" var="listItem" id="mooxTable"> <h:column> <h:outputText value="(#{listItem.localItem.title}) "/> </h:column> <!-- Open --> <h:column> <s:link action="#{mainBean.selectListItem}" value="S:Open"/> </h:column> </h:dataTable>
The other lists are rendered in the same way.
The link navigates to a new detail page, with the same template.
The bean looks like this:@Name("mainBean") @Scope(ScopeType.SESSION) public class MainBean extends AbstractSeamBean { /* REMOVED: Import of referenced beans */ /** * This list contains the select list items. */ @DataModel private List<ContentListItem> selectedListItems = new ArrayList<ContentListItem>(); /** * This is the current content of the main content area. */ @Out(required = false) private ContentListItem currentMainObject = new ContentListItem(0, new MooxMock("Nothing")); public boolean isCurrentList() { return (null != currentMainObject && currentMainObject.getLocalItem() instanceof MooxList); } /** * This is the data model for the left menu. */ @DataModel private List<ContentListItem> leftMenuList; @DataModelSelection("leftMenuList") private ContentListItem selectedLeftMenItem; @Factory("leftMenuList") public void loadMenu() { /* REMOVED: "leftMenuList" initialization */ } public String selectLeftMenuItem() { return setCurrentObject(selectedLeftMenItem); } /** * This is the data model for the list view. */ @DataModel @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) private List<ContentListItem> mainListItems = new ArrayList<ContentListItem>(); @DataModelSelection("mainListItems") private ContentListItem selectedListItem; @Factory("mainListItems") public void updateListItems() { /* REMOVED: "mainListItems" initialization */ } /** * Action method used when selecting a list view item. * * @return Navigation. */ public String selectListItem() { return setCurrentObject(selectedListItem); } /** * Sets a list item as the new object for the main area. * * @param newObject The new object to show in main area. * @return Navigation. */ public String setCurrentObject(ContentListItem newObject) { log.debug("** MainBean - setCurrentObject: #0", currentMainObject); currentMainObject = newObject; updateListItems(); return (isCurrentList() ? "listSelected" : "objectSelected"); } /** * O-pool. */ @DataModel private List<ContentListItem> oPoolItems; @DataModelSelection("oPoolItems") private ContentListItem selectedOpoolItem; @Factory("oPoolItems") public void updateOPoolItems() { /* REMOVED: "oPoolItems" initialization */ } /** * Action method used when selecting an O-pool item. * * @return Navigation. */ public String selectOpoolItem() { return setCurrentObject(selectedOpoolItem); } }
There are no stack traces or errors.
We're using
Seam 1.1.6, MyFaces 1.1.5, Facelets 1.1.12, Ajax4JSF 1.0.6.
/Per -
3. Re: DataModelSelection property not set after using the back
mjek2 Feb 23, 2007 3:56 AM (in response to pnorman4)You call updateListItems() from setCurrentObject() which in turn is called when the user selects something from the list using s:link. If updateListItems() manipulates mainListItems I can imagine that it could cause your problem. Did you try to remove updateListItems() from setCurrentObject()? And do you observe your problem only when using back button?
-
4. Re: DataModelSelection property not set after using the back
pnorman4 Feb 23, 2007 7:35 AM (in response to pnorman4)That's it!! I'm reloading the list when entering detail view. Of cours I can't go back to thelist again. Completely logical now when I see it.
I removed the updateListItems() call and now it works!!
You're my hero!
Per