org.broadleafcommerce.openadmin.web.controller.entity
Class AdminBasicEntityController

java.lang.Object
  extended by org.broadleafcommerce.common.web.controller.BroadleafAbstractController
      extended by org.broadleafcommerce.openadmin.web.controller.AdminAbstractController
          extended by org.broadleafcommerce.openadmin.web.controller.entity.AdminBasicEntityController
Direct Known Subclasses:
AdminUserController

@Controller(value="blAdminBasicEntityController")
@RequestMapping(value="/{sectionKey:.+}")
public class AdminBasicEntityController
extends AdminAbstractController

The default implementation of the #BroadleafAdminAbstractEntityController. This delegates every call to super and does not provide any custom-tailored functionality. It is responsible for rendering the admin for every entity that is not explicitly customized by its own controller.

Author:
Andre Azzolini (apazzolini)

Field Summary
 
Fields inherited from class org.broadleafcommerce.openadmin.web.controller.AdminAbstractController
adminNavigationService, adminRemoteSecurityService, entityConfiguration, entityFormValidator, FILTER_VALUE_SEPARATOR, FILTER_VALUE_SEPARATOR_REGEX, formService, mainEntityActionsExtensionManager, service
 
Constructor Summary
AdminBasicEntityController()
           
 
Method Summary
protected  void addAddActionIfAllowed(String sectionClassName, ClassMetadata cmd, List<EntityFormAction> mainActions)
          Adds the "Add" button to the main entity form if the current user has permissions to create new instances of the entity and all of the fields in the entity aren't marked as read only.
 String addCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, EntityForm entityForm, org.springframework.validation.BindingResult result)
          Adds the requested collection item
 String addEntity(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, EntityForm entityForm, org.springframework.validation.BindingResult result)
          Processes the request to add a new entity.
protected  String buildAddCollectionItemModel(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, String id, String collectionField, String sectionKey, Property collectionProperty, FieldMetadata md, PersistencePackageRequest ppr, EntityForm entityForm, Entity entity)
          Builds out all of the model information needed for showing the add modal for collection items on both the initial GET as well as after a POST with validation errors
 String getCollectionFieldRecords(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, org.springframework.util.MultiValueMap<String,String> requestParams)
          Returns the records for a given collectionField filtered by a particular criteria
 Map<String,String> getCollectionValueDetails(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String collectionField, String ids, org.springframework.util.MultiValueMap<String,String> requestParams)
           
 void initBinder(org.springframework.web.bind.WebDataBinder binder)
          Invoked on every request to provide the ability to register specific binders for Spring's binding process.
 String removeCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, String collectionItemId)
          Removes the requested collection item Note that the request must contain a parameter called "key" when attempting to remove a collection item from a map collection.
 String removeEntity(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, EntityForm entityForm, org.springframework.validation.BindingResult result)
          Attempts to remove the given entity.
 String saveEntity(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, EntityForm entityForm, org.springframework.validation.BindingResult result, org.springframework.web.servlet.mvc.support.RedirectAttributes ra)
          Attempts to save the given entity.
 String showAddCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, org.springframework.util.MultiValueMap<String,String> requestParams)
          Shows the modal dialog that is used to add an item to a given collection.
 String showSelectCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String owningClass, String collectionField, org.springframework.util.MultiValueMap<String,String> requestParams)
          Shows the modal dialog that is used to select a "to-one" collection item.
 String showUpdateCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, String collectionItemId)
          Shows the appropriate modal dialog to edit the selected collection item
 String showViewCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, String collectionItemId)
          Shows the appropriate modal dialog to view the selected collection item.
protected  String showViewUpdateCollection(javax.servlet.http.HttpServletRequest request, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, String collectionItemId, String modalHeaderType)
           
protected  String showViewUpdateCollection(javax.servlet.http.HttpServletRequest request, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, String collectionItemId, String modalHeaderType, EntityForm entityForm, Entity entity)
          Shows the view and populates the model for updating a collection item.
 String updateCollectionItem(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, String collectionItemId, EntityForm entityForm, org.springframework.validation.BindingResult result)
          Updates the specified collection item
 Map<String,Object> updateCollectionItemSequence(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id, String collectionField, String collectionItemId, String newSequence)
          Updates the given colleciton item's sequence.
 String viewAddEntityForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String entityType)
          Renders the modal form that is used to add a new parent level entity.
 String viewCollectionItemDetails(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String collectionField, String id)
          Shows the modal popup for the current selected "to-one" field.
 String viewEntityForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, String id)
          Renders the main entity form for the specified entity
 String viewEntityList(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, Map<String,String> pathVars, org.springframework.util.MultiValueMap<String,String> requestParams)
          Renders the main entity listing for the specified class, which is based on the current sectionKey with some optional criteria.
 
