Saturday, August 7, 2010

Invoking localhost from android emulator

If you are trying to invoke localhost from android emulator
http://localhost:8080... will not work.
If you are using windows you will have to get your ip address using ipconfig command and get your ipv4 address and use that insted of localhost.

setting up android for netbeans

This link will be helpful in setting up android plugin for netbeans

http://gerry.ws/2009/01/1074/how-to-setup-netbeans-for-android-development.html

Tuesday, July 7, 2009

Add default value to column in hibernate

private boolean invalid=false;

@Column(name="INVALID", columnDefinition = "BIT(1) default 0")
public boolean isInvalid() {
return invalid;
}
public void setInvalid(boolean invalid) {
this.invalid = invalid;
}

Should work for mysql only.

Monday, July 6, 2009

Junit and Spring

Here is sample code for Junit testing with spring/hibernate.

@ContextConfiguration(locations = { "/applicationContext-hibernate-test.xml" })
public class TestDaoImplTest extends AbstractJUnit4SpringContextTests {

@Autowired
TestDao testDao;

@Before
public void setUp() {


}

@After
public void tearDown() {

}

@Test
public void test() {
testDao.callyourmethod();

}
}

Wednesday, July 1, 2009

Convert Calendar to Date object java

Suppose the given date string is June, 30 2009

First we will make a Calendar object and convert it to Date Object

Calendar calendar = new GregorianCalendar(2009, 6 - 1, 30);
Date dateObject = new Date(calendar.getTimeInMillis());

So here it is, java.util.Calendar Object converted to java.util.Date object

Friday, June 12, 2009

Spring MVC 2.5 uploading a file using CommonsMultipartResolver

3 Steps to upload a file in Spring MVC 2.5 using CommonsMultipartResolver

Step 1)
in your servlet.xml or applicationContext.xml paste the following code
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- one of the properties overall request size(not file size) -->
<property name="maxUploadSize" value="100000"/>
</bean>


Step 2)
Code for Controller


@RequestMapping("/file-upload")
public ModelAndView uploadFile(
@RequestParam("file") CommonsMultipartFile file) {
//do whatever you want with the file object
return new ModelAndView();
}

step 3)
Html Code


<form action="file-upload.html" enctype="multipart/form-data" method="post">
<input name="file" type="file">
<input value="Upload" type="submit">
</form>

That's it. Questions or Comments?

Next post, redirect the user back to the entry form if the upload file size exceeded the maxUploadsize parameter. Also the form parameters entered along with file upload should be shown back. So the user does not have to re enter the previously entered values. Coming up in next post...

Thursday, September 13, 2007

Hurrican Humberto Pics




I went to bed Wednesday expecting just a little over a heavy downpour, only to be awakened at around 3 am by Category 1 Hurricane Mr. Humberto. The first hurricane experience in my life was awesome.
With around 80mph wind, blowing me, and heavens opening up, it was just too good an experience to miss. I just tried experimenting by putting a chair on the 2nd floor of the apartment and it was blown down to floor 1, and after some chilly windy moments there was power outrage. I tried to walk on the lawn outside the apartments at 4am only to find that the wind was too gusty to bear. Simply an awesome experience!!!!!!!!!!!