Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

ATG Best Practices

2.094 visualizaciones

Publicado el

Best Practices for Form Handlers, Droplets, Repository

Publicado en: Software
  • Sé el primero en comentar

ATG Best Practices

  1. 1. By Kate Soglaeva
  2. 2. »FormHandlers do’s »Droplets do’s »Repositories do’s 2 ATG Hints by Kate Soglaeva
  3. 3. ATG Hints by Kate Soglaeva 3
  4. 4. 4 ATG Hints by Kate Soglaeva
  5. 5. 5 ATG Hints by Kate Soglaeva HTML JSP Droplets ServicesManagers viewpresentermodel Form Handlers Tags Xml,json Repositories Web Services
  6. 6. 6 ATG Hints by Kate Soglaeva Manager Form Handler Form Form Value Object Business Object Repositories Field Validator 1 : 1 Request Business logic validation logic
  7. 7. 7 ATG Hints by Kate Soglaeva Form Manager Form Handler Form Handler Form Field Validator Business Object Repositories Droplet
  8. 8. 8 ATG Hints by Kate Soglaeva JSP Form Handler <dsp:input bean=“MyFormHandler.save" “ type=“hidden“/> MyFormHandler.properties successURL=/… errorURL=/… MyFormHandler.java checkFormRedirect(suc cessURL, errorURL); sendLocalRedirect();
  9. 9. 9 ATG Hints by Kate Soglaeva
  10. 10. 10 ATG Hints by Kate Soglaeva HTML JSP Droplets ServicesManagers viewpresentermodel Html code
  11. 11. » ParameterName instead of the strings. public class GiftlistDroplet extends DynamoServlet { static final ParameterName PROFILE = ParameterName.getParameterName("profile"); ... public void service(DynamoHttpServletRequest pReq, DynamoHttpServletResponse pResp) throws ServletException, IOException { ... Object profileObject = pReq.getObjectParameter(PROFILE); ... } } 11 ATG Hints by Kate Soglaeva
  12. 12. <dsp:droplet name="/atg/dynamo/droplet/Cache"> <dsp:param name="key" param="childCategory.repositoryId"/> <dsp:oparam name="output"> <dsp:valueof param="childCategory.longDescript ion"> No description.</dsp:valueof> </dsp:oparam> </dsp:droplet> 12 ATG Hints by Kate Soglaeva
  13. 13. 13 ATG Hints by Kate Soglaeva
  14. 14. 1. Go to jsp 2. Go to Cache droplet 3. Go to product 4. Refresh cache droplet page 14 ATG Hints by Kate Soglaeva
  15. 15. <dsp:droplet name="/atg/dynamo/droplet/RQLQueryForEach"> <dsp:droplet name="/atg/targeting/RepositoryLookup"> <dsp:param bean="/atg/demo/QuincyFunds" name="repository"/> <dsp:param name="itemDescriptor" value="user"/> <dsp:param name="queryRQL" value="id=elementId"/> <dsp:param name="id" param="elementId"/> <dsp:oparam name="output"> <<dsp:valueof param="element.fundName"/> </dsp:oparam> </dsp:droplet> 15 ATG Hints by Kate Soglaeva
  16. 16. RQLQueryRange <dsp:droplet name="SQLQueryRange"> <dsp:param name="dataSource" bean="/atg/dynamo/service/jdbc/JTDataSource"/> <dsp:param name="querySQL" value="select * from SKIER order by name"/> <dsp:oparam name="output"> <dsp:valueof param="element.name"/> </dsp:oparam> </dsp:droplet> 16 ATG Hints by Kate Soglaeva
  17. 17. » Use in droplets: ˃ *Range ˃ *ForEach ˃ Targeting* » Use servlet bean ˃ Avoid retrieving large arrays of data 17 ATG Hints by Kate Soglaeva
  18. 18. 1. Go to stores page 2. Check code 3. Add sort properties 4. Add Range droplet 18 ATG Hints by Kate Soglaeva
  19. 19. 19 ATG Hints by Kate Soglaeva
  20. 20. <item-descriptor name=“myHoliday" display-property="name" > <table name="tc_holiday" id-column-name="id"> <property name="id"></property> <property name="name"></property> </table> </item-descriptor> 20 ATG Hints by Kate Soglaeva Noun Camel case lowercase , ‘_’
  21. 21. <property name="favouriteColours" data-type="array“ column-name="favourite_colours” component-data-type="string" /> 21 ATG Hints by Kate Soglaeva Noun Camel case lowercase , ‘_’
  22. 22. public class King extends GenericService { private RqlStatement weaponQuery; } 22 ATG Hints by Kate Soglaeva
  23. 23. # /com/kings/Arthur $class=com.kingdom.King $scope=global weaponQuery=name = ?0 23 ATG Hints by Kate Soglaeva
  24. 24. public class King extends GenericService { protected static RqlStatement weaponQuery; static { try { weaponQuery = RqlStatement.parseRqlStatement("name = ?0"); } catch (RepositoryException re) { re.printStackTrace(); } } } 24 ATG Hints by Kate Soglaeva
  25. 25. public String getLogin(String repositoryId, String profileType) { RepositoryItem profileItem = getProfileRepository(). getItem(getRepositoryId(), getProfileType()); String loginPropertyName = getPropertyManager().getLoginPropertyName(); String login = (String) profileItem. getPropertyValue(loginPropertyName); return login; } 25 ATG Hints by Kate Soglaeva
  26. 26. <item-descriptor name=“authur”> <property name=“address" item-type=“address“ cascade="update,delete" /> </item-descriptor> 26 ATG Hints by Kate Soglaeva
  27. 27. » Property in the same group is retrieve in the same select statement » Be default: property in the same group are in the same table 27 ATG Hints by Kate Soglaeva
  28. 28. Never user one primary table in more than one item descriptor Avoid derived properties Don’t use derived and transient in RQL 28 ATG Hints by Kate Soglaeva
  29. 29. ATG Hints by Kate Soglaeva 29
  30. 30. 30 ATG Hints by Kate Soglaeva
  31. 31. » ATG Order object must follow a specific transactional pattern to avoid ˃ exceptions and deadlocks, ˃ ConcurrentUpdateExceptions, ˃ InvalidVersionExceptions 31 ATG Hints by Kate Soglaeva
  32. 32. TransactionLockService service = configuration.getTransactionLockFactory().getServiceInstance( profileId, <logger component> ); service.acquireTransactionLock( profileId ); try { TransactionDemarcation td = new TransactionDemarcation(); td.begin( transactionManager ); boolean shouldRollback = false; try { synchronized( order ) { // do order updates orderManager.updateOrder( order ); } } catch ( ... e ) { shouldRollback = true; throw e; } finally { td.end( shouldRollback ); } } finally { service.releaseTransactionLock( profileId ); } 32 ATG Hints by Kate Soglaeva 1) Obtain local-lock on profile ID 2) Begin Transaction 3) Synchronize on Order 4) Modify Order 5) Call OrderManager.updateOrder 6) End Synchronization 7) End Transaction 8) Release local-lock on profile ID
  33. 33. Verify that the PageFilter in web.xml Pre-Compiling JSPs Recheck components scope Disable Performance Monitor Check loggingDebug
  34. 34. 34 ATG Hints by Kate Soglaeva

×