Friday, May 8, 2015

How to submit a form using javascript in ATG

Today I spent lots of time to figure out how to submit a form in ATG platform. I tired many times and with the help of Google, I finally find the solution,

1. make sure to set type="hidden" to the input field of the formHandler  handleXXX method, like this:

<dsp:form id="myForm">
   ....
  .....
   <dsp:input type="hidden"  bean="MyFormHandler.handleMethod" value="" />

</dsp:form>


2. in  your javascript method, you just need to call:

$(#myForm).submit();


I found when I typed type="submit" for the input field, and  the handleXXX method is never called when the form is submitted through the javascript.

Resources:
1. https://community.oracle.com/thread/2471843
2. http://stackoverflow.com/questions/29300501/atg-formhandlerneed-to-set-some-values-before-calling-the-handle-method
3. http://www.mkthakral.com/j2ee/oracle-atg/atg-formhandler-ajax-call-using-jquery-json/

Wednesday, May 6, 2015

How to mock a for loop using mockito

Today when I tried to use mockito to write unit test cases, I found I need to mock the for loop operation. Then I found the solution from here in stackoverflow: the basic idea is to mock the iterator class and collection class, and base on your situation, you need to set the expectation of iterator.hasNext() and iterator.next() method.

The following code is copied from the above link:

Saturday, May 2, 2015

Groovy's powerful collection methods

Recently I just realize Groovy provides some handy methods for collections.

Permutations

Combinations

Subsequences
Intersect

Friday, May 1, 2015

Review of the talk: "Complexity is Outside of the Code"


Broadcast live streaming video on Ustream


Yesterday I watched the video: "Complexity is Outside of the Code" by Dan North and Jessica Kerr at craft conference 2015.  Here I summarize what I learned.

Learning
  • Learning is a first class task.
  • Follow the process: explore, evaluate, familiarize, understand and validate
  • Lean startup's "build-measure-learn" cycle, nothing should be built without any reason.
business impact <- learn <- measure <- test <- code
Dan uses the Kanban's pull based concept to describe the above concept: for example test pulls the code, business pulls the learn. This drives me to think more about TDD, in TDD we believe we should never start coding without a failing test.(Uncle Bob's 3 laws of TDD),  which is quite similar with the lean startup concept: "nothing should be built without any reason",  in TDD, the failing test is the only reason for coding, which means the failing tests pulls the code, Bingo! Now I understand why Kent beck said TDD is Kanban for code


The Goal of software development
The goal of software development is to sustainably minimize lead time to business impact

Develop a supportive community
  • Nurturing a supporting team is vital within software development
  • It is OK to point out bad things and not have a solution
  • Reduce specialist silos, encourage becoming generalist
  • Developing a supportive community, contribute open source to other teams

Resources
http://www.ustream.tv/recorded/61439914
http://www.infoq.com/news/2015/04/north-kerr-complexity-code
http://www.slideshare.net/jessitron/complexity-is-outside-the-code