how to order strings?

hi,

i have to show some String in my jsp .. this Strings i get dynamiclly from my Database.

now i am showing the String . but i need to make it possible for the admin in a admin jsp to

change the ORDER of the String (sometimes alphabet , sometimes index )

for every string in database i have attribute "index".

how can i do this in the best way ?

want to show the lines and let the admin chose a new order?

something like this:

string 11

string 22

strnig 33

new order:

string 22

string 33

string 11

please anyone an idea?

thankx

[631 byte] By [golanblna] at [2007-11-26 16:32:01]
# 1
You can keep your index and strings in a map and then this link might help you to sort the map: http://www.theserverside.com/discussions/thread.tss?thread_id=29569The sorting criteria can be supplied dynamically.Thanks.
SanjeevGoura at 2007-7-8 22:56:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

As far I understand he just want to manually order the items and not order them by natural string order or so (which is fairly easy to implement using Collections.sort() however).

Well, you can implement it in two ways: using clientside Javascript or using serverside JavaEE. If Javascript, then Google on "javascript moveup movedown" or so. If JavaEE, then just do something like:

public void moveUp() {

int currentIndex = items.indexOf(selectedItem);

items.remove(selectedItem);

items.add(currentIndex - 1, selectedItem);

}

BalusCa at 2007-7-8 22:56:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
NVM sorryMessage was edited by: jbayuga
jbayugaa at 2007-7-8 22:56:36 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...