Calling setter on backing bean via JavaScript / AJAX using JSF2

My application requires me to invoke a setter on a backing bean instance. I am trying to do this using the following javascript code:
var stateListWidth = document.getElementById("myform:stateListWidth");
stateListWidth.setAttribute("value", 100);
jsf.ajax.request(this, event, {execute: 'stateListWidth', render: 'stateListWidth'});and added a hidden field as follows:
<h:form id="myform">
<h:inputHidden id="stateListWidth" value="#{cityController.stateListWidth}"/>However my setter method is never called. I can see the parameters (myform:stateListWidth = 100) are POST'd to the server side, but not translated into a setter invocation. Any ideas if this is possible and how to do this.

I got it working. Had to specify the full ID of the element myform:stateListWidth rather then just stateListWidth.
var stateListWidth = document.getElementById(myform:stateListWidth);
stateListWidth.setAttribute("value", 100);
jsf.ajax.request(this, event, {execute: 'myform:stateListWidth', render: 'myform:stateListWidth' });I still wonder if there is a better way without using a hidden field to get this working?

Similar Messages

  • Value from backing bean in javascript confirm in 10.1.3

    Hallo,
    Please help
    I have 2 problems:
    Page with 1 record, where 8 items are updatable.
    In entity I 've a method where I set a value in bean. (BotId1 is one of these 8 updatebale items)
    What I expect: when I change a value in BotId1 the value of botId in ValiderenBotBean will be also changed
    public void setBotId1(Number value) {
    setAttributeInternal(BOTID1, value);
    EL.set("#{ValiderenBotBean.botId}",BotId.toString());
    My bean (session scope):
    package viewcontroller.pagedefs.produceren.backing;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    public class ValiderenBotBean
    private static Log log = LogFactory.getLog(ValiderenBotBean.class);
    private String botId;
    public ValiderenBotBean() {
    // accessors
    public void setBotId(String botId) {
    log.debug("setBotId : " + botId);
    this.botId = botId;
    public String getBotId() {
    log.debug("getBotId : " + this.botId);
    return this.botId;
    Op my generaten page I have the button:
    <af:commandButton actionListener="#{bindings.Commit.execute}"
    action="Commit" onclick="if (validateForm('dataForm')){return(confirm(#{ValiderenBotBean.botId} + 'la')}"
    rendered="#{(((jhsUserRoles['JDMR_PRD03']) or (jhsUserRoles['JDMR_PRD03'])) or (jhsUserRoles['JDMR_PRD03'])) or (jhsUserRoles['JDMR_PRD03'])}" textAndAccessKey="#{nls['SAVE_BUTTON_LABEL_KOPPELENPRODUCTIEGEGEVENS']}"
    id="KoppelenProductiegegevensSaveButton">
    <af:resetActionListener/>
    </af:commandButton>
    I get the following error:
    Foutdetails webpagina
    Gebruikersagent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.6; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1; AskTB5.6)
    Tijdstempel: Thu, 17 Feb 2011 13:54:46 UTC
    Bericht: Syntaxisfout
    Regel: 3744
    Teken: 1
    Code: 0
    URI: http://172.16.6.108:8988/demeter/adf/jsLibs/Common10_1_3_2_0.js
    The code from Common:
    3732 function _callChained(
    3733 a0,
    3734 a1,
    3735 a2
    3736 )
    3737 {
    3738 if(a0&&(a0.length>0))
    3739 {
    3740 if(a2==(void 0))
    3741 {
    3742 a2=a1.window.event;
    3743 }
    3744 var a3=new Function("event",a0);
    3745 a1._tempFunc=a3;
    3746 var a4=a1._tempFunc(a2);
    3747 a1._tempFunc=(void 0);
    3748 return!(a4==false);
    3749 }
    3750 else
    3751 {
    3752 return true;
    3753 }
    3754 }
    Problem nr.1:
    When I call the button I do not see any logging that indicate that the value is set in backing bean
    Workaround: I made item on my page depending on item where I put my code.
    Result: I have to press 2 times on my button to execute the button code. First time to make the validation and the second time the button code itself.
    Not nice. The validation is also slow.
    But ok:
    Problem 2:
    I still get the same error, I see logging of execution of my validation.
    There is also the difference between loggings is 2 cases:
    If I use
    onclick="if (validateForm('dataForm')){return((#{ValiderenBotBean.botId} + 'la')}"
    what I really want instead of
    onclick="if (validateForm('dataForm')){return'la')}"
    I get:
    17-feb 14:28:40 DEBUG (ValiderenBotBean) -getBotId : -1
    17-feb 14:28:40 DEBUG (ValiderenBotBean) -getBotId : -1
    It means that value is obtained correctly.
    But still the same error.
    If I put for test purpose
    the following code into my bean:
    public String getBotId() {
    log.debug("getBotId : " + this.botId);
    botId = "23";
    return this.botId;
    I do not get any error.
    Any ideas?
    Please help

    Thanks, Amit,
    I will try it tomorrow.
    Some remarkes:
    1. I need javascript for confirmation
    2. I really do not PPR. It takes so long. The user use the scanner to put the value into input items in order speed up the process. And now PPR...
    3. My transient attribute will depend on 8 items. Even more waiting process.
    What I really want is to execute my db function only 1 time "onclick" or "oncommit" and according to outcome of db-function ask user for confirmation of commit.
    I tried already to implement dialog from ADF with launchDialog function.
    But ReturnListener did not function while I launch the Dialog manually.
    Anna

  • Calling function from Backing Bean or JSP page

    We are on Jdeveloper 10.1.3.3.0, ADF Faces, JSF Faces .., Currently there is a function call from Javascript event (onmouseover) in the JSP page. I want to call this function from a backing bean or JSP page, as I have to pass some values to this function.
    For Ex., I have a function call like return submit('A','B','Test'); on the Javascript event (onmouseover) in jsp page. I want to remove this function from the javascript event and call from backing bean or jsp page to pass some values into the submit() function. I appreciate if anyone can give some example of how to call this function from backing bean or jsp page in the <SCRIPT> or <SCRIPTLET>
    Thanks,
    Ram

    A use case would be helpful so that we can get a better idea of what you want to do.
    As a general rule, there is no way to call a client side Javascript function from a backing bean, which is server side. However, there are ways to inject information from a backing bean into your Javascript call. For instance, I have an application that uses Google Maps API. It has an onload call to a Javascript function that builds the map and designates it's center point. The center point comes from a backing bean as latitude and longitude properties. So here is my body tag:
    <afh:body onload="initialize(#{backing_searchResults.latitude},#{backing_searchResults.longitude},#{searchCriteria.distance})"
              onunload="GUnload()">onload calls the Javascript function called initialize, and passes the latitude, longitude, and distance from the bean. Is the function really being called from my backing bean? No - the parameters are hard coded into the onload event code when the page is rendered. Does it do the job? Sure it does.

  • How to call popup from backing bean

    Hi,
    I have an application under jdev 11.1.1.1.0
    I am using the explorer template.
    I have my popups in one page and from another page i need to call these popups.
    I cannot use the <af:showPopupBehavior> because i am using the <af:setActionListener> in my command button.
    So in the action attribute I called my backing bean
    public String showDelBoxPopup() {
       FacesContext context = FacesContext.getCurrentInstance();
       ExtendedRenderKitService extRenderKitSrvc =
         Service.getRenderKitService(context,ExtendedRenderKitService.class);
       extRenderKitSrvc.addScript(context,"AdfPage.PAGE.findComponent('delBoxPopup').show()");
       return null;
    }But i always receive a null error.
    How can i call a popup in one page from another page using backing bean.
    Thank you in advance.
    Emile BITAR

    Hi,
    You can use <af:setActionListener> with <af:showPopupBehavior>, if you set triggerType="click" on the showPopupBehavior and contentDelivery="lazyUncached" on the popup to ensure the popup will be raised after setActionListener.
    I also don't understand what you mean by calling the popup from another page (is that page included as a region?), but if you say it works then your other option could be to bind the popup to the backing bean and use popup.getClientId() in your javascript.
    String script = "var popup = AdfPage.PAGE.findComponent(\"" + popup.getClientId(fc) +  "\"); popup.show();";Pedja

  • Call Plugin-Function with parameters via JavaScript

    Hi!
    I have following problem: I wrote a plugin for Illustrator CS2 in C++ and now I would like to call a function of the plugin from outside of illustrator (from a JavaScript).
    This can be done with the Actionsuite. But how could I then give some parameters to my function?
    For example:
    In the plugin, I have a function "void myFun(char * test)" and I want to call this function in JavaScript with test="Hello World" for example.
    The only possible way right now seems to write parameters into a file and open that file in the plugin to "receive" them.

    Hi,
    Could you send your plugin coding.
    Regards,
    Maria

  • Calling a function in Flash via JavaScript

    My project is in Flash CS3 ActionScript 2. I am using
    JavaScript elements in my project that are called within Flash. The
    following code placed on frame 1 of my main timeline goes to frame
    2 and displays the JavaScript element = that works. Here's the
    code;
    HS_Film_Button.onRelease = function ()
    gotoAndStop(2);
    flash.external.ExternalInterface.call("firehs");
    Now when on frame 2, I want the JavaScript "close button" in
    the element to go to frame 1 on my Flash main timeline. Right now
    what it does is closing itself in frame 2 of my Flash page, so I
    added a flash button in there to go to frame 1. Thus the need to
    double click to finally end up on frame 1. But I want the
    JavaScript element to do that in the first place!
    The real issue here is that the JavaScript element was once
    on my main single frame timeline but its performance (display speed
    and such) was greatly affected by my Flash Time and Date and Frame
    rate calculations. This JavaScript element is based on miliseconds
    and I suspect that my Flash file is based in seconds and that my
    Flash calculations are grabbed by the Browser and directing my
    JavaScript element.....Hey I am getting lost I hope you kind of see
    what I mean. Anyways, if I could just get rid of frame 2 all
    together and have some kind of coding that would eighther have
    Flash calculate in miliseconds rather than seconds????? to match my
    JavaScript one.... Or codify JavaScript so that when called it
    would take over and tell the Browser to change its calculations
    rates?
    If you wish please have a look at the Forum topic postings
    where all of this is evolving with questions examples and
    answers....This link gets you right in the posting.
    Highslide
    JS Forum
    This is where Flash meets JavaScript! I need help please.
    Kind Regards
    Pierre

    Hi, Since your reply I have been trying to follow your
    direction and found a couple of things,
    My flash site is based on the AC_FL_RunContent JS file
    not the
    <object classid= ..............>
    <param name="allowScriptAccess" value="
    sameDomain" /> which element in bold should probably be
    repalced by "always" for the externalinterface addCallback() to
    work properly. The question being what code I have to ad to the
    AC_FL_RunContent JS file for allowScriptAccess.......
    quote:
    ExternalInterface is similar in functionality to the
    CallFrame() method but is more flexible and more generally
    applicable. ExternalInterface is the preferred method for
    JavaScript–ActionScript communication in Flash Player 8 and
    later.
    So I see I could use externalinterface addCallFrame() for
    achieving Javascript to ActionScript communication ; when
    Javascript close button is pressed Flash goes to frame 1........
    The latest hint I got from Highslide JS was to add the
    following in the Head section;
    <script type="text/javascript">
    hs.Expander.prototype.onBeforeClose = function (sender) {
    return confirm("Do you really want to close this nice
    image?");
    </script>
    The line in bold should be the code to call to go to frame 1
    in Flash and the onBeforeClose should probably be onAfterClose.
    Anyways, I am completely lost in space = could you really hep
    me out with this code by code and where to put those exact
    codes.....please
    Pierre

  • Is it possible to call a custom method in App Module from a backing bean?

    I would like to know if a custom method in App Module can be called from inside a backing bean.
    I am not sure if it is logically right to call, from a backing bean, a custom method in App Module. But would like to know if that makes sense or if it is possible.

    Hi..
    Yes it is possible.You have to add that method for client interface of AppModule.Now you can see that method in Data Controls(Refresh the data control). To call this method using bean it should add as method action to bindings(Click Bindings>+>methodAction>and Create action binding).
    Now you can call this method in bean class.
    Check following example use this concept to execute view criteria
    http://adf-lk.blogspot.com/2011/05/oracle-adf-create-view-criteria-and_4727.html

  • Error when I call a method of AppModule from a backing bean.

    I use Jdeveloper 10.1.3.0.3 EA.
    In my application I have created ApplModule and UsrView(for my table USR).
    I have a login page (login.jsp and the backing login.java) with 2 fields userName and password and an ADF Faces Core command button (cmdCheckPass) and the method cmdCheckPass _action() for the click event .
    The problem is that I can’t call method testPassword(userName, password) which is written in AppModule. (I get error:
    javax.faces.FacesException: #{backing_login.cmdCheckPass_action}: javax.faces.el.EvaluationException: java.lang.NullPointerException) from line:
    answer = app.testPass(st1,st2);
    The code is as follows:
    public String cmdCheckPass_action() {
    String answer="";
    String mes = "";
    String st1=this.getInputText1().getValue().toString();
    String st2=this.getInputText2().getValue().toString();
    AppModuleImpl app = new AppModuleImpl();
    answer = app.testPass(st1,st2);
    if (answer == "OK") {
    return "toMain";
    } else {
    answer = "";
    mes="Invalid username, password !!!";
    FacesContext.getCurrentInstance().addMessage(null,new FacesMessage(mes));
    return answer;}
    I don’t know if theoretically is right to call, from a backing bean, a custom method of AppModule.
    Can I have any help on this?
    Thanks in advance,
    Panos

    Some quick ideas:
    Is the clip the same NTSC/PAL standard as the project you are importing it to?
    Have you tried to rename the offending clip (do NOT rename any clips inside the iMovie /Media folder!!).
    How much free space do you have on the iMovie project volume -- what is the size of the imported clip?

  • Set label of adf command button from backing bean

    How can we set the label of a command button from a backing bean using EL?
    Is it : <af: commandButton text="#{bindings.email.label}" action.....

    hi,
    create one string and generate accessor for it.
    then in jspx, like this
    text="#{PrintData.label}"
    you can have the label in this way from backing bean.
    private String label;
    public void setLabel(String label)
    this.label = label;
    public String getLabel()
    label = "test";
    return label;
    or else, through binding property of the command button, you can set it in the backing bean.
    hope this is useful for you.

  • Shift focus to new tab opened in backing bean

    Hi,
    I have a tree whose nodes are displayed as command links. On click of these links I have corresponding method action in my backing bean that generates the URL which is opened as a new tab on the browser. Below is what my method looks like in the backing bean.
    FacesContext ctx = FacesContext.getCurrentInstance();
    ExtendedRenderKitService erks =
    Service.getService(ctx.getRenderKit(), ExtendedRenderKitService.class);
    String url = "window.open('http://www.google.com', '_blank')";
    erks.addScript(FacesContext.getCurrentInstance(), url);
    We are using IE7 and the problem is that the browser opens a new tab but doesn't shift the focus to the new tab. I added a simple af:goLink on my page with the targetFrame as"_blank" and it works fine. But its the script that I'm calling from my backing bean doesn't behave in the same way. We cannot ask the users to change their browser settings.
    Jdev 11.1.1.5.0.
    Thanks

    Thanks Frank,
    Since I'm generating this URL from the backing bean I did change the script in my backing bean to
    ExtendedRenderKitService erks = Service.getService(ctx.getRenderKit(), ExtendedRenderKitService.class);
    erks.addScript(FacesContext.getCurrentInstance(), "window.open('http://www.google.com', '_blank').focus();");
    But that also didn't move the focus to the new tab. When I embed the same string in the javascript on the page(jspx) it works fine.

  • Backing bean properties not getting updated

    I have an input text in my JSP page and it is component-bound to backing bean. The problem is that when I change value of the InputText in the JSP, the value is not getting updated in the backing bean.
    Here is the InputField definition in JSP page.
    <h:inputText binding="#{backing_employeeEdit.firstName}"
    id="firstName"/>
    and here is the setter in backing bean
    public void setFirstName(HtmlInputText inputText1) {
    this.firstName = inputText1;
    Pls note that there is no validation errors because the page navigates successfully. The only problem is that new value is not updated.

    I don't know, wht exactly u wants to do... Here is java code and is working fine for me...
    Emp.java
    public void action() {
         System.out.println(inputText.getValue());
         Emp tt = new Emp();
         inputText.setValue(inputText.getValue().toString()+"bilal");
         tt.setInputText(inputText);
         System.out.println(inputText.getValue());
    JSP...
    <f:view>
    <h:form>
    <h:inputText binding="#{emp.inputText}" />
    <h:commandButton value="submit" action="#{emp.action}" />
    </h:form>
    </f:view>
    faces-config file contents....
    <managed-bean>
              <managed-bean-name>emp</managed-bean-name>
              <managed-bean-class>
                   com.nous.application.Emp
              </managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    Here scope has to be session, otherwise u will lose old value...

  • OrionRemoteException: Second thread call to stateful session bean

    What happen for "com.evermind.server.rmi.OrionRemoteException: Second thread call to stateful session bean".
    I am using JSP/Servlet/EJB and OC4J. When user click the JSP page button to fast, sometimes the error will appear, and then the OC4J will stop, I need to restart the OC4J.
    I am using standlone OC4J 9.0.3.0.0
    Thanks in advance,
    Perry

    Have you cached the remote object you obtained for the stateful session beamn and are reusing the same object on subsequent requests from the JSP page? So in effect, you are making a second call to the bean before the first method call completes?
    Without knowing anything about what you are doing or how you app is constructed, you may want to set some form of flag for the user session to indicate whether the bean is in use, which you can check before using the bean in requests. When the bean method call completes, open the gate again. If the bean is in use, return a nice message to the user telling them to hold off for a short while.
    -steve-

  • Back bean access entityImpl file?

    Hello Guru,
    Just a quick question:
    Can I use back beans to access entityImpl java file?
    --If yes, how to initiate the entityImpl file, I assue EntityImpl entity= new EntityImpl() is not the right option.
    --If no, what's the work around?
    thanks.

    That's a nice demonstration of how to get a DBTransaction object (presumably to execute some straight JDBC code) from your backing bean without a discussion of when doing that is a good idea (i.e., nearly never - database code belongs in the model layer, not in the view layer). Without a clear description of what the OP is trying to do, I don't think anyone can give a reasonable solution, other than a guess. However, I can say that doing JDBC calls in your backing bean is generally "frowned upon" as it breaks the MVC separation of concerns principle. If you need to do a JDBC call, put it in a service method in your AM and call it that way.
    Best,
    John

  • Get selected row from af:table in backing bean

    Hi Experts,
    I have an af:table and i have seelctBoolean check box in that. If the user select 'x' nos of check boxes i want to display the row data of those selected rows. Can somebody help me in getting the selected row data in backing bean?
    I am using adf faces and backing bean.
    JSF Code:
    <af:table value="#{demo.partyList}" var="row"
    rowBandingInterval="0" binding="#{demo.t1}" id="t21"
    rowSelection="multiple">
    <af:column>
    <af:selectBooleanCheckbox text="#{row.person_first_name}"
    label="Label 1" id="sbc1"
    />
    </af:column>
    <af:column>
    <af:inputText value="#{row.emirate}"/>
    </af:column>
    </af:table>
    <af:commandButton action="#{demo.print}" text="Print"/>
    BB Code:
    public void print(){
    // what code to write here
    }

    This is the code
    JSF ::
    <af:table value="#{createOpportunity.dataList}" var="row"
    rowBandingInterval="0" binding="#{demo.t1}" id="t21">
    <af:column headerText="Model">
    <af:selectBooleanCheckbox text="#{row.modelRange}"
    label="Label 1" id="sbc1" value="#{row.selected}"/>
    </af:column>
    <af:column headerText="Description">
    <af:outputText value="#{row.description}"/>
    </af:column>
    <af:column>
    <af:inputText value="#{row.quantity}"/>
    </af:column>
    </af:table>
    <af:commandButton action="#{createOpportunity.print}" text="Print"/>
    Backing bean Code::
    public void print () {
    selectedDataList = new ArrayList<ModelDescription>();
    for (ModelDescription dataItem : dataList) {
    if (dataItem.isSelected()) {
    System.out.println(dataItem.getQuantity());
    selectedDataList.add(dataItem);
    // dataItem.setSelected(false); // Reset.
    Clicking on the print button shows "We have 0 rows selected"
    Thnks for ur replies guys ..
    Edited by: Wannabe Java Guru on Mar 9, 2011 1:43 AM

  • JSF EL: referencing programmatically generated backing beans

    Hi all,
    I create backing beans in Java code using the ValueBinding class:
    for(Question q : questions){
      ValueBinding vb = FacesUtilities.createValueBinding("#{requestScope.questionBean" + question.getId() + "}");
      vb.setValue(FacesContext.getCurrentInstance(), new QuestionBean(question));
    }No problem so far, but how can I reference these backing beans dynamically using the JSF EL?
    <c:forEach var="question" items="#{questionListBean.questions}">
      <h:outputText value="#{#{requestScope.questionBean}#{question.id}.type}"/>
      <h:outputText value="#{requestScope.questionBean#{question.id}.type}"/>
    </c:forEach>None of them seem to work because nesting expressions is not an option. Anybody got a clue?
    Thanks in advance!
    Kind regards,
    Dirk

    Make a List of QuestionBean objects and place that in the request scope instead.

Maybe you are looking for

  • BI Publisher: not able to see the xml data after creating a data model

    I am learning BI publisher and trying to create a report data model I created a new data model from the report tab, use query builder, able to see the results. Then i save it and try to launch XML view from clicking View . I am getting unexpected exc

  • Licensing my application on a target computer

    I built an application and intend to sell it for use in a target computer. How can I incorporate a parallel key for use with my application? Or are there other ways I can license my product? Help is greatly appraciated. Thanks.

  • SPA9000 for Newbie

    Hi all, I am thinking of buying the SPA400 and SPA900 for my home business. I have never used a PBX before. There are a few questions I would like to ask: 1) We have only one PSTN line. Do we need at least two lines/phone numbers in order to forward

  • Gather Stats on Newly Partitioned Table

    I partitioned an existing table containing 92 million rows. The method was using dbms_redefinition, whereby I started the redef and then added the indexes and constraints last. After partitioning, I did not gather stats on any of the partitions that

  • IPhone 4S top button..

    My iphone top button is jam and stucked today morning, My phone is bought in singapore, but now i recently in malaysia. I wanna ask that Apple store can change a new one for me in malaysia? or i have to back to singapore? Thank you.