Mahmoud Saleh
Mahmoud Saleh

Reputation: 33635

Set bean property from jsf page using javascript variable

i am using icefaces 3, and there's a bug in some components in binding it to a bean property, so i am trying to do that manually, so i was wondering about the best way to set bean property from jsf page manually, using a javascript variable.

i want to do something like:

<script type="text/javascript">
          //<![CDATA[    

        function setPopupValues() {

            var onSuccess = document.getElementById('myForm:onSuccess_Sel');
            #{myBean.onSuccessPage}=onSuccess.value;
        }

           //]]>     
       </script>

<h:commandButton  value="Save" action="#{myBean.save}" onclick="setPopupValues();"></h:commandButton>

Upvotes: 0

Views: 6484

Answers (1)

BalusC
BalusC

Reputation: 1109874

If the input is in the same form which is been submitted, then you can also just extract it from the ExternalContext#getRequestParameterMap().

String value = externalContext.getRequestParameterMap().get("myForm:onSuccess_Sel");

I would however fix that component value binding soon or at least report it to ICEfaces, if it's ICEfaces specific.

Upvotes: 1

Related Questions