Fusebox 101: Using switch and case verbs
As part of my fusebox 101 updates I've decided to show how to use the switch and case verb in fusebox.
Here is the code you will need (you can easily spot the similarities):
<cf:case value="1">
<set name="attributes.processDate" value="#dateFormat(dateAdd('m',12,now()),'dd/mm/yyyy')#" overwrite="true" />
</cf:case>
<cf:case value="2">
<set name="attributes.processDate" value="#dateFormat(dateAdd('m',24,now()),'dd/mm/yyyy')#" overwrite="true" />
</cf:case>
<cf:case value="3">
<set name="attributes.processDate" value="#dateFormat(dateAdd('m',36,now()),'dd/mm/yyyy')#" overwrite="true" />
</cf:case>
<cf:defaultcase>
<set name="attributes.processDate" value="#dateFormat(dateAdd('m',12,now()),'dd/mm/yyyy')#" overwrite="true" />
</cf:defaultcase>
</cf:switch>
All we are doing here is checking for a licenceType variable attributes.licenceType, from this the switch statement calls the correct case statement and sets a variable called attributes.processDate. We then set a defaultcase statement which will catch a licenceType that doesn't matche the case statements we've setup. Nice and clean.






There are no comments for this entry.
[Add Comment]