In Spring boot, want to display a field from entity class in output but input is not required - mysql

in Spring boot, I have an entity called Event. All the fields from the entity needs to come from user. I want that this entity should contain a field called approval status. This field doesn't need input from user but during display of that entity need that field populated from some source(from approval table) and displayed along with other fields of entity. Is there a way, I can include this field in Event class itself and specify no input or the only way is to create a wrapper class wrapping Event and approval status field?
Thanks,

#Transient is the exact thing which fulfill your use case.
Make field transient in your entity class and then set it in controller from whatever source you want to, and display it in page.
See https://stackoverflow.com/a/42753469/6572971

Related

How to hide field base on method PUT or POST or advance condition in spring controller by springdoc-openapi

I can't find the way to hide field base on method in springdoc-api.
Example:
For POST method, i want to hide status field in DTO.
For PUT method, i want to show status field in DTO.
How can i config it by springdoc-openapi or anyway i can hidden field base on the condition.

JSON parse the fields which user wants in Django REST API framework

I want to make users to be able to change some values of the object. For example, there is an event with ID "Id1" at "20.12.2021 14:00:00+00:00", a title of the event "the title", a description - "the description" and participants of the event ["Anne", "Jean", "Eren", "Sasha", "ME"].
I need to write a view which allows a user to change/update any of this values. If he wants, he can change only datetime, or only participants, or only title, or datetime AND title, or all the fields at once(although it is better to create a new event if it is needed to change everything in the first event, but anyways). So I need to know how to write a view which allows user to JSON parse only the fields he wants.
You can create a model serializer to serialize your Event objects and the view class can use this serializer. Check out Django Rest Framework's docs https://www.django-rest-framework.org/api-guide/serializers/#modelserializer

Admin - Add new post - hook to display some custom input fields

i have a custom post type
this post type needs some fields to be inserted into a custom MySQL table (wp_my_custom_table) where i store some relations IDs with other products and a number to sort them
i don't know how to put these input fields them after the textarea. I know how to insert them at "save_post" action hook.
these are not registered as "custom fields", are just a few input fields needed for each post type like this
The tag doesn't work, so i put the code that i have tried as image:
I have found, there is a hook "edit_form_after_editor".

where should i put lastlogin in yii2?

i have a lastlogin attribute for User model, but where to put the lastlogin? i'm using the default yii2-advanced template.
$model=User::findOne(Yii::$app->user->id)
$model->lastlogin=time();
$model->save();
If you want to store $model->lastlogin you must first change the database table (eg user) by adding the field that interests you, then update the model of the user by extending or modifying, remmenber of updating its rules.
I think the more appropriate place to enter this field is the user table and the related class ie the User model.

How to use Form tags in jsp to fetch properties from 2 Domain Objects and display in one form

I am doing a project on Springs and Hibernate.
I have a problem which am stating below:
I have 2 entities (District and Address) and I wanted to display a form which contains properties of both entities using form tags in jsp.,for single entity I can do this with CommandName and can retrieve the form values,but if i want to include properties from 2 tables..
How can I do this???? Kindly help me...
I usually create a model object that represents all the fields on the form. Then my model object would contain a District property and an Address property. You can then use nested property paths to access the properties of the nested object.