In Vaadin 8, I am able to asynchronously update a Grid with incoming websocket data using the access method of UI, which locks the thread and performs the updates, then pushes them without the client having to request it.
access(() -> addMessage(message));
I am trying to use vaadin 10 now, and since the main class you start with doesn't extend UI, I am trying to do it like this:
UI.getCurrent().access((Command) () -> addTrade(message))
However it is not working, and you have to click somewhere on the page for the update to happen. I have the #Push annotation on the class, so I believe server push should work.. thank you so much guys!
in my servlet:
asyncSupported = true
have also tried this.getUI().get().access(), still not updating.
This is most likely caused by https://github.com/vaadin/flow/issues/3256 that is currently being fixed.
The tickets also suggests a workaround: grid.getElement().getNode().markAsDirty();. If the workaround solves the issue, then it's very likely caused by that bug. If not, then there's some other issue that would require further investigation.
Related
I have the same question as in the topic below, but I'm not so sure if my approach is wrong.
How do I know if a guard rejected a transistion
My app is a linear step-by-step strategy board game with several different game settings. I've decided to use Spring StateMachine to solve as in my opinion (and so far) it solves a lot little code-related organisational problems But now I'm stacked
The problem I have run into is that I can't say if my event passed all the guards and transition occurs. I just get true-flag when an event is added to the queue
The approach I'm following is passing data via event-context, validation of one with guards and apply changes using actions
transitions
.withExternal().source(SPEECHES).target(VOTING).event(VOTING_EVENT)
.guard(Guard.and(
guards.get(NoVotesFromSuspectedGuard.QUALIFIER),
guards.get(NoSelfVotingGuard.QUALIFIER),
guards.get(NoDeadParticipantsVotingGuard.QUALIFIER),
guards.get(NoVotingForDeadParticipantsGuard.QUALIFIER),
votingOutOfParticipantListGuardFactory.get(NUMBER_OF_PLAYERS),
guards.get(VotingBasedOnPreviousOneGuard.QUALIFIER)
))
.action(actions.get(CalculateVotingAction.QUALIFIER))
As I understand now, there is no possibility to notify event-supplier about failed guard evaluation. If so, just let me know and I will switch to another SM implementation. But if there is any possibility of solving my problem, please help me.
The behaviour I expect is any meta info of failed guard (to build formatted error message)
You can use some context flag, for example context.put("NoVotesFromSuspectedGuard", false) when "NoVotesFromSuspectedGuard" isn't success and then you can check this variable in your invoke code context.getExternalVariables().get("NoVotesFromSuspectedGuard", Boolean.class).
Also, in Spring State Machine you can declare ActionListener bean, which contains some different methods for StateMachine events monitoring.
For more information, you can see Habr(Russian)
I got the following issue on the specific layer we have on Alfresco (version 3, using hibernate 3 + spring):
When a page is first loaded, everything goes fine. No problem.
When we do an interaction on this page that leads to a refresh, we have some
lazyinitializationexception could not initialize proxy - no session.
I know the lazyinit is a common issue. But because of the fact that we want only make changes on the specific layer not on the alfresco layer, many resolutions can't be applied.
The one consisting in forcing the sessions to stay open is not possible for us.
The one using Hibernate.Initialize leads to this error:
User:admin ERROR [org.hibernate.LazyInitializationException] failed to lazily initialize a collection of role: org.jbpm.taskmgmt.exe.TaskInstance.variableInstances, no session or session was closed
So I got three questions:
Does someone has an idea of why on the first load, we have no problem and on refresh we got the lazyInit Exception ?
How could we make the hibernate.initialize work ?
Is there any other way to solve this issue ?
To say a little more about the context:
We want to show to user via IHM the task history. To do that we fill a table, to do so we collect the current taskInstance ti and the previous ones and for each of them we do a ti.GetName(), ti.GetDescription(), etc. The issue seems to come that after collecting the Task Instances, the hibernate session is close, so we can't perform ti.GetName() and other operations on ti.
In advance thank you all for your help,
Regards
Okay, after a lot of days of working on that, we just found how to solve it. A colleague just solve it when I was writing the desperate post :)
So the solution was to use
getHibernateTemplate().Hibernate.Initialize(ti.GetName());
directly in the Callback part of the DAO class.
Hope it will be useful to others and thanks for your efforts to help and I'm always unsure on whether I should post code or not to keep the post simple.
Alright so I am experimenting with Netty 4.0.19 (which is great by the way) and having one connection works fine, but once there are multiple connections there is an error that the handler is not a shared handler and cannot have multiple items.
This is my Handler class: ChannelManager.java
I was thinking, maybe every connection needs its own handler, but then I'm not sure how I will implement that in my current environment. Any suggestions or ideas?
EDIT :
I wasn't sure how to ask this question on google... so excuse me if this question already exists.
I think it has something to do with line 59 in the code. I saw some use of a ChannelInitializer but I don't know how to use that.
if your handler can be shared between multiple clients you need to annotate the class with:
#ChannelHandler.Sharable
My goal is to be able to use HttpUnit to crawl around my webpage and see what is and is not firing in the background... I have gotten it to connect to my page, and if I set
HttpUnitOptions.setLoggingHttpHeaders(true);
I see the sorts of background calls that I care about. However, I do not know how to see those interactions within the program. most of the getText and getInputStream calls fo the WebResponse object seem to just be the HTML call, and don't log the various javascript calls that fire in the background. Is there a way to get a list of all of the things going on in the background? HttpUnit's documentation seems sparse.
Thanks!
I just stumbled upon the answer. it looks like you need to make a class that implements WebClientListener, and then call wc.addClientListener(new YourListener()); where wc is a WebClient.
I don't delete this so others can see...and perhaps there is more nuance to it than that.
Hey all, I'm pretty new to jsf so if this is a poor question then I apologize. I'm currently working on a school project where I need to access a database through a web service to get some basic application data. I have a class that accesses this data through a method and then returns the newest results from the database.
What I want to do is to either spawn a thread that calls the update method on the database. The run method looks similar to this, where i get my application bean and then I call the refresh method on it.
theFacesContext = FacesContext.getCurrentInstance();
ApplicationBean app = (ApplicationBean)theFacesContext.getELContext().getELResolver().getValue(theFacesContext.getELContext(), null, applicationbean);
app.getDBValues();
The thread would then loop based on a variable that would be set to false when the application bean was destroyed. My error is that the thread looses the facescontext. I've seen some posts where people say something allong the lines that you have to keep the thread in a request, but I'm not sure what that means. Any suggestions would be extremely helpful.
If you want to display actual data, you should use polling or server-side push. There are a lot of ajax components that may help. Look at
PrimeFaces poll component
RichFaces push
RichFaces poll
ICEfaces
It is indeed true that FacesContext is not available in a new thread. This is because it is stored in a ThreadLocal, and is initiated per request.
You can get your desired bean and pass it to the new thread, so that you no longer rely on the faces context there.