form.listboxname.options[1].selected = true;
Select 2nd Item In Listbox
27 09 2007Comments : Leave a Comment »
Categories : Javascript
Create List Of Dates With DynaBean
27 09 2007Create list of dates (last 6 months) to populate listbox in .jsp.
// get search date listbox
DynaBean dateBean = new LazyDynaBean();
List<DynaBean> dateList = new ArrayList<DynaBean>();
SimpleDateFormat formatter = new SimpleDateFormat("MMM yyyy");
// display 6 months starting from current month
Calendar cal = Calendar.getInstance();
// get current date
cal.setTime(new Date());
for(int i=0; i<5; i++) {
dateBean = new LazyDynaBean();
dateBean.set("property", formatter.format(cal.getTime()));
dateBean.set("value", cal.getTime());
// add to list
dateList.add (dateBean);
// subtract 1 month
cal.add(Calendar.MONTH, -1);
}
// send to form bean (type="java.util.List")
PropertyUtils.setUtils(form, "datelist", dateList);
in .jsp
<bean:define id="dates" name="MyFormName" property="datelist"/>
<html:select property="s_valueDate" value='<%= request.getParameter("s_valueDate") %>'> <html:options collection="dates" property="value" labelProperty="property"/>
</html:select>
Comments : Leave a Comment »
Categories : Java, Struts
Get Last Date Of The Month
27 09 2007String valueDate= "09/2007";
Calendar cal = Calendar.getInstance();
cal.setTime(new SimpleDateFormat("MM/yyyy").parse(valueDate));
String endDate = cal.getActualMaximum(Calendar.DAY_OF_MONTH) + "/"+ valueDate;
endDate = 30/09/2007;
Comments : Leave a Comment »
Categories : Java
Setup SVN + XCode
23 09 2007Been seriously bonding with Mac OS X lately and Mac sure kicks Windows arse big time in terms of look and feel and stability.
But developing for Mac… urgh.. now i know why there’s not many apps. for Mac *hugs* Visual Studio
Installing Subversion
1. Install FINK
2. Open “Terminal” and install svn command by entering “fink install svn-client-ssl”
3. Checkout project: svn co https:….
Commit: svn commit
Update: svn update
View Status: svn status
Setting Up SVN in XCode
1. Open checked out project with XCode
2. Right-click project -> “Get Info”
3. In “General” tab -> Check “Enable SCM”
Select “SCM System: Subversion”
4. Subversion menu is in “SCM”
Problem with SCM is there’s no success/fail notification after updating/committing and usually have to commit the project twice. Using the Terminal is way more practical but having to $cd and $cd and $cd to get to the project folder is such a pain so I’d rather commit twice in XCode and wait for the email notification.
I live in the 20th century and all things GUI
Update – 10 Nov 2007
SVN in XCode sucks.
svnX 0.9.13 is bucketloads better!
Comments : Leave a Comment »
Categories : SVN, XCode
Set Not To Store Page In Cache
11 09 2007<head>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
</head>
Comments : Leave a Comment »
Categories : JSP, Java, Struts
Javascript Alert Form Bean
4 09 2007<logic:notEmpty name="LoginForm" property="javascriptAlertMsg">
<script>alert('<bean:write name="LoginForm" property="javascriptAlertMsg"/>')</script>
</logic:notEmpty>
Comments : Leave a Comment »
Categories : Javascript, Struts
Javascript Alert Messages From Message Resource
4 09 2007alert('<bean:message key="MSG001"/>');
Validation Message:
var fieldname = '<bean:message key="fieldname.amount"/>';
var errorMsg = '<bean:message key=" errors.float" arg0="'+fieldname+'"/>';
alert(errorMsg);
In Message Resource:
MSG001 Hello world!
fieldname.amount Payment Amount
errors.float {0} is not a float
Comments : 5 Comments »
Categories : Javascript, Struts