double select rempli dans l'Action
Bonjour,
Je rencontre un soucis quand je souhaite utiliser le TAG Double Select de Struts 2. En effet quand je construit directement mes listes au sein de la JSP aucun soucis il fonctionne très bien.
Code:
1 2 3 4 5 6
| <s:doubleselect label="Select Item"
headerValue="--- Please Select ---"
headerKey="1" list="{'Color','Fruits'}"
doubleName="dishes"
doubleList="top == 'Color' ? {'Black','Green','White',
'Yellow','Red','Pink'} : { 'Apple','Banana','Grapes','Mango'}" /> |
Néanmoins quand je souhaite initialiser ces listes au sein de l'action préalable à l'affichage de la JSP, impossible d'accéder à la 2ieme liste de sélection... J'ai essayé plusieurs pistes et rien n'y fait. Or je ne trouve nulle part d'exemple concernant cette fonctionnalité.
Certains d'entre vous ont-ils réussi à utiliser un DoubleSelect initialisé dans l'Action ?
D'avance merci de votre aide.
Besoin d'aide pour faire la même chose que vous
Bonjour,
je souhaiterai faire comme vous, utiliser un doubleselect de struts et le remplir dans une class Action. La première liste se remplit bien de RSA, et ECDSA mais la deuxième reste vide malgré la présence de la classe getListKeySize() dans la classe DigestAlgo()
J'ai bien créé comme vous le dîtes deux classes
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| public class KeySize {
/**
* taille de la cle.
*
*/
private final int code;
/**
* taille de la cle.
*
*/
private final String labelKeySize;
/**
* constructor with intialization of the code.
* @param initialCode keysize
*
*/
public KeySize(final int initialCode) {
this.code = initialCode;
this.labelKeySize = Integer.toString(this.code) + " bits";
}
/**
* retrieve the code.
* @return Code
*/
public final int getCode() {
return code;
}
/**
* returns the string for the key size.
* @return String key size label
*/
public final String getLabelKeySize() {
return this.labelKeySize;
}
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| public final class DigestAlgo {
/**
* algorithm code.
*
*/
private final int code;
/**
* algorithm string.
*/
private final String labelAlgorithm;
/**
* list of KeySize for the algorithm.
*/
private final KeySize[] listKeySize;
/**
* Constructor of the algorithm and its list of keysizes.
* @param c int code
* @param s string of the algorithm
* @param l list of keysizes
*/
public DigestAlgo(final int c, final String s, final KeySize[] l) {
this.code = c;
this.labelAlgorithm = s;
this.listKeySize = l;
}
/**
* access to the code.
* @return int code
*/
public int getCode() {
return this.code;
}
/**
* access to the label.
* @return String label
*/
public String getLabelAlgorithm() {
return this.labelAlgorithm;
}
/**
* @return array of keySize.
*/
public KeySize[] getListKeySize() {
return this.listKeySize;
}
} |
Je crée les instances dans une class static
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public final class Algorithm {
/**
* private list of digestAlgo.
*/
public static final DigestAlgo[] LISTDIGESTALGORITHM;
/**
* Constructor of the list of algorithms available.
*/
static {
LISTDIGESTALGORITHM = new DigestAlgo[2];
//RSA
KeySize[] rsa = new KeySize[2];
rsa[0] = new KeySize(2048);
rsa[1] = new KeySize(4096);
LISTDIGESTALGORITHM[0] = new DigestAlgo(0, "RSA", rsa);
//ECDSA
KeySize[] ecdsa = new KeySize[3];
ecdsa[0] = new KeySize(256);
ecdsa[1] = new KeySize(384);
ecdsa[2] = new KeySize(521);
LISTDIGESTALGORITHM[1] = new DigestAlgo(1, "ECDSA", ecdsa);
}
/**
* This constructor is private to avoid any instantiation of this class as it is a utility class.
* (there is no dynamic fields inside)
*
* As a matter of fact, this class can only be used in a static way as a library.
*/
private Algorithm() {
}
} |
Dans le jsp, j'ai mis ceci:
Code:
1 2 3 4 5
| <s:doubleselect cssStyle="width: 200px" doubleCssStyle="width: 200px"
name="algo" doubleName="paramGen"
list="listdigestAlgorithm" doubleList="listKeySize"
listKey="code" doubleListKey="code"
listValue="labelAlgorithm" doubleListValue="labelKeySize" /> |
Dans mon action.java, j'ai
Code:
1 2 3 4 5 6 7
| /**
* return Enumeration Algorithm.
* @return value of Algorithm.
*/
public DigestAlgo[] getListdigestAlgorithm() {
return Algorithm.LISTDIGESTALGORITHM;
} |
En vous remerciant de l'aide que vous pourriez m'apporter, car celà fait tout l'après-midi que je cherche.
Julien