Ability to 'act' on numerous check boxes that have been checked

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Ability to 'act' on numerous check boxes that have been checked

mepknapp
I have set up an action that will see that a check box has been clicked in one control area and post a value in a different control area.  Unfortunately, it only works for 1 clicked item.  Doesn't matter which 1 is clicked.  As soon as I check the 2nd box, the 2nd object becomes blank.  When I uncheck all extra boxes and leave 1 checked, then the 2nd object now displays what I want again.

So how can I account for all checked boxes in a database and action combination to update information in another object.
Reply | Threaded
Open this post in threaded view
|

Re: Ability to 'act' on numerous check boxes that have been checked

Alessandro  Vernet
Administrator
Mary,

Based on other information you sent by email, I think this is due to the way you are using those values from a <sql:param type="xs:string" select=""/> in a database service. The "value change" action will run every time a check box is checked. However, <sql:param type="xs:string" select=""/> will be replaced by the space separated list of the checked values, giving you "prog_code IN 'v1 v2'", while I imagine you'd like "prog_code IN ('v1', 'v2')". I think the easiest way would be to use a function in your database that splits a string into a sequence that you can in an IN clause. Do you know if such a function is available for your database?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Ability to 'act' on numerous check boxes that have been checked

mepknapp
Hi Alex,

I can create this function.  

So the syntax for the function would be:
        Fn_SpaceToCommas(<sql:param type="xs:string" select=""/>)

So the resultant query syntax would be:

        Where prog_code in '(' || Fn_SpaceToCommas(<sql:param type="xs:string" select=""/>) || ')'

Thanks
Mary

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Alessandro Vernet
Sent: Saturday, January 11, 2014 2:14 AM
To: [hidden email]
Subject: [orbeon] Re: Ability to 'act' on numerous check boxes that have been checked

Mary,

Based on other information you sent by email, I think this is due to the way you are using those values from a <sql:param type="xs:string" select=""/> in a database service. The "value change" action will run every time a check box is checked. However, <sql:param type="xs:string" select=""/> will be replaced by the space separated list of the checked values, giving you "prog_code IN 'v1 v2'", while I imagine you'd like "prog_code IN ('v1', 'v2')". I think the easiest way would be to use a function in your database that splits a string into a sequence that you can in an IN clause. Do you know if such a function is available for your database?

Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
View this message in context: http://discuss.orbeon.com/Ability-to-act-on-numerous-check-boxes-that-have-been-checked-tp4657838p4657846.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Ability to 'act' on numerous check boxes that have been checked

mepknapp
I tried using Oracle's built-in function replace... and it still didn't work:

where prog_code in '('''||replace(<sql:param type="xs:string" select=""/>,' ',''',''')||''')';
Reply | Threaded
Open this post in threaded view
|

Re: Ability to 'act' on numerous check boxes that have been checked

Alessandro  Vernet
Administrator
Hi Mary,

With Oracle, you can split a space separated string into a set of rows that you can use in an IN clause with:

  in (
    select regexp_substr('SMITH ALLEN WARD JONES','[^ ]+', 1, level) from dual
    connect by regexp_substr('SMITH ALLEN WARD JONES', '[^ ]+', 1, level) is not null
  )

Source: https://blogs.oracle.com/aramamoo/entry/how_to_split_comma_separated_string_and_pass_to_in_clause_of_select_statement

And here is a form I created to test this:
https://gist.github.com/avernet/8483487

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Ability to 'act' on numerous check boxes that have been checked

mepknapp
hmmmm.....  I was kind-of expecting an xpath expression to perform the counts from numerous objects.  I'm puzzled on how to call this as a validation.  
Reply | Threaded
Open this post in threaded view
|

Re: Ability to 'act' on numerous check boxes that have been checked

Alessandro  Vernet
Administrator
Mary,

I'm not following you. We haven't been talking of counting objects, but of using the values corresponding to checkboxes in an IN clause of a SQL query you're sending to Oracle. Am I missing something?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Ability to 'act' on numerous check boxes that have been checked

mepknapp
Sorry Alex, the database query sent in the example was performing a count so I thought it didn't apply to this question.  I will continue to play with this to see if I can get it to work as hoped.

Thank You.
Mary
Reply | Threaded
Open this post in threaded view
|

Re: Ability to 'act' on numerous check boxes that have been checked

mepknapp
Alex,
The example given works great for 1 item that has been clicked as a radio button.  The area being referenced is a checkbox object, so need it for numerous boxes that have been checked.  Worked on the checkbox piece yesterday to no avail.

I am now focusing on the below issue, which has been prioritized higher…
 Jan 10, 2014; 5:26pm
How to validate the count from more than one object on the form

Any ideas on how to solve this one.
I appreciate all your help!
Mary
Reply | Threaded
Open this post in threaded view
|

Re: Ability to 'act' on numerous check boxes that have been checked

Alessandro  Vernet
Administrator
Mary,

Are you referring to the example I linked to earlier in this thread? I.e. https://gist.github.com/avernet/8483487. I am re-testing this now, and it works for me, and uses all the values from the B control in the IN clause of the query. Are you seeing something different?



Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet