Is it possible to utilize JSON in Struts 2 to bypass the necessity of tags and page mappings?

Lately, I've been pondering the concept of a design approach that utilizes unmapped pure HTML and JavaScript pages pulling JSON data from Struts 2. This means no action mappings are required, resulting in relative page references with minimal need for Struts 2 tags or any other tags. All necessary model information can be retrieved through JSON or managed by a custom Interceptor. Session management, typically handled by an Interceptor, could potentially be accessed via JavaScript headers, although this is uncertain. Even if not possible, alternative methods such as hidden controls could store this information. While the specifics remain unclear to me, I am confident that this approach is feasible.

The proposed outcome would be a purely HTML / JQuery UI accessible to a UI-focused developer without Java knowledge. Tabs, menus, pop-ups, and other elements might only require JSON data, improving browser caching. Moreover, Web Services may become less essential with a cleanly decoupled model and view eliminating the need for OGNL, JSTL, value stack manipulation, or type converters when using Hibernate. There are existing libraries that directly convert Hibernate entities into JSON, further simplifying the process.

Could this be a viable solution devoid of unnecessary complexity, delivering what Servlets and JSP once promised?

Answer №1

I'm a bit confused by your last statement. I don't understand what you mean by "reducing the need for web services," as the example you provided involves web services that return JSON data.

That being said, it is entirely possible to handle everything on the client side using JavaScript and only receiving JSON from S2. If your client-side framework supports this approach, there may not be any significant drawbacks unless your application relies heavily on bookmarking of specific data or if you are using a JS library that does not support this method.

While there may be a slightly higher level of caching involved, a well-designed application that goes beyond just JSON can implement caching effectively. This could result in some performance improvements, although the extent of these benefits may vary.

It's worth noting that depending on the browser being used, there could be issues related to memory usage or leaks that are challenging to identify or fix. However, if your app and users' browsers align well enough, these problems may never arise.

In today's age with modern browsers and advanced client-side JS frameworks, creating applications like the one described is quite feasible and actually becoming more common—it's no longer a groundbreaking concept.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ensuring a form is required using ng-validate

A sample form structure is shown below: <div class="row" id="yesAuth"> <div class="col-md-6" ng-class="{ 'has-error': invalid.basicAuthForBackendUsername, 'has-success': valid.basicAuthForBackendUsername}"> < ...

Tips on embedding an HTML page within another HTML page by utilizing a custom directive in AngularJS

I am looking to utilize custom directives in order to insert one HTML page into another. How can I achieve this? The custom directive code is as follows: (here is the .js file) fbModule.directive('fbLogin', function(){ return { ...

The Read method of the custom JsonConverter<DateTime> in System.Text.Json is not getting utilized when using the Deserialize method

I've encountered an issue with custom datetime formats in System.Text.Json. A custom converter I created was working fine in my API project, but when I tried using the same class in my client, the .Deserialize() methods wouldn't call .Read() on ...

Guide on showcasing an alert notification when the data is already existing within an array through javascript

Need help with displaying an alert message in JavaScript for duplicate values in an array? var names = []; var nameInput = document.getElementById("txt1"); var messageBox = document.getElementById("display"); function insert() { names. ...

Trigger $q manually in AngularJS

My understanding of $q in AngularJS is that it runs every time I refresh my page, similar to using a function in ng-init. Here is the code for $q.all that I have: $q.all([$scope.getCart(), $scope.getCategory(), $scope.getMenu(), $scope.getRestaurant()]). ...

The controller failed to return a value when utilizing the factory

I am attempting to pass a value from my view to the controller using a function within the ng-click directive. I want to then use this value to send it to my factory, which will retrieve data from a REST API link. However, the value I am sending is not ret ...

Utilizing Angular's globally accessible variables

As we make the switch to Angular.js for our webapp, we are faced with the challenge of storing global data. In the past, we used a global object called app to store various functions and variables that needed to be accessed across different parts of the ap ...

What is the simplest way to test an npm module while coding?

Currently, I am in the process of making modifications to @editorjs/nested-list. To streamline my testing process without extensive installations, I have created a simple web page: <html> <head> <script src="https://cdn.jsdelivr.net/npm ...

What is the best way to change a byte array into an image using JavaScript?

I need assistance converting a byte array to an image using Javascript for frontend display. I have saved an image into a MySQL database as a blob, and it was first converted to a byte array before storage. When retrieving all table values using a JSON ar ...

Initiating a conversation using a greeting in the Javascript bot framework

I am looking to initiate a multi-level, multiple choice dialog from the welcome message in the Bot Framework SDK using JavaScript. I have a main dialog (finalAnswerDialog) that utilizes LUIS for predicting intents, and a multi-level, multiple choice menu d ...

Custom options titled MUI Palette - The property 'primary' is not found in the 'TypeBackground' type

I am currently working on expanding the MUI palette to include my own custom properties. Here is the code I have been using: declare module '@mui/material/styles' { interface Palette { border: Palette['primary'] background: Pa ...

Using the novalidate attribute in Angular 4.0.0

Since migrating to angular 4, I have encountered a peculiar issue with my template-driven form. The required attribute on the input field appears to be malfunctioning. It seems like the form has the novalidate attribute by default, preventing HTML5 validat ...

browsing through a timeline created using HTML and CSS

I am currently working on a web project that involves creating a timeline with rows of information, similar to a Gantt chart. Here are the key features I need: The ability for users to scroll horizontally through time. Vertical scrolling capability to na ...

javascript - the dropdown text remains static

Two dropdown fields are present: DropDownA and DropDownB, along with a checkbox. When the checkbox is checked, DropDownA will mirror the text, value, and selected index of DropDownB before becoming disabled. The issue at hand: Although the attributes ca ...

What is the process of incorporating external links into an angular application?

Attempting to embed an external URL within my Angular app using an iframe has resulted in the following issue: https://i.sstatic.net/liSmX.png The error message reads as follows: https://i.sstatic.net/u9GWw.png Below is the template where I am trying t ...

Having trouble with the npx create-next-app command? Encounter the ENOENT error message?

When attempting to run the command, I encountered an error that is insisting on using yarn even though I am using npx. Npx works perfectly fine for other projects, such as react apps. I expect it to give me the next application starter in line. ...

Error: Trying to access a property that is undefined (specifically referencing 'rendered') has resulted in an uncaught TypeError

As a newcomer to React, I'm attempting to create a headless WordPress application. However, when I fetch a post, I only receive the first value. After fetching the post, I save it in the state: componentDidMount() { this.setState({ lo ...

Enhance the user experience with a personalized video player interface

I am facing difficulty in creating a responsive video with custom controls. While I understand that using a <figure></figure> element and setting the width to 100% makes the video responsive, I am struggling with making the progress bar also r ...

Controller is not cooperating with Artisan migration

I have a database of contacts that is populated through an API call to /users endpoint. It successfully retrieves all user data and displays it in a table. Now, I want the user to be able to click a button and receive an updated contact list with unique v ...

Is it possible to create a single button that, upon clicking, fades in one image while simultaneously fading out another?

My goal is to have the blue square fade in on the first button click, then fade out while the red square fades in on the second click. Unfortunately, it seems that my current code is not achieving this effect. I'm open to any suggestions or help on h ...