Methods inherited from class org.broadleafcommerce.openadmin.web.controller.AdminAbstractController
attachSectionSpecificInfo, extractDynamicFormFields, getAddEntityTypes, getBlankDynamicFieldTemplateForm, getBlankDynamicFieldTemplateForm, getClassNameForSection, getCollectionListGrid, getCollectionListGrid, getCriteria, getDefaultEntityType, getDynamicFieldTemplateForm, getDynamicForm, getMaxIndex, getSectionCustomCriteria, getSectionKey, getSectionPersistencePackageRequest, getSectionPersistencePackageRequest, getSortDirections, getSortPropertyNames, getStartIndex, setModelAttributes
 
Methods inherited from class org.broadleafcommerce.common.web.controller.BroadleafAbstractController
addDeepLink, getContextPath, isAjaxRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdminBasicEntityController

public AdminBasicEntityController()
Method Detail

viewEntityList

@RequestMapping(value="",
                method=GET)
public String viewEntityList(javax.servlet.http.HttpServletRequest request,
                                            javax.servlet.http.HttpServletResponse response,
                                            org.springframework.ui.Model model,
                                            @PathVariable
                                            Map<String,String> pathVars,
                                            @RequestParam
                                            org.springframework.util.MultiValueMap<String,String> requestParams)
                      throws Exception
Renders the main entity listing for the specified class, which is based on the current sectionKey with some optional criteria.

Parameters:
request -
response -
model -
pathVars -
criteria - a Map of property name -> list critiera values
Returns:
the return view path
Throws:
Exception

addAddActionIfAllowed

protected void addAddActionIfAllowed(String sectionClassName,
                                     ClassMetadata cmd,
                                     List<EntityFormAction> mainActions)
Adds the "Add" button to the main entity form if the current user has permissions to create new instances of the entity and all of the fields in the entity aren't marked as read only.

Parameters:
sectionClassName -
cmd -
mainActions -

viewAddEntityForm

@RequestMapping(value="/add",
                method=GET)
public String viewAddEntityForm(javax.servlet.http.HttpServletRequest request,
                                               javax.servlet.http.HttpServletResponse response,
                                               org.springframework.ui.Model model,
                                               @PathVariable
                                               Map<String,String> pathVars,
                                               @RequestParam(defaultValue="")
                                               String entityType)
                         throws Exception
Renders the modal form that is used to add a new parent level entity. Note that this form cannot render any subcollections as operations on those collections require the parent level entity to first be saved and have and id. Once the entity is initially saved, we will redirect the user to the normal manage entity screen where they can then perform operations on sub collections.

Parameters:
request -
response -
model -
pathVars -
entityType -
Returns:
the return view path
Throws:
Exception

addEntity

@RequestMapping(value="/add",
                method=POST)
public String addEntity(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response,
                                       org.springframework.ui.Model model,
                                       @PathVariable
                                       Map<String,String> pathVars,
                                       @ModelAttribute(value="entityForm")
                                       EntityForm entityForm,
                                       org.springframework.validation.BindingResult result)
                 throws Exception
Processes the request to add a new entity. If successful, returns a redirect to the newly created entity.

Parameters:
request -
response -
model -
pathVars -
entityForm -
result -
Returns:
the return view path
Throws:
Exception

viewEntityForm

@RequestMapping(value="/{id}",
                method=GET)
public String viewEntityForm(javax.servlet.http.HttpServletRequest request,
                                            javax.servlet.http.HttpServletResponse response,
                                            org.springframework.ui.Model model,
                                            @PathVariable
                                            Map<String,String> pathVars,
                                            @PathVariable(value="id")
                                            String id)
                      throws Exception
Renders the main entity form for the specified entity

Parameters:
request -
response -
model -
pathVars -
id -
modal - - whether or not to show the entity in a read-only modal
Returns:
the return view path
Throws:
Exception

saveEntity

@RequestMapping(value="/{id}",
                method=POST)
