Service on component

I have problem, I want inject in my FoodGrid service to manipulate with data, standartly I use it in constructor, in my View1 I add FoodGrid, but I dont want use contructor and I dont want use any service in View1, doesnt make sense for me here, how to call only new FoodGrid() without service? @Autowired and set to method isnt best practice and doesnt work for me

  • FoodGrid can’t be a singleton, use e.g. prototype
  • Inject FoodGrid to your View’s constructor
  • yes sure prototype on every request, i only test scopes :stuck_out_tongue:
  • ok make sense this way thanks :slightly_smiling_face:, but I want go way add new some my component without any constuctor parameters, but thats not possible I bet

Technically speaking it’s possible by injecting ApplicationContext and use this to instantiate new Grid classes, but I wouldn’t recommend this everybody