The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by jroysdon]

Tony,

I have a quandry I've not been able to get past, perhaps it is just a mental
block. I have a categorized view, the first two columns being categories. The
first column is unique and is derived from a single value field. The second
column, however, is derived from a multi-value field, allowing values to show
up in more than one category. My problem is getting the current category for
that view entry. If I get the field value, I get just the first value. Is
there a way to get the value of the category from the view entry collection or
the view entry itself?

Thanks,
Jim
import-bot (20211) [Avatar] Offline
#2
Re: View Entry Collections and Categories
[Originally posted by aspatton]

When you traverse a viewentry collection, you can determine if an entry (row)
is a category or not (property). You should be able to set a flag variable to
the category value and reset this value when a new category is encountered.

Tony.
import-bot (20211) [Avatar] Offline
#3
Re: View Entry Collections and Categories
[Originally posted by jroysdon]

I've gotten that far and it works fine. Let me see if I can explain further.
Let say the view looks like this:

Technology
LotusScript
Jim Roysdon
Tony Patton
JAVA
Tony Patton

In the technology field on your record, it is holding two values (LotusScript
and JAVA). When I try to grab the field, or the entry, I get either the first
value (LotusScript) or both values (in the form of an array or vector). I need
to get that second or third or forth value, depending on the category it is
under.

Hope this helps,
Jim
import-bot (20211) [Avatar] Offline
#4
Re: View Entry Collections and Categories
[Originally posted by aspatton]

Yes, what I was describing....set a flag variable when encountering a category
.. let's say LotusScript. Set the variable, read the next entry (which is Jim
Roysdon), and use the flag variable to access its value. Does that make
sense?

Tony.
import-bot (20211) [Avatar] Offline
#5
Re: View Entry Collections and Categories
[Originally posted by jroysdon]

Yes, sorta. I just checked back in to see your response after getting it. Here
is my solution using view entries from a collection (in JAVA):

while (entry != null)
{
if (entry.isCategory())
{
pos = entry.getIndentLevel() + 1; // Add 1 to offset the zero
v = entry.getColumnValues(); // v is a vector, an array of sorts
String cattxt = v.elementAt(pos).toString();
if (cat.equals(cattxt)) // check to see if Category has already been printed
{
rti.addTab(pos);// Yes? Add a tab
}
else // No, print the status
{
cat = cattxt;
rti.addTab(pos);
rti.appendStyle(header);
rti.appendText(cat);
rti.addNewLine(1);
}
}
else
{ ... get and process the real document stuff....}

It works and is fairly clean. It is setting a flag for the last used and
reseting it when it changes. Thanks for being there. I hate posting sometimes,
because usually these problems stick in the back of my mind and refuse to
leave until I solve them. This will lead me to either rework it a number of
times, or just to go insane! Of course, I am trying to learn JAVA for a number
of reasons, and this has been a good exercise.

Thanks again,
Jim
import-bot (20211) [Avatar] Offline
#6
Re: View Entry Collections and Categories
[Originally posted by aspatton]

Good job.

Tony.