DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > AJAX in Apache Wicket

AJAX in Apache Wicket

In this article, I discuss some of the advantages of using AJAX in Apache Wicket. Read on to learn more.

Jayashree Kulkarni user avatar by
Jayashree Kulkarni
·
May. 11, 16 · Web Dev Zone · Opinion
Like (3)
Save
Tweet
4.20K Views

Join the DZone community and get the full member experience.

Join For Free

First, a bit about JavaScript: JavaScript (aka Mocha, aka LiveScript, and many other names) is a client-side (i.e. the browser) scripting language. That means it takes the burden off of processing data from your server thus making it more responsive.

Just as there are many advantages of using JavaScript (such as speed, simplicity, etc.) there are downsides as well: it is frequently turned off in browsers because of security concerns, it can be easily exploited, etc.

AJAX (Asynchronous JavaScript + XML) is based on JavaScript with some other technologies like HTML and CSS and is used to dynamically update parts of the UI without having to reload the page.

While AJAX can be used with many Java frameworks (Spring MVC, Struts, JFS, etc.), it is very easy to use AJAX with Apache Wicket. You don’t even need to write a single line of JavaScript as Wicket has a bunch of AJAX-enabled components.

Here are some advantages of using AJAX in Wicket :

  1. As a Java developer, you can focus on pure Java without needing to learn JavaScript.
  2. The are many built-in AJAX components, also AJAX behavior is encapsulated in Wicket's reusable components.
  3. It is easy to replace components on the fly.
  4. There are faster, more responsive user interfaces, as AJAX requests do not completely refresh the whole page.
  5. It has an excellent debugging utility for debugging AJAX calls.

So, let’s see how much easier it is to use AJAX with Wicket than the traditional approach. Let's see how to submit a form without writing a single line of JavaScript. 

You just need to add a button that can be used to submit the form via AJAX:

form.add(new AjaxButton(“ajax-button”, form)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
// repaint the feedback panel so that it is hidden
target.add(feedback);
}

@Override
protected void onError(AjaxRequestTarget target, Form<?> form)
{
// repaint the feedback panel so errors are shown
target.add(feedback);
}
});

And that’s all. There is no JavaScript in HTML (i.e. markup file) of your Wicket application!

Note: the above piece of code is from the Wicket Library examples and a complete example can be found here.

AJAX Apache Wicket JavaScript

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Observability Tools Help Catch Application Failures — But Automating the Observer Is Becoming Crucial
  • Testing Strategies for Microservices
  • Delivering the Future of Uber-Like Apps With AI and ML
  • Replace your Scripts with Gradle Tasks

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo