Combination View Flat View Tree View
Threads [ Previous | Next ]
abc xyz
sms integration in liferay
January 28, 2013 9:58 PM
Answer

abc xyz

Rank: New Member

Posts: 11

Join Date: January 4, 2013

Recent Posts

hi,
this is my sms code in calender event,i created ca;ender edit_event.jsp hook inside that created SampleStrutsPortletAction.java class bt when selecting sms ,m getting number,the process action method is invoking but inside that sms code is not invoking,plzz help me out..

edit_event.jsp
String test=BeanParamUtil.getString(event, request, "remindBy");
int remindBy1 = BeanParamUtil.getInteger(event, request, "remindBy", CalEventConstants.REMIND_BY_SMS);
if(remindBy1==CalEventConstants.REMIND_BY_SMS){
if(Validator.isNull(test)){
int count = UserLocalServiceUtil.getCompanyUsersCount(10153);
List<User> dataList= UserLocalServiceUtil.getUsers(0, count);

User usr = PortalUtil.getUser(request);
String username = usr.getScreenName();
System.out.println(username);

for(User ge2: dataList)
{
System.out.println(ge2.getScreenName());
if(ge2.getScreenName().equals(username)){

for(Phone ce1: ge2.getPhones()){
if(ce1.getPrimary()){

System.out.println(" ID: " + ce1.getPhoneId());
System.out.println(" ID: " + ce1.getNumber());
test=ce1.getNumber();
}


}
}

}
}else{
System.out.println("inserted");
}
}else{
System.out.println("insert Number");
}


<aui:field-wrapper cssClass="reminders" label="" name="reminderName">
<aui:input checked="<%= remindBy == CalEventConstants.REMIND_BY_NONE %>" label="do-not-send-a-reminder" name="remindBy" type="radio" value="<%= CalEventConstants.REMIND_BY_NONE %>" />
<aui:input checked="<%= remindBy == CalEventConstants.REMIND_BY_EMAIL %>" label='<%= LanguageUtil.get(pageContext, "email-address") + " (" + user.getEmailAddress() + ")" %>' name="remindBy" type="radio" value="<%= CalEventConstants.REMIND_BY_EMAIL %>" />
<aui:input checked="<%= remindBy1 == CalEventConstants.REMIND_BY_SMS %>" label='<%= LanguageUtil.get(pageContext, "sms") + (Validator.isNotNull(test) ? " (" + test + ")" : "") %>' name="remindBy" type="radio" value="<%= CalEventConstants.REMIND_BY_SMS %>" />
<aui:input checked="<%= remindBy == CalEventConstants.REMIND_BY_AIM %>" label='<%= LanguageUtil.get(pageContext, "aim") + (Validator.isNotNull(contact.getAimSn()) ? " (" + contact.getAimSn() + ")" : "") %>' name="remindBy" type="radio" value="<%= CalEventConstants.REMIND_BY_AIM %>" />
<aui:input checked="<%= remindBy == CalEventConstants.REMIND_BY_ICQ %>" label='<%= LanguageUtil.get(pageContext, "icq") + (Validator.isNotNull(contact.getIcqSn()) ? " (" + contact.getIcqSn() + ")" : "") %>' name="remindBy" type="radio" value="<%= CalEventConstants.REMIND_BY_ICQ %>" />
<aui:input checked="<%= remindBy == CalEventConstants.REMIND_BY_MSN %>" label='<%= LanguageUtil.get(pageContext, "windows-live-messenger") + (Validator.isNotNull(contact.getMsnSn()) ? " (" + contact.getMsnSn() + ")" : "") %>' name="remindBy" type="radio" value="<%= CalEventConstants.REMIND_BY_MSN %>" />
<aui:input checked="<%= remindBy == CalEventConstants.REMIND_BY_YM %>" label='<%= LanguageUtil.get(pageContext, "yim") + (Validator.isNotNull(contact.getYmSn()) ? " (" + contact.getYmSn() + ")" : "") %>' name="remindBy" type="radio" value="<%= CalEventConstants.REMIND_BY_YM %>" />
</aui:field-wrapper>



SampleStrutsPortletAction.jsp


@Override
public void processAction(StrutsPortletAction originalStrutsPortletAction,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {
System.out.println("hii");
CalEvent event = (CalEvent)actionRequest.getAttribute(WebKeys.CALENDAR_EVENT);
String remind=actionRequest.getParameter("remindBy");
System.out.println(remind);

// sending sms code
URL url;
HttpURLConnection connection = null;




String stringpost = "username=" + "xyz" + "&pass=" + "123456" + "&senderid=" + "" + "&message=" + "testing"
+"&dest_mobileno="+ remind;
try{
url = new URL(" ");
System.out.println("hii");
connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Length", "" +
Integer.toString(stringpost.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");

connection.setUseCaches (false);
connection.setDoInput(true);
connection.setDoOutput(true);

DataOutputStream wr = new DataOutputStream (
connection.getOutputStream ());
wr.writeBytes (stringpost);
wr.flush ();
wr.close ();

//Get Response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer sresponse = new StringBuffer();
while((line = rd.readLine()) != null) {
sresponse.append(line);
sresponse.append('\r');
}
rd.close();
}catch (Exception e) {
e.printStackTrace();
return;
}finally{
if(connection != null) {
connection.disconnect();
}
}
originalStrutsPortletAction.processAction(portletConfig, actionRequest,
actionResponse);
}