Wednesday, October 14, 2009
Remove table rows dynamically using javascript
{
var tb2 = document.getElementById('ServicesTable');//table id
var lastRow = tb2.rows.length;
while (lastRow > 1) {
try{
lastRow--;
tb2.deleteRow(lastRow);
}catch(e){
}
}
}
Create Dynamic HTML table using JavaScript
JAVASCRIPT CODE
<script type="text/javascript">
function addRowToTable(name,address,tele,fax){
try {
var w = name;
var x = address;
var y = tele;
var z= fax;
var tbl = document.getElementById('ServicesTable');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
if(lastRow % 2 ==0)
row.className="rowgrey";
else
row.className="buttons";
row.height=25;
var secondCell = row.insertCell(0);
var textNode2 = document.createTextNode(w);
secondCell.appendChild(textNode2);
var thirdCell = row.insertCell(1);
var textNode3 = document.createTextNode(x);
thirdCell.appendChild(textNode3);
var fourthCell = row.insertCell(2);
var textNode4 = document.createTextNode(y);
fourthCell.appendChild(textNode4);
var fifthCell = row.insertCell(3);
var textNode5 = document.createTextNode(z);
fifthCell.appendChild(textNode5);
} catch (e) {
}
}
</script>
HTML CODE
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="bodyTable" height="35" id="ServicesTable" >
<tr>
<td width="30%" height="31" align="left" class="tableTitle"><span class="style1">Company Name </span></td>
<td width="40%" height="31" align="left" class="tableTitle"><span class="style1">Address</span></td>
<td width="15%" height="31" align="left" class="tableTitle"><span class="style1">Tele. No. </span></td>
<td width="15%" height="31" align="left" class="tableTitle"><span class="style1">Fax No.</span></td>
</tr>
</table>
Monday, September 21, 2009
Lazy initilasation in Hibernate
An attribute 'lazy' can be used to let Hibernate know if the associated entity or collection has to be lazily loaded or prefetched.
This causes the collection to be eagerly fetched rather than doing a lazy fetch. If on the other hand , the attribute value of lazy is set to true, then hibernate will not make an attempt to fire the query for fetching the collection object until the request is made by the user.
Wednesday, September 2, 2009
delete user from LDAP
String dn = String.valueOf(String.valueOf((new StringBuffer("uid=")).append(username).append(", ou=").append(ou).append(", o=").append(organization)));
ld.delete(dn);
System.out.println("Entry deleted");
return true;
}
Tuesday, September 1, 2009
Send sms using Gammu 1.18
2.setup configuration file
3.add system path to gammu bin directory
4.open command prompt and type below code
c:\>gammu identify
then your phone details should be display otherwise gammu not configured
after that you can send massage using this
c:\>echo Test_Massage_body | gammu nothing --sendsms TEXT +94777123456
Gammu 1.18 Configuration file
port = com8:
;model = 6110
connection = irdaphonet
name=
model=
;synchronizetime = yes
;logfile = gammulog
;logformat = textall
;use_locking = yes
;gammuloc = locfile
;startinfo = yes
;gammucoding = utf8
;usephonedb = yes
I have working example for gammu 1.8 if you having any problem using gammu please contact me somehow I can help you
Java Mail
boolean sucess = false;
Properties props = new Properties();
props.put("mail.smtp.host", "XXX.XXX.XXX.XXX");//SMTP Host
Session sessions = Session.getInstance(props, null);
sessions.setDebug(false);
Message msg = new MimeMessage(sessions);
try {
msg.setFrom(new InternetAddress(from));
msg.setRecipients(javax.mail.Message.RecipientType.TO, InternetAddress.parse(to, false));
msg.setRecipients(javax.mail.Message.RecipientType.CC, InternetAddress.parse(cc, false));
msg.setRecipients(javax.mail.Message.RecipientType.BCC, InternetAddress.parse(bcc, false));
msg.setSubject(subject);
MimeMultipart mp = new MimeMultipart();
mp.setSubType("related");
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setContent(mail, "text/html");
mbp1.setHeader("X-Mailer", "Details");
MimeBodyPart mbp2 = new MimeBodyPart();
MimeBodyPart mbp3 = new MimeBodyPart();
mp.addBodyPart(mbp1);
msg.setContent(mp);
msg.setSentDate(new Date());
sucess = true;
}
catch (MessagingException e) {
e.printStackTrace();
sucess = false;
}
try {
Transport.send(msg);
sucess = true;
}
catch (MessagingException e) {
e.printStackTrace();
sucess = false;
}
return sucess;
}