I need to execute some backend methods based on CSS classes of <html> or <body>.
To determine if the <html> tag has a CSS class name "someClass" I used JQuery $("html").hasClass("someClass"). Then I wrapped it in a function with return values
function hasSomeClass() {
    if ($("html").hasClass("someClass")) {
        return true;
    } else {
        return false;
    }
}
Then I executed my function in my controller via
RequestContext.getCurrentInstance().execute("hasSomeClass();");. But 
RequestContext.getCurrentInstance().execute()'s return type if void.
Q: How can I send the return value of my javascript function to my backend bean function?
I can think of some options, but I would like to pass the return value as parameter to my backend method directly instead of these walkarounds:
- Use a global javascript variable as parameter
- Use a hidden input field
Edit: About other solutions:
I also tried this solution, but I don't know where to put remoteCommandFunctionName([{name: 'name1', value: 'value1'}, {name: 'name2', value: 'value2'}]);. Do I put it in the <script> tag? Do I wrap it with a function? Because if I System.out.println(name1); I receive null.
My quick fix with weird behaviour:
<h:body onload="hasSomeClass() ? #{controller.onDoSomething('true')} : #{Controller.onDoSomething('false')}" > returns true and false a millisecond apart, although <html> has someClass.
