You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by lucast <lu...@hotmail.com> on 2011/04/25 14:32:03 UTC

Continue navigating while on submit button process stuff on the background

Dear Forum,
I have a simple tabbed view object page with a notify button that when the
user clicks on the button, it emails a long list of people with information
about the concerning the object.

Some objects have a list of 100+ email addresses and clicking on submit
stops me from continuing visiting other tabbed pages until the email class
has finished sending all the emails (40 seconds afterwards).

How can implement the notify button so that it emails people on the
background AND allows me to continue navigating out of the current view
tabbed page into another page?

Thanks in advance,
Lucas

The button i'm implementing is simple:
new Button ("notifyButton"){
	@Override
	public void onSubmit() {
		EmailServices emailService = new EmailNotificationService();
		emailService.notifyMailingList(object);
	}
};



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3473026.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Continue navigating while on submit button process stuff on the background

Posted by MZ...@osc.state.ny.us.
....or if you are not using Spring...use Java Futures...

http://download.oracle.com/javase/6/docs/api/java/util/concurrent/Future.html



From:   lucast <lu...@hotmail.com>
To:     users@wicket.apache.org
Date:   04/25/2011 08:32 AM
Subject:        Continue navigating while on submit button process stuff 
on the background



Dear Forum,
I have a simple tabbed view object page with a notify button that when the
user clicks on the button, it emails a long list of people with 
information
about the concerning the object.

Some objects have a list of 100+ email addresses and clicking on submit
stops me from continuing visiting other tabbed pages until the email class
has finished sending all the emails (40 seconds afterwards).

How can implement the notify button so that it emails people on the
background AND allows me to continue navigating out of the current view
tabbed page into another page?

Thanks in advance,
Lucas

The button i'm implementing is simple:
new Button ("notifyButton"){
                 @Override
                 public void onSubmit() {
                                 EmailServices emailService = new 
EmailNotificationService();
                                 emailService.notifyMailingList(object);
                 }
};



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3473026.html

Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org






Notice: This communication, including any attachments, is intended solely 
for the use of the individual or entity to which it is addressed. This 
communication may contain information that is protected from disclosure 
under State and/or Federal law. Please notify the sender immediately if 
you have received this communication in error and delete this email from 
your system. If you are not the intended recipient, you are requested not 
to disclose, copy, distribute or take any action in reliance on the 
contents of this information.

Re: Continue navigating while on submit button process stuff on the background

Posted by lucast <lu...@hotmail.com>.
Yes, you are right. I have realised that if all I want the thread to do is to
send emails then all I need to pass is the necessary parameters. 
There is no need to access wicket components from inside the search. With
this exclusions, the functionality is more modular.
Cheers,
Lucas

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3506961.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Problem with PaginNavigator/DataView and popup link

Posted by jl...@anticipa-solutions.com.
Hi,

I am fairly new to wicket so if I am missing obvious please forgive me. I am 
displaying a list of items with a DataView (a PageableListView is the same) 
and a PagingNavigator. Everything works fine, I can view all elements in any 
page but the moment I click on the Link to open a pop up the Navigation does 
not seem to work any more, as if the url in the navigator is out of 
sync..... below is a the code if anyone could help I would be really 
greatful.

Regards
José

		final DataView products = new DataView("products", new ListDataProvider(
				productlist),15)

		{
			public void populateItem(final Item item)
			{
				CProduct prod = (CProduct) item.getModelObject();				item.add(new 
Label("name", prod.getName()));

				Link detailsLink = new Link("more", item.getModel())
				{
					@Override
					public void onClick()
					{
						CProduct prod = (CProduct)getModelObject();
						PageParameters pars = new PageParameters();
						pars.add("productid", prod.getID()+"");
						setResponsePage(ViewProductPage.class, pars);
					}
				};


				detailsLink .setPopupSettings(new PopupSettings(PopupSettings.RESIZABLE 
|
						PopupSettings.SCROLLBARS).setHeight(500).setWidth(700));
				item.add(detailsLink );

				// Image
			final BufferedDynamicImageResource resource = new 
BufferedDynamicImageResource();				BufferedImage 
img = getApp().getValidImage(prod.getPicture());		 
        resource.setImage((BufferedImage)img);
		        item.add(new Image("image", resource));			}
		};


		add(products);
    	add(new PagingNavigator("navigator", products));

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Continue navigating while on submit button process stuff on the background

