Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: ModeImpl cannot be resolved to a type
Hi All,
In 6.2 we are able to instance ModleImpl.e.g
Model model=new ModelImpl();but in Liferay 7.2 we cannot do it.Can any body tell me how we can do this in Liferay 7.2 version.
Thanks,Pankaj Semwal
In 6.2 we are able to instance ModleImpl.e.g
Model model=new ModelImpl();but in Liferay 7.2 we cannot do it.Can any body tell me how we can do this in Liferay 7.2 version.
Thanks,Pankaj Semwal
Pankaj Kumar:
It's wrong to instantiate a ModelImpl directly in client code: Encapsulate it in a service and hand it out.
In 6.2 we are able to instance ModleImpl.e.g
Model model=new ModelImpl();but in Liferay 7.2 we cannot do it.Can any body tell me how we can do this in Liferay 7.2 version.
You want client code to purely be dependent on the interface, so that you can hand out any kind of wrapper at any time. Your client code is only dependent on the api, never on the service implementation.
It was always wrong (bad style) to access implementation classes. Luckily now it's also impossible without going through hoops. Don't go through hoops - have your service provide whatever it wants, under the Model interface.
Thanks Olaf for your quick response.I did like this.InModeLocalServiceIml classgetInstance(){Model model=new ModelImpl()
return model;}
return model;}
Again, this was wrong.
Instead, in ModelLocalServiceImpl, you should have just called "createModel(0);" and let Liferay construct one properly.
Oh, and the way you did it in 6.2 was also wrong, it should have been createModel(0) there too.
Instead, in ModelLocalServiceImpl, you should have just called "createModel(0);" and let Liferay construct one properly.
Oh, and the way you did it in 6.2 was also wrong, it should have been createModel(0) there too.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™