public String saveEntity(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response,
                                        org.springframework.ui.Model model,
                                        @PathVariable
                                        Map<String,String> pathVars,
                                        @PathVariable(value="id")
                                        String id,
                                        @ModelAttribute(value="entityForm")
                                        EntityForm entityForm,
                                        org.springframework.validation.BindingResult result,
                                        org.springframework.web.servlet.mvc.support.RedirectAttributes ra)
                  throws Exception
Attempts to save the given entity. If validation is unsuccessful, it will re-render the entity form with error fields highlighted. On a successful save, it will refresh the entity page.

Parameters:
request -
response -
model -
pathVars -
id -
entityForm -
result -
Returns:
the return view path
Throws:
Exception

removeEntity

@RequestMapping(value="/{id}/delete",
                method=POST)
public String removeEntity(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response,
                                          org.springframework.ui.Model model,
                                          @PathVariable
                                          Map<String,String> pathVars,
                                          @PathVariable(value="id")
                                          String id,
                                          @ModelAttribute(value="entityForm")
                                          EntityForm entityForm,
                                          org.springframework.validation.BindingResult result)
                    throws Exception
Attempts to remove the given entity.

Parameters:
request -
response -
model -
pathVars -
id -
Returns:
the return view path
Throws:
Exception

showSelectCollectionItem

@RequestMapping(value="/{owningClass:.*}/{collectionField:.*}/select",
                method=GET)
public String showSelectCollectionItem(javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response,
                                                      org.springframework.ui.Model model,
                                                      @PathVariable
                                                      Map<String,String> pathVars,
                                                      @PathVariable(value="owningClass")
                                                      String owningClass,
                                                      @PathVariable(value="collectionField")
                                                      String collectionField,
                                                      @RequestParam
                                                      org.springframework.util.MultiValueMap<String,String> requestParams)
                                throws Exception
Shows the modal dialog that is used to select a "to-one" collection item. For example, this could be used to show a list of categories for the ManyToOne field "defaultCategory" in Product.

Parameters:
request -
response -
model -
pathVars -
owningClass -
collectionField -
Returns:
the return view path
Throws:
Exception

getCollectionValueDetails

@RequestMapping(value="/{collectionField:.*}/details",
                method=GET)
@ResponseBody
public Map<String,String> getCollectionValueDetails(javax.servlet.http.HttpServletRequest request,
                                                                                javax.servlet.http.HttpServletResponse response,
                                                                                org.springframework.ui.Model model,
                                                                                @PathVariable
                                                                                Map<String,String> pathVars,
                                                                                @PathVariable(value="collectionField")
                                                                                String collectionField,
                                                                                @RequestParam
                                                                                String ids,
                                                                                @RequestParam
                                                                                org.springframework.util.MultiValueMap<String,String> requestParams)
                                             throws Exception
Throws:
Exception

viewCollectionItemDetails

@RequestMapping(value="/{collectionField:.*}/{id}/view",
                method=GET)
public String viewCollectionItemDetails(javax.servlet.http.HttpServletRequest request,
                                                       javax.servlet.http.HttpServletResponse response,
                                                       org.springframework.ui.Model model,
                                                       @PathVariable
                                                       Map<String,String> pathVars,
                                                       @PathVariable(value="collectionField")
                                                       String collectionField,
                                                       @PathVariable(value="id")
                                                       String id)
                                 throws Exception
Shows the modal popup for the current selected "to-one" field. For instance, if you are viewing a list of products then this method is invoked when a user clicks on the name of the default category field.

Parameters:
request -
response -
model -
pathVars -
collectionField -
id -
Returns:
Throws:
Exception

getCollectionFieldRecords

@RequestMapping(value="/{id}/{collectionField:.*}",
                method=GET)
public String getCollectionFieldRecords(javax.servlet.http.HttpServletRequest request,
                                                       javax.servlet.http.HttpServletResponse response,
                                                       org.springframework.ui.Model model,
                                                       @PathVariable
                                                       Map<String,String> pathVars,
                                                       @PathVariable(value="id")
                                                       String id,
                                                       @PathVariable(value="collectionField")
                                                       String collectionField,
                                                       @RequestParam
                                                       org.springframework.util.MultiValueMap<String,String> requestParams)
                                 throws Exception
Returns the records for a given collectionField filtered by a particular criteria

Parameters:
request -
response -
model -
pathVars -
collectionField -
criteriaForm -
Returns:
the return view path
Throws:
Exception

