Fórum

how to use entity impl class of a portlet in ext

thumbnail
Rajesh Chaurasia, modificado 12 Anos atrás.

how to use entity impl class of a portlet in ext

Regular Member Postagens: 183 Data de Entrada: 18/08/11 Postagens Recentes
I created an entity with name WebContentNavigate using a portlet .I am able to create a and upload thsi portlet.I want to create an instanxce and write this portlet's entity in my ext .In this ext I have modified and overriden the liferays' action class .In the action class Named EditArticleAction.java , i want to access the portlets' model classes . How can I access model classes of entity and write the instance class into db from my ext?

I did import the servcie class namely WebContentNavigate-portlet-service.jar but this does not help either as this servcie class doesnot ship the impl classes.
I have this code for your reference
if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
article = updateArticle(actionRequest);
DLFileEntry fileEntry = updateFileEntry(actionRequest, actionResponse);
if(fileEntry!= null && article != null){
//article.getExpandoBridge().setAttribute("dlFileId", fileEntry.getFileEntryId());
String dlFileIds = ParamUtil.getString(actionRequest, "dlFileIds");
System.out.println("Attachment id is :"+fileEntry.getFileEntryId());
//String dlfileIds = (String)article.getExpandoBridge().getAttribute("dlFileIds");
System.out.println("dlfileIds id is init :"+dlFileIds);
if(dlFileIds!= null && !("").equals(dlFileIds)){
dlFileIds = dlFileIds +","+String.valueOf(fileEntry.getFileEntryId());
}else{
dlFileIds = String.valueOf(fileEntry.getFileEntryId());
}
System.out.println("dlfileIds id is final:"+dlFileIds);
if(dlFileIds!= null){
article.getExpandoBridge().setAttribute("dlFileIds", dlFileIds);
}else{

}
}

long folderId = ParamUtil.getLong(actionRequest, "folderId");
String articleId = ParamUtil.getString(actionRequest, "articleId");
JournalArticle jrnlArt = article;
System.out.println("jrnl in insertWebContentNavigate:"+jrnlArt);
WebContentNavigateImpl wcEntry = new WebContentNavigateImpl();
wcEntry.setCreateDate(new Date());
wcEntry.setFolderId(folderId);
wcEntry.setModifiedDate(new Date());
wcEntry.setJournalarticleId(jrnlArt.getPrimaryKey());
wcEntry.setCompanyId(jrnlArt.getCompanyId());
wcEntry.setUserId(jrnlArt.getUserId());
wcEntry.setUserName(jrnlArt.getUserName());
WebContentNavigate wcn = (WebContentNavigate) WebContentNavigateLocalServiceUtil.addWebContentNavigate(wcEntry);
System.out.println("WebContentNavigate entry saved in db :"+wcn);

}

Please help me asap.

--Rajesh
thumbnail
Ravi Kumar Gupta, modificado 12 Anos atrás.

RE: how to use entity impl class of a portlet in ext

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
In place of
WebContentNavigateImpl wcEntry = new WebContentNavigateImpl();
Use
WebContentNavigate wcEntity = WebContentNavigateLocalServiceUtil.create(); // or similar method available.

Add the WebContentNavigate-portlet-service.jar file to tomcat/lib/ext folder, remove this jar from portlets lib in webapps..

Try and let us know how it goes..
thumbnail
Juan Carrey, modificado 12 Anos atrás.

RE: how to use entity impl class of a portlet in ext

Junior Member Postagens: 31 Data de Entrada: 15/08/11 Postagens Recentes
Ravi Kumar Gupta:
In place of
WebContentNavigateImpl wcEntry = new WebContentNavigateImpl();
Use
WebContentNavigate wcEntity = WebContentNavigateLocalServiceUtil.create(); // or similar method available.

Add the WebContentNavigate-portlet-service.jar file to tomcat/lib/ext folder, remove this jar from portlets lib in webapps..

Try and let us know how it goes..



Thats the way,

You should work with interfaces, which are in the *-service.jar , and never use Impl classes. Use factories to create instances of new objects ( In this case WebContentNavigateLocalServiceUtil.createWebContentNavigate(long id);
thumbnail
Rajesh Chaurasia, modificado 12 Anos atrás.

RE: how to use entity impl class of a portlet in ext

Regular Member Postagens: 183 Data de Entrada: 18/08/11 Postagens Recentes
Thanks for ginving me right direction but still I face issues as given below:

I am not able to get an instance of WebContentNavigate
1 webcontentnavigateId = CounterLocalServiceUtil.increment(this.getClass().getName());
2 WebContentNavigate wcEntry = WebContentNavigateLocalServiceUtil.createWebContentNavigate(webcontentnavigateId);

It gives NPE (at line no 2 above ) and hence I am not able to insert data in WebContentNavigate table.

java.lang.NullPointerException
at com.sify.npp.service.WebContentNavigateLocalServiceClp.<init>(WebContentNavigateLocalServiceClp.java:398)
at com.sify.npp.service.WebContentNavigateLocalServiceUtil.getService(WebContentNavigateLocalServiceUtil.java:243)
at com.sify.npp.service.WebContentNavigateLocalServiceUtil.createWebContentNavigate(WebContentNavigateLocalServiceUtil.java:59)
at com.liferay.portlet.journal.action.EditArticleAction.processAction(EditArticleAction.java:103)
at com.liferay.portal.struts.PortletRequestProcessor.process(PortletRequestProcessor.java:169)
at com.liferay.portlet.StrutsPortlet.processAction(StrutsPortlet.java:186)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:652)
at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:687)
at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:360)
at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:784)

PLease let me know what else is needed to make this work.
thumbnail
Rajesh Chaurasia, modificado 12 Anos atrás.

RE: how to use entity impl class of a portlet in ext

Regular Member Postagens: 183 Data de Entrada: 18/08/11 Postagens Recentes
I suspect it is due to the fcat that I canrt get service instance in my ext while i am trying to invoke the portlets' WebContentNavigateLocalServiceUtil.createWebContentNavigate(webcontentnavigateId);
thumbnail
Ravi Kumar Gupta, modificado 12 Anos atrás.

RE: how to use entity impl class of a portlet in ext

Liferay Legend Postagens: 1302 Data de Entrada: 24/06/09 Postagens Recentes
is your service jar file in tomcat lib?? tomcat/lib/ext??
thumbnail
Rajesh Chaurasia, modificado 12 Anos atrás.

RE: how to use entity impl class of a portlet in ext

Regular Member Postagens: 183 Data de Entrada: 18/08/11 Postagens Recentes
yes i put the servcie .jar in lib /ext of tomcat