Page 1 of 1

How to get the product url in admin fetch?

Posted: Sun Jun 22, 2014 8:48 am
by gowthamgutha
I have implemented my own PersistenceHandler for the BLC_PRODUCT. Now, I would like to know, how could I get product url or atleast product id of the product that is requested. For example, if the user requested.
'
http://localhost:8086/admin/product/12303

Then, I would want the 12303 number. How could I get that. In the fetch() method of the CustomPersistenceHandler, I only have these parameters,

PersistencePackage persistencePackage
CriteriaTransferObject cto
DynamicEntityDao dynamicEntityDao
RecordHelper helper

The reason I am asking this is, when a single product is requested I need to send only a single record and in order to ensure that the requested record is returned by the fetch() method of my persistence handler, i need a way to know which product I am being requested.

I am getting the Entity Not Found error if I send all the records, because of this..

Code: Select all

AdminEntityServiceImpl.java
Assert.isTrue(entities != null && entities.length == 1, "Entity not found");


Thanks in advance. Hope you will reply as soon as possible.

Re: How to get the product url in admin fetch?

Posted: Mon Jun 23, 2014 11:48 am
by phillipuniverse
This is normally handled in the AdminBasicEntityController in the 'viewEntityForm' method:

Code: Select all

@RequestMapping(value "/{id}"method RequestMethod.GET)
public 
String viewEntityForm(HttpServletRequest requestHttpServletResponse responseModel model,
        @
PathVariable  Map<StringStringpathVars,
        @
PathVariable("id"String idthrows Exception {
    
String sectionKey getSectionKey(pathVars);
    
String sectionClassName getClassNameForSection(sectionKey);
    List<
SectionCrumbcrumbs getSectionCrumbs(requestsectionKeyid);
    
PersistencePackageRequest ppr getSectionPersistencePackageRequest(sectionClassNamecrumbspathVars);

    
ClassMetadata cmd service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData();
    
Entity entity service.getRecord(ppridcmdfalse).getDynamicResultSet().getRecords()[0];
 


In this case, the Spring path variable {id} on the method and the mapping on the controller itself of @RequestMapping("/{sectionKey}") leads you with the URL "/admin/{sectionKey}/{id}". This method gleans out the ID and then sends that along as criteria in the CriteriaTransferObject to the CustomPersistenceHandler.

So in the fetch() method you should've gotten some values in the cto parameter for the 'id' field. Was that not the case?