Hello,
I have a list with x number of items, and a page with x number of portlets. Each portlet on the page has the same backing class and access to my list, and what's shown changes depending on which list item is selected. The edit mode allows the user to select which item to display, and I store the item they selected in the preferences object behind the portlet.
As it stands, each portlet initially displays the first item in the list until a user edits the portlet and selects a different item. However, I'd like each portlet to show a different item initially.
It seems like I'll have to calculate which item to show based on position. If I have 2 columns and 6 rows then the item in column 2 row 4 will show item 8 ((row - 1) * #columns + column). This works well except that, when the user starts moving the portlets around, the portlet values change with position.
I'd like to "lock in" the item selected initially, so it doesn't change with movement. Unfortunately, I really need to store the initial item selected (or the initial position) in the preferences object, but I can't do that in the doView function, and processAction isn't called until a portlet switches states.
I thought about just storing the initial choice in the session and reading it when the processAction function is called (giving it lower priority than the actual submitted choice). The problem with this is that, if the session invalidates before the user switches portlet modes, the selected item won't be stored.
My other thought was to somehow include the portlet's position as a variable in the portlet-preferences element of the portlet.xml file, but I don't even know if this is possible.
I guess another option would be to use my own preferences implementation, but I kind of see that as a last resort.
Does anyone have any ideas about how I might accomplish what I need?
Any help/suggestions are much appreciated.
Thanks,
B.J.
P.S. I'm using the Portlet 2.0 specification (though I'm not using events) and Jetspeed 2.1 as a portlet container.