PDA

View Full Version : Set list elements on UserInputPanel at run time



eldada
05-20-2003, 01:18 AM
I would like to be able to set the List items at run time.
I read a text file, and each line in it should be a List item. Can it be done with the UserInputPanel?

eldada
05-20-2003, 09:14 AM
To extend my question,
Can I create a custom class that extends UserInputPanel and by that create, modify and remove controls on the fly?

I would love an example for this...

afreed
11-11-2003, 10:04 AM
This doesn't do everything you want, but it is a start. This modifies list entries at runtime. So far, you can't dynamically add to the list. You have to have existing items in the list (I use blank items), and this code modifies the display name and value for them. I'd be very interested if anyone improves this code.

// "targetBeanID" is the beanid of your UserInputPanel.
WizardBean mywizard = getWizardTree().findWizardBean(targetBeanID);
int numEntries = choices.length;

UserInputPanel uip = (UserInputPanel) mywizard;
UserInputField [] uif = uip.getFields();

//index is the position on the UserInputPanel
// index is 0-based, first field is 0, second is 1, etc.
UserInputFieldChoice[] choices = uif[index].getChoices();

//Process results file, populate choices in ISMP list
//"outputFile" was created previously, with alternating lines
// of values and display names
FileReader reader = new FileReader(outputFile);
BufferedReader in = new BufferedReader(reader);
String line = "";
int idx=0;
while (null != line && idx < numEntries) {

line = in.readLine().trim(); choices[idx].setValue(line);
line = in.readLine().trim(); choices[idx].setDisplayName(line);
idx++;
}

in.close();

UserInputFieldChoice[] newChoices = new UserInputFieldChoice[idx];
int newIdx = 0;
while( newIdx < idx ){
newChoices[newIdx] = choices[newIdx];
newIdx++;
}

uif[index].setChoices(newChoices);

gigistan
01-09-2004, 11:27 AM
Hi.

Does this works on "queryExit" too?

Thank you.

P.S. After queryEnter() call, the ISMP runtime environment calls a method for initializing the graphical components (on 4.5 was initialize()). After these components are created, how can you change their values on queryExit() ????? e.g you need to update a label's value to inform the user about an error that occured during queryExit call?
Recreating the new UserInputField[] and this.setFields(...) is enough?
This will refresh the graphical interface? Probably not.
How this can be done if you cannot access the instance of the panel graphical implementer (e.g. swing)?

Again, thanks.