Friday, May 9, 2008

NYI - Not Yet Implemented error

If you are getting this error

Exception in thread "main" java.lang.RuntimeException: NYI at cryptix.jce.provider.elgamal.ElGamalCipher.engineGetParameters(ElGamalCipher.java:120) at javax.crypto.Cipher.a(DashoA12275)
Reason is the suns default policy doesn't have the strength to encrypt/decrypt with higher strength keys. Got to SUN downloads and install/replace it in you JRE/lib/security Other Downloads Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6

Wednesday, May 7, 2008

Formating Currencies and Dates in Struts 2

Create a Global message property so that the formating can be applied to all the pages name it globalMessages.properties

item.listprice = {0,number,$##0.00}
Now add the property to struts.properties
struts.custom.i18n.resources=globalMessages
Now how to Call the formating string in JSP where listprice comes from the stack and the formating string from the global resource we set earlier.
<s:text name="%{getText('item.listprice')}"> <s:param name="value" value="listprice"/> </s:text>
And now the Output
$12.20
Make sure to put the property files in the correct folder of your project.

Monday, April 21, 2008

Another Session Iteration

<s:if test="#session.cartitems.size > 0"> <table> <s:iterator value="#session.cartitems"> <tr id="row_<s:property value="itemid"/>"> <td> <s:property value="itemName" /> </td> <td> <s:property value="listprice" /> </td> <td> <s:url id="removeUrl" action="removeItemFromCart"> <s:param name="itemid" value="itemid" /> </s:url> <s:a href="%{removeUrl}" theme="ajax" targets="basket">Remove</s:a> <s:a id="a_%{id}" theme="ajax" notifyTopics="/edit">Edit</s:a> </td> </tr> </s:iterator> </table> </s:if>

Tuesday, April 1, 2008

Iterating a List Value Struts2

<s:if test=""> 0"> <s:iterator value="#session.categorys"> <li><a href="<s:url action="itemlisthome.action"><s:param name="catalogid" value="#session.catalogs[catalogid-1].id"> <s:param name="categoryid" value="#session.categorys[id-1].id"> </s:url>"> <s:property value="#session.categorys[id-1].name"> </a> </li> </s:iterator> </s:if><s:if test=""> </s:if>

Struts 2 Tips and Tricks

OGNL treats a character in single-quotes as an actual character, not a String. So this statement will not return your desired result.

<s:if test="%{state=='N'}"> This will work. <s:if test="%{state=='NE'}"> </s:if>

Monday, March 24, 2008

File Count in a Folder

Recently I found a command that displays the Number of files in a ls command listing: Code: ls -l | wc -l Above will find the number of files in a directory, and it will send o/p as pipe to the wc -l, which outputs the number of lines in its input. To display all file including hidden and dot files, try Code: ls -lA | wc -l

Friday, March 14, 2008

Stripping white space

s = s.replaceAll(" +", ""); Here is the String BFI NS-16 after the replace BFINS-16