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

What is the best way to populate a field in a collection using stream operators?

I am currently working with two different lists of objects: builders of type Builder and adminUsers of type AdminUser. Below are the class definitions for both types: public class Builder { @Id private String id; private String name; @Fiel ...

Leverage variables in Ajax to retrieve the data of an HTML element

Seeking assistance in converting multiple lines into a single for loop. var optie1 = ""; if($('#form #optie1_check').is(':checked')) { optie1 = $('#form #optie1_naam').val(); } var optie2 = ""; if($('#form #optie2_ch ...

Looking to reset the default display option in a select dropdown using JavaScript or jQuery?

Here is some HTML code for a select element: <select> <br> <option>1</option><br> <option>2</option><br> </select> This select element will initially display the first option item (display ...

Unable to communicate between react components

I am currently working on a project using React JS (jsfiddle). The issue I am facing is that the textbox does not update with the true/false value of the checkbox when it is checked. Can anyone provide insight into why this might be happening? var Custo ...

The server-side PHP script may not always successfully respond to an Ajax call from the client

Whenever I try to access my index.html site, there are times when the Ajax request is made to call the PHP on the server in order to display the dynamic content. But for some reason, it only works intermittently when I manually refresh the page using the a ...

Decode contentless data using Gson

The server is sending me the following data: data":[[ "15", "", 0, 254, 0, "0m", "N", 0, 1, "N", 0 ], [ "3", "Other", 504, 2, 36, "503m", "NW", 310, 1, "SE", 130 ] ], I recognize that it's an array of objects, but I'm struggling to parse the in ...

What is the best way to dynamically link an Angular Material table with information pulled from the backend server

I am attempting to connect a mat-table with data from the backend API following this Angular Material Table Dynamic Columns without model. Below is the relevant content from the .ts file: technologyList = []; listTechnology = function () { ...

What is the best way to utilize jq to arrange the contents of this JSON file based on the seconds value?

Here is a snippet of json data: { "results": [ { "request": { "metric": "CLOUDFREE_TIME_PERCENT", "path": { "fromPoint" ...

Central alignment of div with cursor

I'm experimenting with creating a unique custom cursor using a <div> that trails the movement of the mouse pointer. While the current setup works smoothly, I've noticed that when scrolling down the page, the div lags behind until the scrol ...

How can I show the number of items in my filtered data using AngularJS?

My data array holds objects in JSON format. var users = { 'New':{ {Name:'One'}, {Name:'Two'} }, 'Old':{ {Name:'Three'}, {Name:'Four'} } This piece of code is used to disp ...

Uncovering the jsPlumb link between a pair of identifiers

Could someone help me understand how to disconnect two HTML elements that are connected? I have the IDs of both elements, but I'm not sure how to locate their connection in the jsPlumb instance. Any tips on finding the connection between two IDs? ...

Generating well-structured JSON response to be utilized in highcharts alongside Laravel is crucial for efficient data

In one of my views, I have integrated a highcharts chart and I am trying to load the data via ajax from an API route that returns a JSON response. Here is the API route I created: Route::get('api/v1/data/{id}', function($id) { //Perform som ...

What could be causing this code to malfunction on jsfiddle?

Why doesn't this code from W3schools work on jsfiddle? I tried to implement it here: https://jsfiddle.net/u6qdfw5f/ <!DOCTYPE html> <html> <title>W3.CSS</title> <meta name="viewport" content="width=device-width, initial ...

AngularJS is throwing an error stating that the URL ID is undefined

I am developing an application that utilizes angularjs with codeigniter as the backend. Within my URL, I have http://localhost/submit/1234, with 1234 serving as the ID. Within my angularjs setup: var singlepost = angular.module('singlepost', [ ...

jquery method for retrieving default value from dropdown list

When no option is selected from the dropdown list, I require the default value to be used for business logic purposes. ...

What is the best way to modify JSON data within a file?

To start, I retrieve a JSON array by using the following JavaScript code: $.getJSON("myJSONfile.json") .done(function(data) { myData = data; }); After storing the data in myData, which is a global variable, I proceed to add more informati ...

Using ajax to submit a request to the controller

I'm currently developing an ASP.NET Core MVC application and have a registration page set up. My goal is to return View with errors if the model state is false: @model WebApplication2PROP.Entities.UserRegister @* For more information on enabling M ...

Substitute an item with another -JavaScript

While I understand this is a rather common question, my search through various sources has yielded answers that involve libraries, ES6, or methods not supported by native JavaScript. My goal is to simply replace one object with another based on a condition ...

Issue experienced with Vue2 where utilizing a computed property to filter a nested v-for structure

I have a unique HTML challenge that requires me to iterate through an unconventional data setup. The information is retrieved in two separate parts from Firebase: one for categories and another for businesses. The structure of the data is as follows: Busi ...

What is the best way to incorporate this json feed into a database format?

Working on developing an app where I am integrating various stores for customers to purchase products. I have a json feed containing all the necessary data about these stores. Many fields like phone number, address, and postcode are straightforward to inc ...