Wednesday 4 November 2015

IsEmpty and IsNull in ATG

Java differences 


StringUtils.isEmpty()   : checks empty or null)

StringUtils.isEmpty("")        = true
StringUtils.isEmpty(null)      = true
StringUtils.isEmpty(" ")       = false
StringUtils.isEmpty("hoo")     = false
StringUtils.isEmpty("  omg  ") = false




StringUtils.isBlank() : checks white space,null ,empty

 StringUtils.isBlank(null)      = true
 StringUtils.isBlank("")        = true
 StringUtils.isBlank(" ")       = true
 StringUtils.isBlank("hoo")     = false
 StringUtils.isBlank("  omg  ") = false

ATG Droplets


isEmpty Droplet in Atg  :
                            Here we are checking hobbies are empty or not in MyProfile.

 <dsp:importbean bean="atg/dynamo/droplet/IsEmpty"/>
  <dsp:importbean bean="atg/dynamo/droplet/ForEach"/>
 <dsp:droplet name="IsEmpty">
   <dsp:param name="value" bean="MyProfile.hobbies"/>
   <dsp:oparam name="false">
      Your hobbies are:
        <dsp:droplet name="ForEach">
           <dsp:param name="array" bean="MyProfile.hobbies"/>
           <dsp:oparam name="output">
              <dsp:valueof param="element"/>
           </dsp:oparam>
        </dsp:droplet>
   </dsp:oparam>
   <dsp:oparam name="true">
      All work and no play makes Jack a dull boy.
   </dsp:oparam>
</dsp:droplet>


IsNull Droplet in Atg :
                                     Here we are checking email is null or not in MyProfileFormHandler,if its null
we are updating it with the user provided value.

 <dsp:importbean bean="atg/dynamo/droplet/IsNull"/>
  <dsp:droplet name="IsNull">
  <dsp:param bean="MyProfile.email" name="value"/>
  <dsp:oparam name="true">
    <dsp:form action="address_book.jsp" method="POST">
      My email address:
      <dsp:input type="text" bean="MyProfileFormHandler.email"/>
      <dsp:input type="submit" bean="MyProfileFormHandler.update value="Update"/>
    </dsp:form>
  </dsp:oparam>
</dsp:droplet>



No comments:

Post a Comment