This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Apr 21, 2011, 5:19 PM
94 Posts
topic has been resolvedResolved

Now that I've set my innerHTML value with csjs, how do I get it with ssjs?

  • Category: Custom JSF code (Eclipse IDE)
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 4
I'm creating an array of values with csjs and am storing it in an edit box with
 
field.innerHTML = newarrayvalue;

Now, I need to use that array in ssjs code - how do I get the fields value?  getComponent getValue() doesn't work.
 
OR

Maybe I'm going about this wrong way - how else can I store an array with csjs and then pick it up with ssjs?
Apr 21, 2011, 6:54 PM
4 Posts
Re: Now that I've set my innerHTML value with csjs, how do I get it with ssjs?
You cannot access innerHTML with ssjs. You'll need to write the array values to a temporary storage container (a field) first on your submit/save/whatever button. If your writing to innerHTML then I'm assuming your field is not a real field or its a field that isn't in edit mode.

Create a temp field and when it comes to your submit operation write some CSJS code that gathers all the values and populates a css hidden field:
 
var tmpArr = arrayYourTringToAccessViaSSJS ;
var hideFld = document.getElementById("hiddenFld") ;
hideFld.value = tmpArr.join(";"); // semi-colon is the multivalue field sperator
 
Then you can write some SSJS code on to grab the field values...
Apr 21, 2011, 7:12 PM
94 Posts
Re: Now that I've set my innerHTML value with csjs, how do I get it with ssjs?
hmmm... well, here's the context - I have a repeat control that displays a list of documents.  The csjs is used so the user can select/deselect documents in the list.  I store the id of the document in an array using innerHTML because when I tried to store it with field.value = arrayval, the field didn't show the result on the page.  The "field", btw, is an edit box.  I'm using display:none to hide it from the user.
 
The select/deselect must use csjs because I don't want to make a trip to the server.  I was originally storing the id's in a sessionScope var, but it was taking 30 seconds to update it with each click.  The csjs is practically instant if I can only get the id's for processing from the serverside.
 
I just tested it again...  field.value = arrayval doesn't do anything.  Am I missing something?
 
btw - The page does not have a document data source.  The edit box for storing my array is just defined with javascript default value "".
Apr 21, 2011, 7:46 PM
31 Posts
Re: Now that I've set my innerHTML value with csjs, how do I get it with ssjs?
Bob, I had to do the same thing you're trying to do.  Neil XXX's advice is basically what I did in CSJS.  I used a hidden input control bound to a viewScope variable though instead of an edit box to store the UNIDs in it.  In my case, both the CSJS & SSJS were triggered from the same button -- the CSJS will run first & populate the hidden input field.  Then the SSJS will get it back out & can do whatever you need to with it.
 
-- Hidden Input Source:
        <xp:inputHidden id="yourHiddenInput"
            value="#{viewScope.pickedUNIDs}">
        </xp:inputHidden>
 
-- CSJS:
var unids = XSP.getElementById("#{id:yourHiddenInput}");
var delUNIDArray = new Array();

/* Save the UNIDs selected */

var a = document.getElementsByName("delThis");
for(var x=0;x<a.length;x++){
      //alert("checkbox[" + x + "] checked = " + a[x].checked + " value = " + a[x].value);
      if ( a[x].checked == true ){
          //alert("in checked = true [" + x + "]");
          delUNIDArray.push(a[x].value);
      };
};

var unidString = delUNIDArray.join(', ');
//alert( "UNIDs selected = " + unidString );
unids.value = delUNIDArray;
 
-- SSJS:
var aUNIDArray = new Array();
aUNIDArray = @Unique(@Trim(@Explode(getComponent("yourHiddenInput").value)));
viewScope.pickedUNIDs = @List(aUNIDArray);

Apr 21, 2011, 8:19 PM
94 Posts
YES! That worked!
I changed my edit box to a hidden input control bound to a scoped var and now using field.value=arrayval works just as it should.  I can also get the value back out with getcomponent getvalue() on the server side.
 
Thank you!
 
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal