Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5986667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:42:17+00:00 2026-05-22T22:42:17+00:00

Currently, I am working on a web application that uses draw2d library to draw

  • 0

Currently, I am working on a web application that uses draw2d library to draw shapes and charts. On the server side I am using Java(JSF).

I can say that 95% of this application is just pure JavaScript. I like to be able to send Ajax requests from inside my JavaScript with no need of using hidden fields such as <f:inputText> (perhaps using jQuery Ajax components?).

I tried to hack around this by adding different hidden JFS component and jsf.ajax.request, but for whatever reason they are not very reliable and sometimes they don’t send the ajax request.

Any suggestion? Also, about jQuery, I am not sure how to process the request on the server side.

Answer: I ended up using what Dave suggested. I previously tried to use jsFunction from this link, but I got error. Apparently, the problem is , which is not yet implemented in Richfaces 4. However, if you use , as dave mentioned it works perfectly.

One more point, the beans didn’t work for me as Dave potsed. I had to change it as follows:
@ManagedBean(name = “jsFunctionBean”)
@SessionScoped
public class JsFunctionBean {

/**
 * Test String name
 */
private String name;

public String getName() { return this.name; }
public void setName(String name) { this.name = name; }

/**
 * Test boolean
 */
private boolean test;
public boolean getTest() { return this.test; }
public void setTest(boolean test) { this.test = test; }    

/**
 * Action Method 
 * 
 * @return
 */
public String getActionMethod() {
    return null;
}

public String actionMethod(){
    this.test = true;
    this.name = "Dave";
    return null;
}
}

I am not sure why this is the case, but if I remove getActionMethod or actionMenthod I would get error!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:42:18+00:00Added an answer on May 22, 2026 at 10:42 pm

    If you are up for a third party library Richfaces a4j:jsFunction offers the ability to invoke a server side method with a javascript function as well as the ability to pass a object serialized as json back to a callback function:

    <h:form id="form1" prependId="false">
    
        <a4j:jsFunction 
            name="submitApplication"
            action="#{jsFunctionBean.actionMethod}"
            data="#{jsFunctionBean}"
            oncomplete="processData(event.data)" 
            immediate="true">
        </a4j:jsFunction>
    
        <script type="text/javascript">
            //example callback function
            function processData(data) {
                alert(data.test);
                alert(data.name);
            }
    
            //call the ajax method from javascript
            submitApplication();
        </script>
    
    </h:form>
    

    And your Bean:

    @ManagedBean(name = "jsFunctionBean")
    @SessionScoped
    public class JsFunctionBean {
    
        /**
         * Test String name
         */
        private String name;
    
        public String getName() { return this.name; }
        public void setName(String name) { this.name = name; }
    
        /**
         * Test boolean
         */
        private boolean test;
        public boolean getTest() { return this.test; }
        public void setTest(boolean test) { this.test = test; }    
    
        /**
         * Action Method 
         * 
         * @return
         */
        public String getActionMethod() {
            this.test = true;
            this.name = "Dave";
            return null;
        }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on an web application that uses ASP.NET 2.0 framework. I
I am currently working on a web application that uses PHP and MySQL, but
I'm currently working with a part of my application that uses Dynamic Web User
I have a web application that I am currently working on that uses a
I'm currently working on a web application in ASP.NET that displays reports (created with
I am currently working on converting an existing web application to support an additional
I'm working on a Rails web application, and it's currently being used by some
In the application I'm working on porting to the web, we currently dynamically access
I'm currently working on a WebSphere 6.1 Web Project. In my java code, how
I am working on splitting out an existing, working application that I currently have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.