showAddCollectionItem

@RequestMapping(value="/{id}/{collectionField:.*}/add",
                method=GET)
public String showAddCollectionItem(javax.servlet.http.HttpServletRequest request,
                                                   javax.servlet.http.HttpServletResponse response,
                                                   org.springframework.ui.Model model,
                                                   @PathVariable
                                                   Map<String,String> pathVars,
                                                   @PathVariable(value="id")
                                                   String id,
                                                   @PathVariable(value="collectionField")
                                                   String collectionField,
                                                   @RequestParam
                                                   org.springframework.util.MultiValueMap<String,String> requestParams)
                             throws Exception
Shows the modal dialog that is used to add an item to a given collection. There are several possible outcomes of this call depending on the type of the specified collection field.

addCollectionItem

@RequestMapping(value="/{id}/{collectionField:.*}/add",
                method=POST)
public String addCollectionItem(javax.servlet.http.HttpServletRequest request,
                                               javax.servlet.http.HttpServletResponse response,
                                               org.springframework.ui.Model model,
                                               @PathVariable
                                               Map<String,String> pathVars,
                                               @PathVariable(value="id")
                                               String id,
                                               @PathVariable(value="collectionField")
                                               String collectionField,
                                               @ModelAttribute(value="entityForm")
                                               EntityForm entityForm,
                                               org.springframework.validation.BindingResult result)
                         throws Exception
Adds the requested collection item

Parameters:
request -
response -
model -
pathVars -
id -
collectionField -
entityForm -
Returns:
the return view path
Throws:
Exception

buildAddCollectionItemModel

protected String buildAddCollectionItemModel(javax.servlet.http.HttpServletRequest request,
                                             javax.servlet.http.HttpServletResponse response,
                                             org.springframework.ui.Model model,
                                             String id,
                                             String collectionField,
                                             String sectionKey,
                                             Property collectionProperty,
                                             FieldMetadata md,
                                             PersistencePackageRequest ppr,
                                             EntityForm entityForm,
                                             Entity entity)
                                      throws ServiceException
Builds out all of the model information needed for showing the add modal for collection items on both the initial GET as well as after a POST with validation errors

Parameters:
request -
model -
id -
collectionField -
sectionKey -
collectionProperty -
md -
ppr -
Returns:
the appropriate view to display for the modal
Throws:
ServiceException
See Also:
#addCollectionItem(HttpServletRequest, HttpServletResponse, Model, Map, String, String, EntityForm, BindingResult)}, #showAddCollectionItem(HttpServletRequest, HttpServletResponse, Model, Map, String, String, MultiValueMap)}

showUpdateCollectionItem

@RequestMapping(value="/{id}/{collectionField:.*}/{collectionItemId}",
                method=GET)
public String showUpdateCollectionItem(javax.servlet.http.HttpServletRequest request,
                                                      javax.servlet.http.HttpServletResponse response,
                                                      org.springframework.ui.Model model,
                                                      @PathVariable
                                                      Map<String,String> pathVars,
                                                      @PathVariable(value="id")
                                                      String id,
                                                      @PathVariable(value="collectionField")
                                                      String collectionField,
                                                      @PathVariable(value="collectionItemId")
                                                      String collectionItemId)
                                throws Exception
Shows the appropriate modal dialog to edit the selected collection item

Parameters:
request -
response -
model -
pathVars -
id -
collectionField -
collectionItemId -
Returns:
the return view path
Throws:
Exception

showViewCollectionItem

@RequestMapping(value="/{id}/{collectionField:.*}/{collectionItemId}/view",
                method=GET)
public String showViewCollectionItem(javax.servlet.http.HttpServletRequest request,
                                                    javax.servlet.http.HttpServletResponse response,
                                                    org.springframework.ui.Model model,
                                                    @PathVariable
                                                    Map<String,String> pathVars,
                                                    @PathVariable(value="id")
                                                    String id,
                                                    @PathVariable(value="collectionField")
                                                    String collectionField,
                                                    @PathVariable(value="collectionItemId")
                                                    String collectionItemId)
                              throws Exception
Shows the appropriate modal dialog to view the selected collection item. This will display the modal as readonly

Parameters:
request -
response -
model -
pathVars -
id -
collectionField -
collectionItemId -
Returns:
the return view path
Throws:
Exception

