Five Reasons to Use Apache Wicket

Apache Wicket is a Java web development framework. I feel that he is not given as much attention as he deserves. I've been using Wicket professionally for real projects for the past 6 years and I love it! In this post, let's take a look at five reasons why you should consider using it.





1. Simple state management

The Wicket application development experience is very similar to desktop development. Sometimes you can almost forget that you are working with HTTP, because no need to save states. This is because in Wicket, the web page and all of its components (buttons, text boxes, etc.) are Java objects that maintain their own state. Component state is serialized in the user's session and deserialized at the right time.





Simply put, let's say you have a form with fields that the user fills in and submits. In a Wicket application, this form, its fields, and the submit button are components (Java objects) that are created and added to the web page. On clicking the submit button:





1. We automatically have access to user input, usually in the form of POJO fields.





2.We don't need to bind the HTTP POST request with the GET request.





We also don't need to think about filling the form fields with the submitted values. This is done using models, which are the core concept of Wicket.





2. Standard HTML Integration

HTML in Wicket does not require any special tags, unlike some other frameworks. In fact, you can take any existing HTML and integrate it with your Wicket application with little or no change. To connect HTML tags to Wicket components, only one attribute is needed: wicket: id



Consider an example:





<div wicket:id="userName">Roman</div>

add(new Label("userName", getUsername()));
      
      



wicket:id "userName"



HTML Wicket. Wicket Label div



. , . , . Wicket HTML / CSS / JS, , React. , .





3. Javascript ( )

- JS. AJAX, Wicket, , JS- . Wicket JQuery JS- -. , . , . Javascript . Wicket -.





4. /

Wicket - . , , . , , . , , , . :





send(getPage(), Broadcast.BREADTH, new CriticalUpdate(target, payload));
      
      



- CriticalUpdate , :





public void onEvent(IEvent event) {    

if (event.getPayload() instanceof CriticalUpdate) { 

      String msg = ((CriticalUpdate)event.getPayload());       //do something with the msg    

  } 

}
      
      



5.

/ Wicket , , . Wicket , . , . - CRUD: . . , , , , . All of this can be done using pure Java and JUnit code, without resorting to Selenium, Puppeteer or similar libraries.





Conclusion

I hope you've heard enough to give Wicket a try. If you're interested in learning more:





  1. Head over to the official site for great documentation.





  2. Take a look at code examples of common web development practices.












All Articles