PDA

View Full Version : Portal Index and Column - IndexOutOfBoundsException



mwmcmullen
11 Jan 2011, 6:41 AM
There is a portal with 3 columns. Each portal has sets of portlets which can obviously be dragged and dropped anywhere in the portal. Upon a user saving a configuration, I'm storing all relevant information including the index and column positions of each portlet.

When the user loads the newly saved configuration, I receive a IndexOutOfBoundsException_1.

The desired outcome is for the user to drag and drop where they want things to be, save it, load it and see the portal in the same state (i.e. portals in right positions) they were when they were saved.

I'm doing the equivalent of:

Looping a list to see if index/col are null, if not null:


final MyPortlet port = new MyPortlet(params);
portlets.add(port);
int col = Integer.valueOf(column);
int i = Integer.valueOf(index);

insert(port, i, col);

Anyone see what I'm doing wrong?

sven
11 Jan 2011, 12:40 PM
It probably fails because the index you choose is higher than the count of items you have in your porlet. Could this be possible?

mwmcmullen
12 Jan 2011, 3:26 AM
It probably fails because the index you choose is higher than the count of items you have in your porlet. Could this be possible?

It is definitely possible. However that's a problem that I thought would be handled by the portal? If there is essentially a list of portlets which need to be inserted into a portal whilst avoiding an indexoutofbounds for the index into the column - how would this be done?

sven
12 Jan 2011, 12:09 PM
Add them in the correct order, or at a valid index. If you want to add something at index 7, than this index needs to be valid. Same as in a list.

mwmcmullen
12 Jan 2011, 12:19 PM
Add them in the correct order, or at a valid index. If you want to add something at index 7, than this index needs to be valid. Same as in a list.

Why offer the insert(Portlet,Column,Index) method if it does exactly the same as add(Portlet,Column) then?

sven
12 Jan 2011, 12:27 PM
It is not doing the same.

You have 2 elements in the Portal, than you can add something at for example index 0 or 1, but not index 7 because its invalid. With add you cannot do that.