showViewUpdateCollection

protected String showViewUpdateCollection(javax.servlet.http.HttpServletRequest request,
                                          org.springframework.ui.Model model,
                                          Map<String,String> pathVars,
                                          String id,
                                          String collectionField,
                                          String collectionItemId,
                                          String modalHeaderType)
                                   throws ServiceException
Throws:
ServiceException

showViewUpdateCollection

protected String showViewUpdateCollection(javax.servlet.http.HttpServletRequest request,
                                          org.springframework.ui.Model model,
                                          Map<String,String> pathVars,
                                          String id,
                                          String collectionField,
                                          String collectionItemId,
                                          String modalHeaderType,
                                          EntityForm entityForm,
                                          Entity entity)
                                   throws ServiceException
Shows the view and populates the model for updating a collection item. You can also pass in an entityform and entity which are optional. If they are not passed in then they are automatically looked up

Parameters:
request -
model -
pathVars -
id -
collectionField -
collectionItemId -
modalHeaderType -
ef -
entity -
Returns:
Throws:
ServiceException

updateCollectionItem

@RequestMapping(value="/{id}/{collectionField:.*}/{collectionItemId}",
                method=POST)
public String updateCollectionItem(javax.servlet.http.HttpServletRequest request,
                                                  javax.servlet.http.HttpServletResponse response,
                                                  org.springframework.ui.Model model,
                                                  @PathVariable
                                                  Map<String,String> pathVars,
                                                  @PathVariable(value="id")
                                                  String id,
                                                  @PathVariable(value="collectionField")
                                                  String collectionField,
                                                  @PathVariable(value="collectionItemId")
                                                  String collectionItemId,
                                                  @ModelAttribute(value="entityForm")
                                                  EntityForm entityForm,
                                                  org.springframework.validation.BindingResult result)
                            throws Exception
Updates the specified collection item

Parameters:
request -
response -
model -
pathVars -
id -
collectionField -
entityForm -
Returns:
the return view path
Throws:
Exception

updateCollectionItemSequence

@RequestMapping(value="/{id}/{collectionField:.*}/{collectionItemId}/sequence",
                method=POST)
@ResponseBody
public Map<String,Object> updateCollectionItemSequence(javax.servlet.http.HttpServletRequest request,
                                                                                   javax.servlet.http.HttpServletResponse response,
                                                                                   org.springframework.ui.Model model,
                                                                                   @PathVariable
                                                                                   Map<String,String> pathVars,
                                                                                   @PathVariable(value="id")
                                                                                   String id,
                                                                                   @PathVariable(value="collectionField")
                                                                                   String collectionField,
                                                                                   @PathVariable(value="collectionItemId")
                                                                                   String collectionItemId,
                                                                                   @RequestParam(value="newSequence")
                                                                                   String newSequence)
                                                throws Exception
Updates the given colleciton item's sequence. This should only be triggered for adorned target collections where a sort field is specified -- any other invocation is incorrect and will result in an exception.

Parameters:
request -
response -
model -
pathVars -
id -
collectionField -
collectionItemId -
Returns:
an object explaining the state of the operation
Throws:
Exception

removeCollectionItem

@RequestMapping(value="/{id}/{collectionField:.*}/{collectionItemId}/delete",
                method=POST)
public String removeCollectionItem(javax.servlet.http.HttpServletRequest request,
                                                  javax.servlet.http.HttpServletResponse response,
                                                  org.springframework.ui.Model model,
                                                  @PathVariable
                                                  Map<String,String> pathVars,
                                                  @PathVariable(value="id")
                                                  String id,
                                                  @PathVariable(value="collectionField")
                                                  String collectionField,
                                                  @PathVariable(value="collectionItemId")
                                                  String collectionItemId)
                            throws Exception
Removes the requested collection item Note that the request must contain a parameter called "key" when attempting to remove a collection item from a map collection.

Parameters:
request -
response -
model -
pathVars -
id -
collectionField -
collectionItemId -
Returns:
the return view path
Throws:
Exception

initBinder

@InitBinder
public void initBinder(org.springframework.web.bind.WebDataBinder binder)
Invoked on every request to provide the ability to register specific binders for Spring's binding process. By default, we register a binder that treats empty Strings as null and a Boolean editor that supports either true or false. If the value is passed in as null, it will treat it as false.

Parameters:
binder -


Copyright © 2013. All Rights Reserved.