掲示板

Can I access mvc porlet module imports to service builder ?

7年前 に Revathi Vadlamudi によって更新されました。

Can I access mvc porlet module imports to service builder ?

Junior Member 投稿: 82 参加年月日: 14/11/14 最新の投稿
Create module as employee-mvc-portlet

employee-mvc-portlet -> src/main/java -> com.test.portlet.search


In com.test.portlet.search 4 class files

TestSearch.java, TestDetails.java, TestSearchTerms.java, TestDisplayTerms.java

In below path I need to get TestDetails.java import.

service-builder -> src/main/java -> emp.service.builder.service.persistence.impl -> TestFinderImpl


Added below line in build.gradle of service builder

compileOnly project(":modules:employee-mvc-portlet")


I got the import in FinderImpl, but when I run build of emp-service-builder-service, this error displayed. Did I give configuration in build.gradle?

FAILURE: Build failed with an exception.

* What went wrong:
Circular dependency between the following tasks:
:modules:employee-mvc-portlet:classes
\--- :modules:employee-mvc-portlet:compileJava
     \--- :modules:emp-service-builder:emp-service-builder-service:jar
          \--- :modules:emp-service-builder:emp-service-builder-service:classes
               \--- :modules:emp-service-builder:emp-service-builder-service:compileJava
                    +--- :modules:employee-mvc-portlet:jar
                    |    \--- :modules:employee-mvc-portlet:classes (*)
                    \--- :modules:emp-service-builder:emp-service-builder-service:jar (*)

(*) - details omitted (listed previously)


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 0.152 secs
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Can I access mvc porlet module imports to service builder ?

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Definitely bad practice.

If your SB layer needs something, keep it there. If front end needs it too, put in the API layer so it is available to both.
7年前 に Revathi Vadlamudi によって更新されました。

RE: Can I access mvc porlet module imports to service builder ?

Junior Member 投稿: 82 参加年月日: 14/11/14 最新の投稿
Thank you David. Keeping below two lines of code in build.gradle of service builder api.


compileOnly group: "javax.portlet", name: "portlet-api", version: "2.0"
compileOnly group: "javax.servlet", name: "javax.servlet-api", version: "3.0.1"


Is it good practice to do so?
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Can I access mvc porlet module imports to service builder ?

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Not really.

The whole purpose of the SB layer is to provide a data access layer and sometimes a business layer.

If you try adding in details from the view layer (the portlet and servlet APIs), you're polluting the layers and not keeping a clear separation of concerns.

Your front end portlet code, your action handlers, your portlet class, etc. should be responsible for dealing with presentation issues such as extracting parameter values, etc. Heck, your presentation layer is also responsible for verification and validation because, after all, it is responsible for displaying errors/notices in the forms.

Your service builder layer may use those values, but that's the extent of it.

If you don't keep a clear separation of concerns, you can get to a point where you can't call your SB layer from some other entry point. Imagine, for example, that someone wants to call your SB layer from a scheduled task. There is no http or portlet request there, so now they would have to construct a fake one just to invoke the service.

Maintain the separation of concerns, build each layer out so that it has no dependency on outer layers to keep your options open.
7年前 に Revathi Vadlamudi によって更新されました。

RE: Can I access mvc porlet module imports to service builder ?

Junior Member 投稿: 82 参加年月日: 14/11/14 最新の投稿
Ok. As I understand you want me to create separate layer/module, so that, service-builder api won't disturb and my work will done and I can access those files using dependencies.

So can you please tell me what exactly I have to follow to import action files in service builder and jsp as well.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Can I access mvc porlet module imports to service builder ?

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Import action files? Not enough context here to understand what you're going for.

If you're talking about some sort of file upload, are you loading into the doc lib? That has numerous routines in the SB layer to support file storage w/o blurring the lines separating the layers. Doc lib portlet handles the upload, data is passed to the service layer, everything is separate and organized.

If not going into doc lib, it at least provides a model for how you can support file upload w/o exposing web constructs in the service implementation...
7年前 に Revathi Vadlamudi によって更新されました。

RE: Can I access mvc porlet module imports to service builder ?

Junior Member 投稿: 82 参加年月日: 14/11/14 最新の投稿
Actually my requirement is, I have written one package search as you can see my previous posts to modify search container results.

Now I am unable to import that package in *FinderImpl. Because, I wrote that package in mvc-portlet and I am trying to import in service-builder.

After reading your post, I understand that I should not write that package in mvc-portlet, lieu I should write in service-builder-api, so that I can import that package in both. For that I modified build.gradle. But, it is also the wrong practice.

Now if I want to get *Details package in *FinderImpl what I have to do? Where *Details, *Search, *SearchTerms, *DisplayTerms are used to modify liferay-search-container.
thumbnail
7年前 に David H Nebinger によって更新されました。

RE: Can I access mvc porlet module imports to service builder ?

Liferay Legend 投稿: 14916 参加年月日: 06/09/02 最新の投稿
Revathi Vadlamudi:
Now if I want to get *Details package in *FinderImpl what I have to do? Where *Details, *Search, *SearchTerms, *DisplayTerms are used to modify liferay-search-container.


Okay, I think I see where the confusion is.

So your best example of the "right" way to do things is to go to the Liferay source. If you take a look at the Liferay shopping-web module, you'll see that they keep all of these support classes in the web module: https://github.com/liferay/liferay-portal/tree/master/modules/apps/shopping/shopping-web/src/main/java/com/liferay/shopping/web/internal/search

They do not, in fact, invoke a FinderImpl class directly, nor does the finders access these classes directly.

The search itself is shown on this page: https://github.com/liferay/liferay-portal/blob/master/modules/apps/shopping/shopping-web/src/main/resources/META-INF/resources/orders.jsp. You can see on the order_search.jsp where the DisplayTerms and stuff are used to define "filters" for the search.

The actual search calls are handled in orders.jsp: https://github.com/liferay/liferay-portal/blob/master/modules/apps/shopping/shopping-web/src/main/resources/META-INF/resources/orders.jsp#L57-L63

There's no passing in of these special classes, the values are passed to the search() method and it's up to the search() method to handle them. Behind the scenes it could be using one of the finders for the service layer, but the front end doesn't know about it and the back end doesn't have any visibility on the special classes.