Re: Sending Mail with GWT+Spring

114 views
Skip to first unread message

Ümit Seren

unread,
Apr 15, 2013, 4:05:45 AM4/15/13
to google-we...@googlegroups.com
?!
You can't have Spring Beans or resources on the client-side and you can't just simple execute a sever side function by calling it on the client side. 
You have to use RPC, RequestFactory or RequestBuilder to generate a request for the backend and then call the server-side function (in your case sending an email). 
I would strongly recommend to read the GWT docs and how to client-server communication works.


On Friday, April 12, 2013 5:39:49 PM UTC+2, vinu raju wrote:

can anybody help me , how to send the mail using gwt and spring.

i tried but getting error as : no source code is available for type org.springframework.core.io.Resource,did you forget the inherit a required module?

my code is this:

Client side:
Resource res = new ClassPathResource("classpath:context/applicationContext.xml");
       BeanFactory factory = new XmlBeanFactory(res);
       
       Object o = factory.getBean("id2");
       GreetingServiceImpl mail = (GreetingServiceImpl)o;
        //String password =result.getPassword();
 
       try {
mail.sendMail("fromvinu1","fromvinu1","forgotpassword",password);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Server side:

private MailSender mail;
public void setMail(MailSender mail)
     {
         this.mail = mail;
     }
public String sendMail(String from, String to,String subject,String msg) {
SimpleMailMessage message = new SimpleMailMessage();

    message.setFrom(from);
    message.setTo(to);
    message.setSubject(subject);
    message.setText(msg);

    mail.send(message); 
    System.out.println("Mail Sent Successfully...!");
   // return UserInfo;
return msg;

XML file:
<bean id="id1" class="org.springframework.mail.javamail.JavaMailSenderImpl">
     <property name="host" value="smtp.gmail.com" />
     <property name="port" value="465" />
     <property name="username" value="fromvinu1" />
     <property name="password" value="********" />
 
     <property name="javaMailProperties">
       <props>
         <prop key="mail.smtp.auth">true</prop>
         <prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
         <prop key="mail.smtp.socketFactory.port">465</prop>
         <prop key="mail.debug">true</prop>
         <prop key="mail.smtp.starttls.enable">true</prop>
       </props>
     </property>
</bean> 
 
<bean id="id2" class="package.GreetingServiceImpl">
<property name="mail" ref="id1" />
</bean>


Ümit Seren

unread,
Apr 16, 2013, 1:58:52 PM4/16/13
to google-we...@googlegroups.com
this is only possible if the java files/libraries that are in the client package can be translated/compiled to Javascript (or you provide an override via super-source).
Spring beans/service most definatley can't be translated to javascript 



On Mon, Apr 15, 2013 at 5:13 AM, Senyuan Wang <wang.s...@gmail.com> wrote:
I guess you put this service under the client package, which will be compiled into Javascript.
--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/5Ox4kxeI1wc/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages