How to check if table have action handler - spring-mvc

in my vaadin/spring application i have a table which can have added action handler. Is there any option how to chcek if table already have an action handler ?

I checked source code of com.vaadin.ui.Table class and how it deals with Action handlers - and unfortunately, I didn't find any direct way how to check how many action handlers there are in the Table (Vaadin version 7.7.6) - thats because the only exposed methods which deal with action handles are these:
addActionHandler - for adding action handlers
removeActionHandler - for removing specific action handler
removeAllActionHandlers - for removing all action handlers
However, good news is that the addActionHandler method will add the new handler only if it wasn't already added. So if you just want to be sure that you haven't added your handler twice, just impelment the equals() method in your handler and it shouldn't be added twice. See code of method com.vaadin.ui.Table#addActionHandler and maybe set some debug points there...

Related

how to implement source filter property page?

I have followed the instructions at http://msdn.microsoft.com/en-us/library/windows/desktop/dd375010%28v=vs.85%29.aspx to create a property page for my CSourceStream based stream.
When testing with amcap I can see that amcap now shows the menu item to show the capture pin properties (ISpecifyPropertyPages::GetPages is queried). The problem is that when amcap calls OleCreatePropertyFrame it returns with E_FAIL and I am not sure why, it does not seem to even get to the stage of quering my dll for the factory method to instantiate the CBasePropertyPage based property class.
The problem was my DllRegisterServer only registered my filter.
I can use AMovieDllRegisterServer2 to register all components in g_Templates but that function does not register source filters properly so for the moment I am just calling AMovieDllRegisterServer2 and then re-registering my filter with source filter specific code.

How do I check that a particular lifecycle event method runs in a Doctrine event subscriber?

I have a preUpdate event hook in an event listener and I want to write a test that just verifies that it gets executed when a particular document is updated. The only documentation I've been able to find about testing anything Doctrine-related was about testing query builders. I am new to Doctrine and this seems like a very simple thing to do but I really can't figure it out.
You can use partial mock. Lets say the class that has preUpdate hook is called Entity.
$mock = $this->getMockBuilder('Mock')->setMethods(array('preUpdate'))->getMock();
This create an object for which only the preUpdate method is stubbed and you can write expectations to this method:
$mock->expects($this->once())->method('preUpdate');
// some code that triggers the hook
All other methods of the class will work as in the original class - they would not be overriden

action url not calling correct action method in liferay6.1?

I have developed a liferay6.1 portlet with spring mvc where i have two drop down's(First option and second option) and a text box(enter a name) and a save button.
I am having two ajax request respective to each drop down. Say for example, for second option drop down, i have a javascript method where I frame the action url with a param called action with value in it like below
<portlet:actionURL portletMode='view'><portlet:param name='action' value='dropDownSelect'/></portlet:actionURL> .
Likewise, I have a javascript method for other drop down also where I am providing action url like
<portlet:actionURL portletMode='view'><portlet:param name='action' value='addAnotherOption'/></portlet:actionURL>.
When I click on save button, I am doing a form submit where I have framed a url without action param. like
<portlet:actionURL portletMode='view'></portlet:actionURL>.
So for each and every action, I have a different method in my controller.java which will receive this action request. For two action methods, I have annotation like
#RequestMapping(params = "action=dropDownSelect")
on top of the method. For one action method alone, I just gave annotation like this
#RequestMapping("VIEW")
My issue is often, action request with param is not getting received in correct method instead it is going to the method which have annotation as #RequestMapping("VIEW").
I have used the same code in liferay6.0 where I didnt face any issues like this but in Liferay 6.1 , I am facing this issue frequently. Can anyone help me with issue?
This issue was happening because for each action url which i frame in javascript has portletmode="view". BEcause of which , intermiteently, spring doesn't lookup to verify whether any action param is there or not, it by default called the action method which has #RequestMapping("VIEW"). To solve this, i modified my annotation like this,
#RequestMapping("VIEW")
#ActionMapping(params = "action=dropDownSelect") for all the methods which has params values to be mentioned in annotation.
So that while going from javascript to controller, spring will check for portletmode= view plus the action param also.

Symfony2 - Execute a function before calling the action and all bundles

I want to execute a function when a road is called it in any controller but before the call to action.
The goal is that the code is invisible in the controller and do it the best walkthrough possible.
Here you have the solution: https://matt.drollette.com/2012/06/calling-a-method-before-every-controller-action-in-symfony2/
In short, you have to intercept the call to a Controller using a Kernel event, and then execute your code inside the listener. You can "select" which controllers use this behavior extending a particular Interface.

Asynchronous action for strongly-typed partial view in _Layout

So, here's the rundown...
I've got a master layout page for my MVC 4 app that has some dynamic information and needs to be strongly typed to a specific domain entity to get that information. To keep my files cleaner, I've extracted out the typed fields to a partial view.
To grab the entity I need and map it to the partial's view-model, I have a LayoutController with an action that returns a Task<PartialViewResult>. This action uses a service layer to make an async call out to a Web API project, awaiting the entity. It massages that entity into the view-model and then returns PartialView("_LayoutPartial", viewModel).
From within the _Layout page, the partial is called via:
#{Html.RenderAction("LayoutInfo", "Layout", new { /*entity primary key*/ });}
I've stepped through the code and it does indeed get the correct entity back, but then after returning the partial view task, I get everybody's favorite Server Error page with the following error:
HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete.
I've done some Googling and SO searching and have no idea what this actually means. Am I thinking through this correctly?
That error message means that you're trying to invoke (and wait on!) an asynchronous method from within a synchronous method. In your specific case, the synchronous method is HtmlHelper.RenderAction, and the asynchronous method is your Task-returning action method. The reason the error occurs is that the point of writing an asynchronous Task-returning method is presumably to avoid blocking a thread, but RenderAction can't return until the Task is complete, so RenderAction ends up blocking while waiting for the operation to finish.
One option is to make the method that RenderAction calls synchronous instead of asynchronous, keeping in mind that this will continue to block the original thread. Another option is to populate the layout data asynchronously from within the original action method, then to pass that via ViewData to the layout page.

Resources