9/26/2012

Wrapping the call in Seam contexts

http://seamframework.org/Documentation/ReplacingServletsWithSeamResources#H-WrappingTheCallInSeamContexts

1. You can map the <web:context-filter/> in components.xml to wrap all calls on a particular URL pattern, see reference documentation.

2. You can wrap a call manually in a particular Servlet:

class MyServlet extends HttpServlet {

    protected void service(final HttpServletRequest request, final HttpServletResponse response)
            throws ServletException, IOException {

        new ContextualHttpServletRequest(request) {
            @Override
            public void process() throws Exception {
                doWork(request, response);
            }
        }.run();
    }

    private void doWork(HttpServletRequest request, HttpServletResponse response) {
        Component.getInstance(...);
    }

}

9/05/2012

Map request parameters as a Map in a controller method

@RequestMapping(value = "/selectAppsForAsset", method = RequestMethod.POST)
public @ResponseBody String selectAppsForAsset(@RequestParam(value = "pid") String assetPublicId, @RequestParam(value="map[]", required=false) String[] selectedAppNumbers) {
...
}


Here it is:
@RequestParam(value="map[]", required=false) String[] selectedAppNumbers

9/04/2012

Eсли ты заметил, что скачешь на дохлой лошади, – слезь с неё

Индейская мудрость гласит: «если ты заметил, что скачешь на дохлой лошади, – слезь с неё».

Но в жизни мы часто руководствуемся другими стратегиями:
– достаём более крепкий кнут;
– меняем всадника;
– говорим себе: «мы и раньше скакали на дохлой лошади»;
– создаём рабочую группу для изучения дохлой лошади;
– посещаем разные места,чтобы посмотреть, как скачут на дохлых лошадях там;
– создаём отдел по оживлению дохлой лошади;
– устраиваем тренировки,чтобы научиться лучше скакать на дохлой лошади;
– проводим сравнительный анализ всевозможных дохлых лошадей;
– изменяем критерии,устанавливающие, что лошадь мертва;
– нанимаем на стороне людей, якобы умеющих скакать на дохлой лошади;
– внушаем себе, что ни одна лошадь не может быть настолько дохлой, чтобы на ней нельзя было скакать;
– проводим исследования,чтобы узнать, есть ли более хорошие или более дешёвые дохлые лошади;
– объясняем себе, что наша дохлая лошадь быстрее, лучше и дешевле, чем другие;
– создаем совет по качеству, чтобы найти применение дохлым лошадям;
– пересматриваем условия работы для дохлых лошадей;
– расширяем сферу применения дохлых лошадей;
– и, наконец: образуем особый отдел, в котором изучают потребности именно дохлых лошадей.

8/30/2012

Removing duplicates from the table

SELECT DISTINCT a.*
  FROM dbo.AssetDealsConnections a
  JOIN dbo.AssetDealsConnections b
  ON a._fk_Asset = b._fk_Asset AND a._fk_stageID = b._fk_stageID AND a._pk != b._pk
  ORDER BY a._fk_Asset, a._pk;


 DELETE b
  FROM dbo.AssetDealsConnections a
  JOIN dbo.AssetDealsConnections b
  ON a._fk_Asset = b._fk_Asset AND a._fk_stageID = b._fk_stageID AND a._pk > b._pk;

8/06/2012

Using Spring @Configurable and @Autowire to inject DAOs into domain objects

http://sujitpal.blogspot.com/2007/03/accessing-spring-beans-from-legacy-code.html

http://stackoverflow.com/questions/4703206/spring-autowiring-using-configurable

7/24/2012

ConcurrentModificationException

ConcurrentModificationException usually has nothing to do with multiple threads. Most of the time it occurs because you are modifying the collection over which it is iterating within the body of the iteration loop. For example, this will cause it:

Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
    Item item = (Item) iterator.next();
    if (item.satisfiesCondition()) {
       collection.remove(item);
    }
}
In this case you must use the iterator.remove() method instead. This occurs equally if you are adding to the collection, in which case there is no general solution. However, the subclass ListIterator can be used if dealing with a list and this has an add() method.