Below is Java code that I am trying to get the user to pick from a list from a Inpit Dialoghowever I am trying to get the list of values from a view. Everything I try is failing.
Anyone know what I am doing wrong please…
Object choices = null;
pView = db.getView("LKERLPDF");
pDoc = pView.getFirstDocument();
while (pDoc != null)
{
String strGetProfileName = pDoc.getItemValueString("InDocName");
choices[intDocCount] = strGetProfileName;
intDocCount = intDocCount + 1;
pDoc = pView.getNextDocument(pDoc);
}
//Object choices = { “Choice 0”, “Choice 1”, “Choice 2”, “Choice 3” };
String strGetResult = (String) JOptionPane.showInputDialog(null, "Please make your choice...,", "User choices", JOptionPane.PLAIN_MESSAGE, null, choices, choices[0]);
Subject: one part or the other of your code is irrelevant to your question
and you should be able to determine which part is it. Debug your code. See whether the variable choices contains the value you expect. If not, the problem is in the code that sets it. If not, the problem is in the code that uses it.
It’s really not enough to say something fails. You need to say where it fails (on what line of code) and what it actually does do. Is there an error message in the console? If so, what message? Does your dialog display? If so, what do you see in it? How do you know it’s not working?
Subject: That was no help
of couse I debugged itthat is why I am asking for help
Subject: But you’re not revealing your findings.
You say “of course” you debugged it, but you have to understand, first, that it’s not “of course” for us. Anybody can post here, and more often than not they do so without, apparently, having done any work themselves to figure out the problem. So that is my default assumption.
You don’t tell us what you found out by debugging. You don’t tell us what it’s doing that you don’t like. Are we supposed to read your mind to find out all this useful information you know and don’t bother to say?
All right; here’s my answer. Your code to read values from the view is fine. The problem is that you’re misusing the showInputDialog method, giving it the wrong kind of input. I’m not familiar with that class, so I can’t be more detailed than that.
If the above does not solve your problem, we need more information about what you’re doing. If you’re not sure what information to supply, the C R I S P Y document might help you.
- Andre Guirard, IBM/Lotus Development
Useful blog: Best Practice Makes Perfect