V
VisionSet
In my model tier I often have constants declared like this:
private static final String[] STRING_CONSTANTS = new String[2];
private static final int CONST_A = 0, CONST_B = 1;
static {
STRING_CONSTANTS[CONST_A] = "Eh?";
STRING_CONSTANTS[CONST_B] = "Bee";
}
Then I can give the view tier (jsp) access to the array which it can iterate
over, using the array index to return selected <option>s.
This can then be matched up back in the model tier with simple switch
statement.
switch(myHttpParam) {
case CONST_A: // do A stuff
case CONST_B: // do B stuff
}
I can't see how it can be any simpler than this, but have never seen this
done.
Any views on this?
[Chris Smith, you answered a similar question from me a month or so back,
this is a more concrete example]
private static final String[] STRING_CONSTANTS = new String[2];
private static final int CONST_A = 0, CONST_B = 1;
static {
STRING_CONSTANTS[CONST_A] = "Eh?";
STRING_CONSTANTS[CONST_B] = "Bee";
}
Then I can give the view tier (jsp) access to the array which it can iterate
over, using the array index to return selected <option>s.
This can then be matched up back in the model tier with simple switch
statement.
switch(myHttpParam) {
case CONST_A: // do A stuff
case CONST_B: // do B stuff
}
I can't see how it can be any simpler than this, but have never seen this
done.
Any views on this?
[Chris Smith, you answered a similar question from me a month or so back,
this is a more concrete example]