Posted by jcgarciam <jc...@gmail.com>.
Hi, putting configuration aside of your first question (since i just made a
comment, for the sake of best practice). Back to your original question and
since you are using Spring, you can just use Spring facilities to Schedule
the jobs an pass the appropriate parameters (list of objects) to
the appropriate async service

http://static.springsource.org/spring/docs/2.5.x/reference/scheduling.html

<http://static.springsource.org/spring/docs/2.5.x/reference/scheduling.html>But
keep in mind the following, from a Thread you shouldn't access any wicket
component since those are bound the Http Thread, which at the point when the
jobs runs the request would be gone.



On Sat, May 7, 2011 at 6:26 AM, lucast [via Apache Wicket] <
ml-node+3505262-1989378023-65838@n4.nabble.com> wrote:

> @jcgarciam,
> Thanks for your post. Sorry it took me so long to reply.
> Yes, I am using component instantiation listener on my wicket app.
>
> I think I might have not explained things properly in my last post. For the
> sake of clarity, I'm posting my web.xml and applicationContext set up:
>
> On my WicketApplication class I have the following, also based on the
> wicket in action book:
> public class WicketApplication extends WebApplication {
>
>        @Autowired
>         private ObjectService objects_service;
>
>         @Override
>         protected void init() {
>                 addComponentInstantiationListener(new
> SpringComponentInjector(this));
>         }
>
> My spring/hibernate set-up is also similar to the wicket in Action book :
>
> My web.xml file has the following hibernate session filter (wicket in
> action book, section 12.3.2):
> <filter>
>                 <filter-name>opensessioninview</filter-name>
>                 <filter-class>
>
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
>         </filter>
>         <filter-mapping>
>                 <filter-name>opensessioninview</filter-name>
>                 <url-pattern>/*</url-pattern>
>         </filter-mapping>
>
>
>         <context-param>
>                 <param-name>contextConfigLocation</param-name>
>                 <param-value>/WEB-INF/applicationContext.xml</param-value>
>         </context-param>
>         <listener>
>
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>         </listener>
>
>
> On the applicationContext.xml file I have the following:
> <tx:annotation-driven />
> <bean id="wicketApplication" class="com.myApp.WicketApplication">
> </bean>
>  ...
>
> I think the whole set up is pretty much standard but if you think I am
> missing something, then I'd be most grateful if you point it out.
> Cheers,
> Lucas
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3505262.html
>  To start a new topic under Apache Wicket, email
> ml-node+1842946-398011874-65838@n4.nabble.com
> To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
>
>



-- 

JC


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3505480.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Continue navigating while on submit button process stuff on the background

Posted by lucast <lu...@hotmail.com>.
@jcgarciam, 
Thanks for your post. Sorry it took me so long to reply.
Yes, I am using component instantiation listener on my wicket app. 

I think I might have not explained things properly in my last post. For the
sake of clarity, I'm posting my web.xml and applicationContext set up:

On my WicketApplication class I have the following, also based on the wicket
in action book:
public class WicketApplication extends WebApplication {

       @Autowired
	private ObjectService objects_service;

        @Override
	protected void init() {
		addComponentInstantiationListener(new SpringComponentInjector(this));
	}

My spring/hibernate set-up is also similar to the wicket in Action book :

My web.xml file has the following hibernate session filter (wicket in action
book, section 12.3.2):
<filter>
		<filter-name>opensessioninview</filter-name>
		<filter-class>
		
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
	</filter>
	<filter-mapping>
		<filter-name>opensessioninview</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>


	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext.xml</param-value>
	</context-param>
	<listener>
	
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>


On the applicationContext.xml file I have the following:
<tx:annotation-driven />
<bean id="wicketApplication" class="com.myApp.WicketApplication">
</bean>
 ...

I think the whole set up is pretty much standard but if you think I am
missing something, then I'd be most grateful if you point it out.
Cheers,
Lucas

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3505262.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Continue navigating while on submit button process stuff on the background

Posted by jcgarciam <jc...@gmail.com>.
Lucast is not good idea to make the Wicket application and spring bean
directly (can't remember why, but look for it into the archive), instead the
use of the CompenentInstantiaionListener is the recommended with the
companion of the wicket @SpringBean annotation.



On Thu, Apr 28, 2011 at 8:31 AM, lucast [via Apache Wicket] <
ml-node+3480723-1382859170-65838@n4.nabble.com> wrote:

> Thank you Mzemeck,
> I am using Spring and I tried implementing @Async but for some reason when
> I fired up my wicket app it complained that it couldn't find the beans.
> I think it must have been because I'm declaring all of my spring managed
> beans (including my wicketApplication class) on my applicationContext file.
>
> Looking at the Task Execution and Scheduling<http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#scheduling>
> section of the spring reference manual, I decided to use a TaskExecutor<http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#scheduling-task-executor-usage> instead
> of using @Async annotations and it works perfectly with my current spring
> settings.
>
> I am autowiring spring beans on my WicketAppliation class. And I noticed
>  that calling WicketApplication.get() from the taskExecutor kept throwing a
> "WicketRuntimeException: There is no application attached to current thread
> taskExecutor-1" exception.
> I realised that I didn't need to call my db services from the taskExecutor
> since none of those tasks are time consuming, the sending emails is what is
> time consuming and that's what I limited the functionality of taskExecutor
> to.
>
> Thanks, once more for your help.
> Lucas
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3480723.html
>  To start a new topic under Apache Wicket, email
> ml-node+1842946-398011874-65838@n4.nabble.com
> To unsubscribe from Apache Wicket, click here<http://apache-wicket.1842946.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1842946&code=amNnYXJjaWFtQGdtYWlsLmNvbXwxODQyOTQ2fDEyNTYxMzc3ODY=>.
>
>



-- 

JC
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3486071.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Continue navigating while on submit button process stuff on the background

Posted by lucast <lu...@hotmail.com>.
Thank you Mzemeck,
I am using Spring and I tried implementing @Async but for some reason when I
fired up my wicket app it complained that it couldn't find the beans.
I think it must have been because I'm declaring all of my spring managed
beans (including my wicketApplication class) on my applicationContext file. 

Looking at the 
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#scheduling
Task Execution and Scheduling   section of the spring reference manual, I
decided to use a 
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#scheduling-task-executor-usage
TaskExecutor  instead of using @Async annotations and it works perfectly
with my current spring settings.

I am autowiring spring beans on my WicketAppliation class. And I noticed 
that calling WicketApplication.get() from the taskExecutor kept throwing a
"WicketRuntimeException: There is no application attached to current thread
taskExecutor-1" exception.
I realised that I didn't need to call my db services from the taskExecutor
since none of those tasks are time consuming, the sending emails is what is
time consuming and that's what I limited the functionality of taskExecutor
to.

Thanks, once more for your help.
Lucas

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3480723.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Continue navigating while on submit button process stuff on the background

Posted by MZ...@osc.state.ny.us.
Send your emails in a batch at a later time, or if you are using Spring 
you could use the new @Async annotation.




From:   lucast <lu...@hotmail.com>
To:     users@wicket.apache.org
Date:   04/25/2011 08:32 AM
Subject:        Continue navigating while on submit button process stuff 
on the background



Dear Forum,
I have a simple tabbed view object page with a notify button that when the
user clicks on the button, it emails a long list of people with 
information
about the concerning the object.

Some objects have a list of 100+ email addresses and clicking on submit
stops me from continuing visiting other tabbed pages until the email class
has finished sending all the emails (40 seconds afterwards).

How can implement the notify button so that it emails people on the
background AND allows me to continue navigating out of the current view
tabbed page into another page?

Thanks in advance,
Lucas

The button i'm implementing is simple:
new Button ("notifyButton"){
                 @Override
                 public void onSubmit() {
                                 EmailServices emailService = new 
EmailNotificationService();
                                 emailService.notifyMailingList(object);
                 }
};



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Continue-navigating-while-on-submit-button-process-stuff-on-the-background-tp3473026p3473026.html

Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org






Notice: This communication, including any attachments, is intended solely 
for the use of the individual or entity to which it is addressed. This 
communication may contain information that is protected from disclosure 
under State and/or Federal law. Please notify the sender immediately if 
you have received this communication in error and delete this email from 
your system. If you are not the intended recipient, you are requested not 
to disclose, copy, distribute or take any action in reliance on the 
contents of this information.