Question on getComponent(fieldname).getValue();

I am building an app to be able to compare different applications (maybe one day it will become an appstore (used internally) but for now it’s definitely a catalog).

Basically you can turn on/off checkboxes and a table will be updated with a summary of corresponding applications. What happens in the background is that I perform a FT search, check which documents  match the selected items (fieldnames, values = ‘Yes’) and return a collection of documents.

Works great with one group of checkboxes, untill I thought to organize them into several groups (security, document management, messaging etcetera).

I use the getComponent(fieldname).getValue() function. This works fine, but I wonder what it returns actually. I assume an array.

However if I try to merch/join two result arrays via the concat() method it throws up an error.

My code looks like this:

var selectedFilter1 = getComponent(“checkboxgroup1”).getValue();
var selectedFilter2 = getComponent(“checkboxgroup1”).getValue();
var selectedFilter = selectedFilter1.concat(selectedFilter2);

What am I doing wrong? Thanks in advance, your help is much appreciated!

Advertisements

4 thoughts on “Question on getComponent(fieldname).getValue();

  1. Paul Withers 2010-July-8 / 2:08 pm

    I think it returns an array if multiple values, a string if one, and perhaps a blank string if nothing is selected. Could you use var selectedFilter1 = @Text(getComponent(“checkboxgroup1”).getValue()). This will get a string or a string separated by commas if it was an array? Then you can combine the variables and do an @Explode to get them back into an array.

  2. Tim Tripcony 2010-July-8 / 3:06 pm

    You can use typeof to determine the return value’s type if you want to find out exactly what Domino is treating it as (i.e. string, object… java.util.Vector…).

    Also, if you post the error it’s throwing, that would give us more insight into exactly why it’s upset. 😉

  3. Patrick Kwinten 2010-July-9 / 10:36 am

    so far I get the

    ‘selectedFilter1’ is null and cannot be accessed as an array.

    Somehow this made it work:

    var selectedFilter1 = new Array();
    selectedFilter1 = getComponent(“filtersecurity”).getValue();

    var selectedFilter = new Array();
    checkvalue = selectedFilter1 ;
    if (checkvalue != 0 ){
    var selectedFilter = selectedFilter.concat(selectedFilter1);
    }

  4. Tommy Valand 2010-July-12 / 10:01 am

    You could simplify your code down to something like this:
    var selectedFilter1 = getComponent(“checkboxgroup1″).getValue();
    var selectedFilter2 = getComponent(“checkboxgroup2″).getValue();
    var selectedFilters = @Trim( [ selectedFilter1, selectedFilter2 ] );

    @Trim keeps 0 (zero), and trims empty strings, null and undefined. If you also want to get rid of zeroes, then you’d need more code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s