Providing UI field attributes within server JSON data

Suppose I have numerous form fields that need to be displayed on the user interface. Additionally, in a standard Modify workflow, let's assume that these fields will have various attributes like value, mandatory, editable, disabled, label, regex (for validation), and more.

While "value" would need to come from the service as it is a persisted database value, should other attributes/flags such as mandatory, editable, etc also be returned from the service? These attributes might be determined by certain business logic (e.g. whether a field is editable based on a specific workflow status).

Is it preferable to avoid including anything related to business logic in the UI, or should attributes like mandatory, editable, etc be kept on the UI since they are UI-specific? Any references on this topic would be greatly appreciated.

Answer №1

One way to create complex GUIs is by converting hyperlinks into forms and their parameters into input fields or sub-forms. However, the logic for displaying different representations or how they are related must be added by client developers separately.

When discussing input field flags, it's important to note that they pertain to hyperlink parameters rather than the returned data. For situations involving a form, it may be helpful to view it as pre-filled with data rather than just a representation of a resource.

As far as I know, Hydra is currently the only REST framework that partially incorporates this feature, despite my previous attempt to request better support for it. While I am also working on a similar framework based on RDF technologies, it will not be open source like Hydra. Therefore, if you require this functionality for your current project, manual development may be more efficient than creating an entire framework from scratch.

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

Does the GSON getAsString() method retain double quotes in JSON elements?

When using GSON to parse this JSON data, I am encountering an issue where the deserialized string ends up with quotes around it. In the code snippet below: val ret = gson.toJson(tempObject.getAsJsonObject("medias") .getAsJsonObject("media").getAsJ ...

Integrate a PHP variable into an HTML/JavaScript statement that was previously transformed from PHP

Incorporated within this PHP variable is a mix of HTML and JavaScript code. My task is to enhance it by adding another PHP variable. Specifically, I have a PHP variable denoted as $user->user_email. How can I seamlessly integrate this variable into th ...

Error encountered during the compilation of Angular2 Typescript due to difficulty in mapping a JSON response with underscores in the names

I recently started working with angular2 and I'm trying to map a JSON response to an array of custom objects. The issue I'm facing is that when I try to access a variable with an underscore in its name, I encounter a compile error. I followed the ...

IntelliJ lacks the option to run code when right-clicking

I recently transitioned to a new machine where I am running a maven project with a series of automated Java tests. On my previous machine, these tests worked perfectly fine. However, on the new machine, when I attempt to right-click on the test Java class ...

Executing API calls utilizing Axios in a NodeJS environment with the Authorization Basic feature

I have developed an API to retrieve a token from PayPal. curl -v POST https://api.sandbox.paypal.com/v1/oauth2/token \ -H "Accept: application/json" \ -H "Accept-Language: en_US" \ -u "CLIENT_ID:SECRET" &b ...

How can we create external labels for a polar chart in ng2-charts and chart.js, with a set position outside the circular rings?

Currently, I am working on creating a polar chart using Angular along with chart.js version 2.8.0 and ng2-charts version 2.3.0. In my implementation, I have utilized the chartjs-plugin-datalabels to show labels within the polar chart rings. However, this p ...

What is required to run npm rebuild node-sass --force following each instance of a `yarn add` command?

As I attempt to set up the isemail npm library, everything appears to be going smoothly. However, when I execute yarn start:dev, which essentially runs "npm run build:dev && ./scripts/gendevconfig.sh && cross-env BABEL_DISABLE_CACHE=1 NODE_ ...

Ways to extract single JSON entities from a consolidated JSON structure

I am facing a challenge with parsing multiple JSON objects within a single large JSON object. Currently, the entire JSON object is being stored as one entity, but I need to parse and store them separately in MongoDB. Below is the code snippet I am using. ...

execute a limited number of Selenium methods

When creating a test suite, it is possible to run all class files by using code such as: suite.addTestSuite( TestCase3.class); suite.addTestSuite( TestCase2.class); suite.addTestSuite( TestCase1.class); But what if you only want to run specific test me ...

How can I retrieve the length of an array in vuejs?

This snippet includes a script tag <script> export default { data() { return { blogs: [], }; }, created() { this.paginate_total = this.blogs.length / this.paginate; }, }; </script> Displayed below is the respo ...

Enabling CSRF protection between a ReactJS frontend and a Spring Boot backend across different domains

Our setup includes a frontend React JS application and a backend Spring Boot API with CSRF enabled, running on different domains. What is the most effective approach for passing the CSRF token between the REST API and the React application? ...

Is there a way to lead to a password-protected page without making it accessible through the URL?

I'm currently honing my skills in web development and embarking on a project to create an interactive puzzle website. The premise is simple - the homepage will feature just an answer input field where users can enter the correct solution to progress t ...

In a designated paragraph, set the display of all <span> elements to none using JavaScript

I have a long paragraph with over 10,000 lines of text and I need a way to quickly remove all the lines without hiding the entire paragraph. Specifically, I want to hide each line individually by changing the span style from "display:block" to "display:non ...

Filtering ng-repeat in AngularJs based on nested data properties

Within my data tracking appointments, I have information on months, weeks, days, and timeslots. When it comes to the listing view, displaying "weeks" is unnecessary (although important for other reports). To eliminate days without appointments, I can use ...

Utilizing $.Deferred() in a loop of nested ajax requests

I have spent countless hours searching for solutions to my problem, but I am still hopeful that someone out there has a solution. The issue at hand is being able to receive a notification once function a() has finished its execution. The challenge lies in ...

What is the mechanism behind declaring a function using square brackets in Node.js/Javascript?

Encountering something new while working with Node.js - a unique way of declaring functions. You can find an example at this link. 'use strict'; const Actions = { ONE: 'one', TWO: 'two', THREE: 'three' }; clas ...

Sort by user identifier

I'm having an issue trying to filter a list of posts and comments by userId. I've passed the userId params as postCreator and commentCreator, but something seems to be amiss. Can anyone help me identify what I might be doing wrong? // Defining ...

Using jQuery each, the output is an undefined Object or HTMLElement

Using jQuery's each/getJSON to iterate through a data.json file, collect and format the data, and display it on the page within the #output div. The functionality is working correctly, except for the unexpected addition of [object HTMLElement] that a ...

How can you run a function in JavaScript or TypeScript that is stored as a string?

Is there a way to call a function that is stored as a string? For example: var dynamicFun = `function Hello(person) { return 'Hello' + person; }` In this case, the dynamicFun variable can store any function definition dynamically, such as: var ...

Implementing Jquery to attach a click event immediately after adding a new row to the table, all

I have an issue where I am adding a new row to my table. Within this row, there is a button that should be clickable and trigger an event. I have come across various solutions, but they all involve using the following code: .on('click', 'bu ...