You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by marino <ma...@di.unito.it> on 2008/12/01 13:21:55 UTC
updating a page when external event occurs
Hello,
I have a simple wicket application built around the DefaulDataTable example.
In the same program I have an Event Listener class which is called outside
the wicket application context. This class produces data that I would like
to show
in the current wicket page, but when I call any operation like add(),
replaceWith() ..
I always receive the message:
WicketRuntimeException: There is no application attached to current thread
...
........
What can I do?
Thanks,
Marino
--
View this message in context: http://www.nabble.com/updating-a-page-when-external-event-occurs-tp20770960p20770960.html
Sent from the Wicket - User 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: updating a page when external event occurs
Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Mon, 01 Dec 2008, marino wrote:
> I have a simple wicket application built around the DefaulDataTable example.
> In the same program I have an Event Listener class which is called outside
> the wicket application context. This class produces data that I would like
> to show
> in the current wicket page, but when I call any operation like add(),
> replaceWith() ..
Could you show us some code please? "Outside the Wicket
application context" sounds strange, does it mean another
thread?
> WicketRuntimeException: There is no application attached to current thread
Just about everything that you do with Wicket components
needs a couple of ThreadLocal variables initialised, the most
important of them being the Application (with Application.set() ).
But to know how to fix your issue exactly we need more data.
WicketSessionFilter might help.
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: updating a page when external event occurs
Posted by Timo Rantalaiho <Ti...@ri.fi>.
On Mon, 01 Dec 2008, marino wrote:
> // this is the event listener method itself, called from the Gigaspaces
> library
> // when some eventon their space is detected
It really sounds like it would be from within another
thread, right? The best way would be to refactor your code
so that Wicket code would only make the hierarchy change
during the request cycle.
To be able to do it like you're trying, you would have to
emulate request cycle processing in the notify() method (at
least set up the Application ThreadLocal), but it doesn't
sound as good as the other way.
Best wishes,
Timo
--
Timo Rantalaiho
Reaktor Innovations Oy <URL: http://www.ri.fi/ >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: updating a page when external event occurs
Posted by marino <ma...@di.unito.it>.
Excerpts from the listener class
// RemoteEventListener is an Interface of the GigaSpaces middleware
// the class is very similar to the example UserProvider , and holds a list
of user calendars;
// I omit here details
public class UserProvider extends SortableDataProvider implements
RemoteEventListener{
DataTablePage compo = null; // the page containing the DataTable
.........
// this is the event listener method itself, called from the Gigaspaces
library
// when some eventon their space is detected
public void notify(RemoteEvent theEvent) throws UnknownEventException,
RemoteException {
System.out.println("In notify!!");
Contact cc = new Contact(new Name("abc", "def"));
userList.add(cc)
// replace the previous defaultdatatable with this one, containing
one more user
compo.replaceTable(this);
System.out.println("\n\AFTER REPLACE\n\n");
}
// now the wicket page class
public class DataTablePage extends WebPage {
// similar to the example with this method added
.....
public void replaceTable(UserProvider userProvider){
List userList = userProvider.getUsers();
List columns = new ArrayList();
Iterator it = userList.iterator();
int i =0;
while (it.hasNext()) {
Contact s = (Contact) it.next();
columns.add( new PropertyColumn(new Model(s.getName().getFirst()),
"index"));
}
// THE NEXT LINE causes the error
table.replaceWith(new DefaultDataTable("datatable", columns,
userProvider, 10));
}
--
View this message in context: http://www.nabble.com/updating-a-page-when-external-event-occurs-tp20770960p20771378.html
Sent from the Wicket - User 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: updating a page when external event occurs
Posted by Igor Vaynberg <ig...@gmail.com>.
components should only be manipulated inside a servlet request. what
you should do i store the data somewhere and then let the components
update themselves during render by reading new data.
-igor
On Mon, Dec 1, 2008 at 4:21 AM, marino <ma...@di.unito.it> wrote:
>
> Hello,
>
> I have a simple wicket application built around the DefaulDataTable example.
> In the same program I have an Event Listener class which is called outside
> the wicket application context. This class produces data that I would like
> to show
> in the current wicket page, but when I call any operation like add(),
> replaceWith() ..
> I always receive the message:
>
> WicketRuntimeException: There is no application attached to current thread
> ...
> ........
>
> What can I do?
>
> Thanks,
>
> Marino
> --
> View this message in context: http://www.nabble.com/updating-a-page-when-external-event-occurs-tp20770960p20770960.html
> Sent from the Wicket - User 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: updating a page when external event occurs
Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
Hi marino,
You should consider using an IDataProvider implementation to handle the
data transfer between your external process and wicket.
The wicket page will update using the ajax timer and add the datatable
to the ajax request target to be rerendered (This looks to me what you
are currently doing).
The data will be provided by your IDataProvider implementation which can
handle the synchronization issues and cleanly separate the rendering
logic from how the data is generated.
For more information on how to do things in wicket look at the wiki here
: http://cwiki.apache.org/WICKET
The 'Reference Library' and 'New User Guide' pages are good starting points.
Regards,
Mike
> Here is how I solved the problem.
>
> I extended AjaxSelfUpdatingTimerBehavior and overrid onPostProcessTarget().
> inside method I replace the table wicket ( because the DefaultDataTable
> does not seem able to dynamically add column);
> I created a borderwicket containing the table, added the timer
> to it and, by miracle, it Works!!! :jumping:
> Up to now the wicket library seems to me very good, but it's very hard
> for a beginner to figure out what the methods do.
>
> Marino
>
>
> marino wrote:
>
>> Hello,
>>
>> I have a simple wicket application built around the DefaulDataTable
>> example.
>> In the same program I have an Event Listener class which is called
>> outside
>> the wicket application context. This class produces data that I would like
>> to show
>> in the current wicket page, but when I call any operation like add(),
>> replaceWith() ..
>> I always receive the message:
>>
>> WicketRuntimeException: There is no application attached to current thread
>> ...
>> ........
>>
>> What can I do?
>>
>> Thanks,
>>
>> Marino
>>
>>
>
>
Re: updating a page when external event occurs
Posted by marino <ma...@di.unito.it>.
Here is how I solved the problem.
I extended AjaxSelfUpdatingTimerBehavior and overrid onPostProcessTarget().
inside method I replace the table wicket ( because the DefaultDataTable
does not seem able to dynamically add column);
I created a borderwicket containing the table, added the timer
to it and, by miracle, it Works!!! :jumping:
Up to now the wicket library seems to me very good, but it's very hard
for a beginner to figure out what the methods do.
Marino
marino wrote:
>
> Hello,
>
> I have a simple wicket application built around the DefaulDataTable
> example.
> In the same program I have an Event Listener class which is called
> outside
> the wicket application context. This class produces data that I would like
> to show
> in the current wicket page, but when I call any operation like add(),
> replaceWith() ..
> I always receive the message:
>
> WicketRuntimeException: There is no application attached to current thread
> ...
> ........
>
> What can I do?
>
> Thanks,
>
> Marino
>
--
View this message in context: http://www.nabble.com/updating-a-page-when-external-event-occurs-tp20770960p20834366.html
Sent from the Wicket - User 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