3

I am having a scenario wherein we have a Product Entity or a Front End Module which can be Added, Edited and Deleted.

Now Product ( when added or edited) can contain a Dropdown called as Manufacturer. User can select one value out of it.

I have written a Spring Controller->Service->Dao->Model type of Code to serve the JSON Output of a Tuple from Database Table 'product'.

product : {name:"abc",meta-title:"",manufacturer:"Dell",Model:"some model",price:"2000",SKU:""}

When this JSON arrives in View it is rendered to Template by ProductService.js->ProductController.js->product.jsp ( Using Angularjs )

My Question specifically is :-

  1. How are Sub Entities ( like manufacturer ) be handled ? Like, all the Values of Manufacturer to be sent to View as part of product JSON with an additional selected:Dell flag ?

E.g :-

 product : {
 name:"abc",
 meta-title:"",
 manufacturer:"Dell",
 Model:"some model",
 price:"2000",
 SKU:"",
 selectedManufacturer:1,
 manufacturer :
 [ 
   { id:1,name:"Dell"}, 
   { id:2,name:"Sony"}
 ]
};

OR

  1. A Manufacturer Controller needs to be written which will serve the list of Manufacturers and then ProductController.js (Angular Client Side) will invoke the ManufacturerService (Angular Client side) which will get the list of Manufacturers and provide it to the Product View.

Even in the second case the Product JSON needs to sent the selected value of the Manufacturer saved in the Database Table product. so how should the JSON be ?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.