<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:base="http://jdn.pl">
<channel>
 <title>Blog użytkownika Łukasz Lenart</title>
 <link>http://jdn.pl/blog/416</link>
 <description>       
       
       
        
       </description>
 <language>pl</language>
<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/LukaszLenartsBlog" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="lukaszlenartsblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">LukaszLenartsBlog</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><item>
 <title>Smażenie confitury</title>
 <link>http://jdn.pl/node/2180</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;Powoli zbliża się kolejna edycja konferencji &lt;a href="http://2013.confitura.pl/"&gt;Confitura&lt;/a&gt; - część z Was możecie jeszcze kojarzyć jej poprzedniczkę - Javarsovię. Jednak nowa nazwa konferencji już mocno wgryzła się w świadomość społeczności okołojavowej i nie tylko.&lt;/p&gt;
&lt;p&gt;Konferencja ciągle ewoluuje, zmienia się zakres tematyczny wystąpień, pojawiają się miękkie tematy związane z zarządzaniem projektami, budowaniem zespołów czy też kultury pracy. Oczywiście tematy ściśle techniczne mają swoje miejsce i każdy znajdzie coś co go zainteresuje.&lt;/p&gt;
&lt;p&gt;Bardzo często wielość tematów jest tak duża, że dochodzą do nas żale ludzi, którzy nie mogli wybrać się na wszystkie interesujące wykłady i postulują o zredukowanie liczby ścieżek do dwóch, trzech, jednej - tak abym "pasowało tylko mnie" ;-)&lt;/p&gt;
&lt;p&gt;Taki dylemat z liczbą ścieżek mamy co roku, zawsze mamy bardzo dużo zgłoszeń na &lt;a href="http://2013.confitura.pl/news/2/otwieramy_call_4_papers"&gt;C4P&lt;/a&gt;, do tego dochodzą wystąpienia Partnerów, a każdym z uczestników kierują inne potrzeby. Nie ma szans aby zaspokoić życzenia i oczekiwania wszystkich :-)&lt;/p&gt;
&lt;p&gt;Tegoroczna edycja odbędzie się ponownie w gmachu Uniwersytetu Warszawskiego w centrum Warszawy. Wszystkie sale są wyremontowane i wyposażone w klimatyzację, do tego dysponujemy jeszcze jedną salą w budynku Starej Biblioteki.&lt;/p&gt;
&lt;p&gt;W tym roku planujemy całą jedną ścieżkę w języku angielskim, oznacza to tyle, że zgłaszając swoją propozycję wystąpienia możesz wybrać w jakim języku będziesz prezentował. Jest to ukłon w stronę części prelegentów, którzy chcą szlifować swoją formę również w aspekcie języka jak również jest to otwarcie się na przyjezdnych uczestników z zagranicy.&lt;/p&gt;
&lt;p&gt;Zobaczymy co z tego wyjdzie :-)&lt;/p&gt;
&lt;p&gt;I tak już na zakończenie, zachęcam wszystkich do zgłaszania się z propozycjami wystąpienia podczas konferencji, trwa ciągle &lt;a href="http://2013.confitura.pl/news/2/otwieramy_call_4_papers"&gt;Call 4 Papers&lt;/a&gt; i jest to najlepsza sposobność aby zaistnieć w społeczności, sprzedać się jako znawca tematu lub po prostu podzielić się swoją wiedzą i przemyśleniami na wybrany problem!&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/70"&gt;confitura&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 03 Apr 2013 09:24:23 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2180 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2180#comments</comments>
</item>
<item>
 <title>Hibernate i dobre rady</title>
 <link>http://jdn.pl/node/2165</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;&lt;a href="http://www.hibernate.org/"&gt;Hibernate&lt;/a&gt; jest przez wielu traktowany jako podstawowy element składowy każdego projektu - tak jak Spring ;-) I w sumie racja, bardzo szybko na początku otrzymujemy funkcjonalność zapisu danych w bazie danych, nasze obiekty bez większego wysiłku same się aktualizują, zapisują, etc.&lt;/p&gt;
&lt;p&gt;Problemy zaczynają się pojawiać, gdy nasz aplikacja się rozrasta i przybywa zależności między obiektami, graf domeny przypomina  bardziej las a nie pojedyncze drzewo a do tego wszystkiego dokładamy jeszcze Enversa aby monitorować co i kto miesza nam w bazie.&lt;/p&gt;
&lt;p&gt;Powyższe to najprostszy przepis na niezły bajzel :P&lt;/p&gt;
&lt;p&gt;Podam kilka dobrych rad, które możesz wykorzystać i może pomogą ci uniknąć problemów z jakimi borykamy się w naszym projekcie po trzech latach pisania i dodawania ficzerów.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Po pierwsze:&lt;br /&gt;
Jeśli piszesz testy integracyjne, czyli takie które zapisują coś do bazy a następnie odczytują, to potrzebne dane testowe twórz z poziomu kodu. Nie korzystaj z jakiś zewnętrznych plików, nawet nie wiem o jak prostej składni to i tak ci nie pomoże gdy przyjdzie zrobić refactoring albo dodać jedno pole - pomyśl o tych wszystkich zewnętrznych plikach, do których będziesz musiał dodać wartości dla tego pola. Kompilator tego nie wykryje, dopiero odpalenie wszystkich testów pozwala wykryć brakujące dane (miejmy nadzieję że tak jest ;-)
&lt;/li&gt;
&lt;li&gt;Po drugie:&lt;br /&gt;
Jeśli wybrałeś strategię generowania kluczy dla encji to upewnij się że rozumiesz jak ona działa i że wszyscy w zespole wiedzą jakie wartości będą generowane dla kluczy. I przetestuj czy faktycznie działa tak jak myślisz. Ma to o tyle znaczenie, że jeśli odkryjesz po czasie, że jednak strategia działa inaczej niż myślałeś a już jesteś na "produkcji" to migracja danych może nie być możliwa.
&lt;/li&gt;
&lt;li&gt;Po trzecie:&lt;br /&gt;
Hibernate i Envers zawiera błędy jak każdy inny kod. I jeśli nawet używany jest przez tysiące projektów to może się okazać, że Twoja konfiguracja jest na tyle specyficzna, że źródłem problemów i błędów jest właśnie Hibernate czy też Envers. Przykładem niech będzie błąd w Enversie, który generuje rewizyjne dane pomimo, że transakcja została wycofana a druga transakcja przeszła poprawnie - więcej szczegółów wkrótce u &lt;a href="http://tomaszdziurko.pl/"&gt;Tomka Dziurko&lt;/a&gt; na blogu.
&lt;/li&gt;
&lt;li&gt;Po czwarte:&lt;br /&gt;
Lazy jest fajne ale musisz rozumieć kiedy i jak działa. Co powoduje, że nastąpi select do bazy danych i pociągnięty zostanie graf obiektów. Przykład dość prosty: jeśli masz &lt;code&gt;hashCode()&lt;/code&gt; który bazuje na propertisach, które są lazy to w momencie wstawiania takiego obiektu do HashMapy jako klucza, nastąpi wywołanie zapytania do bazy danych - przecież musi być obliczony &lt;code&gt;hashCode()&lt;/code&gt;!&lt;br /&gt;
Rozwiązanie problemu jest dość proste, użyj dwóch map. W jednej trzymasz relację id =&amp;gt; encja1 a w drugiej id_encja1 =&amp;gt; encja2. Mało eleganckie ale rozwiązuje problem ładowania obiektu przy wstawianiu go jako klucz.
&lt;/li&gt;
&lt;li&gt;Po piąte:&lt;br /&gt;
Hibernate definiuje dwie opcje persystowania propertisów - wg pól lub wg getter/setter i zależy to gdzie jest umiejscowiona adnotacja @Id - jeśli na polu to mamy &lt;b&gt;field access&lt;/b&gt;, jeśli przy getter/setter to mam &lt;b&gt;property access&lt;/b&gt; - szczegóły w &lt;a href="http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#d0e6292"&gt;dokumentacji&lt;/a&gt;. Dlaczego o tym mówię ? Bo jeśli potrzebujemy wyciągnąć tylko klucz obiektu, który jest lazy to ma to znaczenie. Dla przykładu: &lt;code&gt;encja1.getEncja2().getId()&lt;/code&gt; - i w zależności czy mam &lt;b&gt;field access&lt;/b&gt; czy &lt;b&gt;property access&lt;/b&gt; to wywołanie &lt;code&gt;getId()&lt;/code&gt; pociągnie cały obiekt z bazy lub tylko odczyta wartość klucza z encja1 (toż encja1 zawiera już klucz encja2 ;-)
&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;To chyba na razie tyle, jak jeszcze wejdę na jakąś minę i przeżyję to dam znać :D&lt;/p&gt;
&lt;p&gt;Pozdrawiam&lt;br /&gt;
--&lt;br /&gt;
Łukasz&lt;br /&gt;&lt;a href="http://www.lenart.org.pl/"&gt;www.lenart.org.pl&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/45"&gt;architektura&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 10 Oct 2012 10:22:14 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2165 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2165#comments</comments>
</item>
<item>
 <title>Testowanie z transakcjami w tle</title>
 <link>http://jdn.pl/node/2159</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;Spora część aplikacji, które piszemy wykorzystuje relacyjne bazy danych. Pewnie można by założyć, że większość aplikacji, które mają coś wspólnego z bazami danych, korzysta z baz relacyjnych. Bazy NoSQL są wciąż w mniejszym stopniu w powszechnym użyciu.&lt;br /&gt;
Oczywiście testowanie w aplikacji składających się z wielu warstw jest obecnie dość proste. Wstawia się mocka zamiast rzeczywistej implementacji i gotowe, można testować. Jednak czasami mamy potrzebę sprawdzić trochę więcej niż jedną klasę, potrzebujemy napisać test integracyjny, które przejdzie przez kilka warstw, dotknie bazy danych, zahaczy o transakcje i oczywiście będzie odpalany z IDE ;-)&lt;/p&gt;
&lt;p&gt;Jeśli jeszcze do tego dodamy &lt;strong&gt;DI&lt;/strong&gt; w postaci CDI oparte o Welda, JPA 2.0 na bazie Hibernate'a to zaczyna robić się ciekawie. I strasznie zarazem - mało kto wie co się dzieje :P W &lt;a href="http://www.softwaremill.pl/"&gt;SoftwareMill&lt;/a&gt; korzystamy z własnej biblioteki &lt;a href="https://github.com/softwaremill/softwaremill-common/"&gt;softwaremill-common&lt;/a&gt;, która dostarcza różne ciekawe moduły do pracy z CDI, JPA, JSF, etc. Kod jest dostępny na GitHubie i jako repozytorium Mavena z Nexusa.&lt;/p&gt;
&lt;p&gt;Wśród wielu modułów jest również klasa &lt;a href="https://github.com/softwaremill/softwaremill-common/blob/master/softwaremill-test/softwaremill-test-db/src/main/java/pl/softwaremill/common/dbtest/AbstractDBTest.java"&gt;AbstractDBTest&lt;/a&gt; służąca do pisania testów, które potrzebują prawdziwej bazy danych a nie mocka. W założeniu miała ona wspierać transakcje, bazując na konfiguracji, która została użyta przy testowaniu Enversa i paczki Hibernate-Testing - znajdziecie wiele przykładów.&lt;/p&gt;
&lt;p&gt;Niestety, wszystkie one nie działają ;-)&lt;/p&gt;
&lt;p&gt;Nie działają z transakcjami, bo do bazy zapisują i odczytują, ale nie w ramach transakcji, którą można sterować.&lt;/p&gt;
&lt;p&gt;Tak się złożyło, że w projekcie dla jednego z naszych klientów musieliśmy przetestować czy działa &lt;cite&gt;rollback&lt;/cite&gt; na transakcji, a konkretnie czy wykonane wcześnie zmiany w bazie w wyniku rzucenia &lt;code&gt;Exception&lt;/code&gt; zostaną wycofane z bazy - czyli klasyczne &lt;cite&gt;begin/commit/rollback&lt;/cite&gt;.&lt;/p&gt;
&lt;p&gt;Niestety nie było to możliwe z AbstarctDBTest, jak również Weld i Embedded Container psują tu wszystko - pierwsza za sprawą wspomnianego pakietu Hibernate Testing, a drugi w związku z pustą implementacją UserTransaction, która nic nie robi.&lt;/p&gt;
&lt;p&gt;Jedynym słusznym rozwiązaniem było napisanie wszystkiego jak trzeba, czyli tak aby działało z prawdziwymi transakcjami - pewnie ktoś powie, że takie rozwiązanie już jest, a ja odpowiem, że moje jest lepsze :P&lt;/p&gt;
&lt;p&gt;Rozwiązaniem problemu jest klasa &lt;a href="https://github.com/softwaremill/softwaremill-common/blob/master/softwaremill-test/softwaremill-test-db/src/main/java/pl/softwaremill/common/dbtest/TransactionalDBTest.java"&gt;TransactionDBTest&lt;/a&gt;, która wykorzystuje bibliotekę &lt;a href="http://docs.codehaus.org/display/BTM/Home"&gt;Bitronix&lt;/a&gt; jako Transaction Managera. Bitronix jest bardzo fajnym rozwiązaniem, gdyż pozwala na uruchomienie serwera JNDI i wstawienia naszego DataSource tak aby Hibernate mógł z niego skorzystać.&lt;/p&gt;
&lt;p&gt;Nie będę podawał przykładu jak użyć tej klasy, wystarczy przyglądnąć się testowi &lt;a href="https://github.com/softwaremill/softwaremill-common/blob/master/softwaremill-test/softwaremill-test-db/src/test/java/pl/softwaremill/common/dbtest/TestTransactionalDBTest.java"&gt;TestTransactionDBTest&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Klasa wykorzystuje Arquilliana i bazuje na magicznym &lt;a href="https://github.com/softwaremill/softwaremill-common/blob/master/softwaremill-util/src/main/java/pl/softwaremill/common/util/dependency/D.java"&gt;D.inject()&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Miłego testowania i uwagi mile widziane w postaci push requestów na GitHubie :-)&lt;/p&gt;
&lt;p&gt;Pozdrawiam&lt;br /&gt;
--&lt;br /&gt;
Łukasz&lt;br /&gt;&lt;a href="http://www.lenart.org.pl/"&gt;www.lenart.org.pl&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/37"&gt;szkielety&lt;/a&gt;&lt;/div&gt;&lt;div class="field-item odd"&gt;&lt;a href="/taxonomy/term/52"&gt;testy&lt;/a&gt;&lt;/div&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/53"&gt;testy jednostkowe&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 21 Sep 2012 14:11:14 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2159 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2159#comments</comments>
</item>
<item>
 <title>... i po konfiturze</title>
 <link>http://jdn.pl/node/2146</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;Tak właśnie, minęło już kilka dni od zakończenia drugiej edycji konferencji &lt;a href="http://www.confitura.pl"&gt;Confitura&lt;/a&gt;, a w sumie szóstej licząc cztery poprzednie edycje pod marką Javarsovia. Pasuje podsumować całość, zwłaszcza jak było się członkiem kapituły - choć lepszym mianem dla mnie było by "księgowy" ;-)&lt;br /&gt;
Jest to kolejny rok, gdzie konferencja rośnie, może już nie tak skokowo jak jakiś czas temu ale bardziej organicznie - szacunkowo było &lt;strong&gt;~850&lt;/strong&gt; uczestników w porównaniu do poprzedniego roku, kiedy to zjawiło się &lt;strong&gt;~800&lt;/strong&gt; osób.&lt;/p&gt;
&lt;p&gt;Jeszcze kilkanaście tygodni temu nie wiedzieliśmy co nam się uda zorganizować, czy będzie catering z lunchem, czy tylko kawa i ciasteczka. Czy będzie SPOINa czyli impreza integracyjna po konferencji czy tylko wyskoczymy na piwko. Czy będą koszulki dla uczestników. Więcej było niewiadomych niż byśmy sobie tego życzyli.&lt;/p&gt;
&lt;p&gt;Zawsze chcemy zapewnić jak najwięcej atrakcji ale jest to trudne nie dysponując gotówką na ich pokrycie. Konferencja jest całkowicie bezpłatna dla uczestników, jedynym kosztem w tym roku to była zgoda na mailing od naszych Partnerów, gdzie maksymalnie będzie to sześć wiadomości wysłanych w ciągu najbliższych sześciu miesięcy. Chyba żaden koszt jak za całodzienną konferencję wraz z wyżywieniem. Jednak mimo tego część uczestników nie chciała nas wesprzeć i nie zgodziła się na mailing - szkoda, za rok konferencja może przez to być skromniejsza.&lt;/p&gt;
&lt;p&gt;I tu dochodzimy do clue sprawy - konferencja nie zrobi się sama, ktoś ją organizuje, ktoś wykłada pieniądze, ktoś przychodzi w wolną sobotę i dokłada cegiełkę do całości. Stąd naszych sponsorów nazywamy Partnerami a nie Sponsorami, bo ich wkład jest ważny i nie chodzi tylko o pieniądze. Stąd nasza prośba o zgodę na mailing, bo dzięki temu wy również stajecie się partnerami dla naszych Partnerów. To jest transakcja wiązana - oni Wam atrakcje, a wy wysłuchanie ich głosu. Naprawdę niewiele.&lt;/p&gt;
&lt;p&gt;Dobra, dość tego marudzenia, chyba rozumiecie, że nie działamy na Waszą szkodę.&lt;/p&gt;
&lt;p&gt;Myślę, że wszyscy są bardzo zadowoleni z udziału w konferencji, i Partnerzy, i uczestnicy. Każda ze stron wyniosła to co chciała z konferencji. Ilość atrakcji jakie były dostępne samych nas wprowadziła w zdumienie i gdyby niezbyt szeroki korytarz wszystko wyglądało by super. Choć w sumie wystarczyło przesunąć jedno stoisko w inne miejsce aby rozłożyć atrakcje równomiernie a tym samym zagęszczenie uczestników ;-)&lt;/p&gt;
&lt;p&gt;Osoby, które były na konferencji wiedzą, że już za rok odbędzie się Confitura'13 i mamy nadzieje, że w tym samym miejscu. Oczywiście, że &lt;a href="http://www.uw.edu.pl/"&gt;Uniwersytet Warszawski&lt;/a&gt; - nasz gospodarz, a dokładnie Audytorium Maximum ma swoje minusy - wąski korytarz - ale ma też plusy, które trudno nie doceniać - lokalizację w centrum miasta, możliwość rozstawienia namiotów (jeszcze tydzień przed konferencją nie było żadnych wykopków ;-)) no i cena :-)&lt;/p&gt;
&lt;p&gt;Na koniec chciałbym podziękować jeszcze raz naszym Partnerom, bo niestety nie da się zrobić konferencji tej skali bez pieniędzy:&lt;br /&gt;
Platynowy: &lt;a&gt;&lt;/a&gt;Javart&lt;br /&gt;
Złotym: &lt;a href="http://www.akamai.com/html/careers/index.html"&gt;Akamai&lt;/a&gt;, &lt;a href="http://www.oracle.com/pl/"&gt;Oracle&lt;/a&gt;, &lt;a href="http://epoint.pl/"&gt;e-point&lt;/a&gt;, &lt;a href="http://allegro.pl/country_pages/1/0/marketing/about.php"&gt;Allegro Group&lt;/a&gt;, &lt;a href="http://www.atlassian.com/"&gt;Atlassian&lt;/a&gt;&lt;br /&gt;
Srebrnym: &lt;a href="http://www.google.pl/"&gt;Google&lt;/a&gt;, &lt;a href="http://www.decerto.pl/"&gt;Decerto&lt;/a&gt;, &lt;a href="http://www.nask.pl/"&gt;NASK&lt;/a&gt;, &lt;a href="http://www.smtsoftware.com/"&gt;SMT Software&lt;/a&gt;, &lt;a href="http://outbox.pl/"&gt;Outbox&lt;/a&gt;, &lt;a href="http://www.pracuj.pl/"&gt;pracuj.pl&lt;/a&gt;&lt;br /&gt;
Brązowym: &lt;a href="http://touk.pl/"&gt;TouK&lt;/a&gt;, &lt;a href="http://www.xentivo.pl/"&gt;Xentivo&lt;/a&gt;, &lt;a href="http://www.sages.com.pl/"&gt;SAGES&lt;/a&gt;, &lt;a href="http://www.agileszkolenia.pl/"&gt;Code Sprinters&lt;/a&gt;&lt;br /&gt;
Technicznym: &lt;a href="http://www.softwaremill.pl/"&gt;SoftwareMill&lt;/a&gt;, &lt;a href="http://www.ovh.pl/"&gt;OVH&lt;/a&gt;, &lt;a href="http://www.ej-technologies.com/"&gt;ej-technologies&lt;/a&gt;, &lt;a href="http://oreilly.com/"&gt;O'Relily&lt;/a&gt;, &lt;a href="http://www.helion.pl/"&gt;Helion&lt;/a&gt;, &lt;a href="http://www.uw3d.tv/"&gt;3D TV&lt;/a&gt;, &lt;a href="http://nzspw.pl/"&gt;NZS PW&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;W tym roku zaliczyliśmy dość poważną wpadkę, jak zawsze na koniec konferencji zapraszaliśmy naszych &lt;a href="http://2012.confitura.pl/view/6"&gt;Wolontariuszy&lt;/a&gt; na zakończenie, abyście mogli poznać z twarzy osoby, bez których obsłużenie takiego tłumu nie było by możliwe. Jest mi przykro z tego powodu i jedyne co mogę obiecać, to że uczymy się na błędach i w przyszłym roku powrócimy do tej chlubnej tradycji.&lt;/p&gt;
&lt;p&gt;I jeszcze na koniec, wszyscy marudzący na temperaturę, powinni być wdzięczni, że konferencja odbyła się w minioną sobotę, na tą najbliższą prognozowane jest od 32 do 35 stopni, dopiero byłby ukrop ;-)&lt;/p&gt;
&lt;p&gt;Pozdrawiam&lt;br /&gt;
--&lt;br /&gt;
Łukasz&lt;br /&gt;&lt;a href="http://www.lenart.org.pl"&gt;www.lenart.org.pl&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/40"&gt;wydarzenia&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 04 Jul 2012 10:12:47 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2146 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2146#comments</comments>
</item>
<item>
 <title>@ViewScoped czy nie @ViewScoped</title>
 <link>http://jdn.pl/node/2144</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;Dzisiaj bardzo ważny wpis dla wszystkich używających JSF 2.0 i adnotacji &lt;strong&gt;@ViewScoped&lt;/strong&gt;. Oczywiście dla niektórych może to być oczywista oczywistość to co przeczytają, ale mi zajęło trochę czasu zrozumienie całości problemu i dojście do poniższych wniosków.&lt;/p&gt;
&lt;p&gt;Dobra, spytacie o co chodzi z &lt;strong&gt;@ViewScoped&lt;/strong&gt; ?&lt;/p&gt;
&lt;p&gt;Tej adnotacji używa się na klasie kontrolera strony JSF jeśli używamy go w połączeniu z &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:ajax&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;, sprawa prosta i oczywista. Jednak dość często nasz kontroler ma dodatkowe adnotacje na poziomie klasy. Może to być &lt;strong&gt;@ManagedBean&lt;/strong&gt; lub &lt;strong&gt;@Named&lt;/strong&gt; czy też inne adnotacje &lt;a href="http://docs.oracle.com/javaee/6/tutorial/doc/gjbnr.html"&gt;CDI&lt;/a&gt;. Dla jasności &lt;strong&gt;@ManagedBean&lt;/strong&gt; jest adnotacją JSFową a nie CDI.&lt;/p&gt;
&lt;p&gt;I właśnie tu jest mały problem. Jeśli na poziomie klasy kontrolera mieszamy adnotacje z dwóch światów - JSF i CDI - to skutki mogą być opłakane a co najmniej nieprzewidywalne ;-)&lt;/p&gt;
&lt;p&gt;Pewnie zastanawiacie się dlaczego ? Ano sprawa jest prosta, JSF tworzy swoją instancję kontrolera a CDI swoją i która gdzie będzie wstrzykiwana to może być niezła zagwozdka do rozsupłania.&lt;/p&gt;
&lt;p&gt;Pewnie teraz powiecie, no ale &lt;strong&gt;@ViewScoped&lt;/strong&gt; jest tylko w JSFie, w CDI nie ma odpowiednika (wg specyfikacji) i będziecie mieć rację. Jednak w takim przypadku należy wystrzegać jest adnotacji z CDI i użyć poczciwego &lt;strong&gt;@ManagedBean&lt;/strong&gt; znanego z czasów JSF 1.0, czyli:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;@ManagedBean&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;name &lt;span style="color: #339933;"&gt;=&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;quot;myPage&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;@ViewScoped&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; MyPageBean &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;i gra gitara.&lt;/p&gt;
&lt;p&gt;Jednak mała uwaga. Seam 3 dostarcza moduł &lt;a href="http://seamframework.org/Seam3/FacesModule" title="Seam Faces"&gt;Seam Faces&lt;/a&gt; a wraz z nim jest dostarczana implementacja &lt;strong&gt;@ViewScoped&lt;/strong&gt; bazująca na CDI. Jeśli niechcący użyjecie sobie tego modułu w waszej aplikacji, to znów mamy pomieszane dwa światy :P&lt;/p&gt;
&lt;p&gt;Tak więc, w przypadku używania modułu Seam Faces wyrzucamy &lt;strong&gt;@ManagedBean&lt;/strong&gt; i używamy &lt;strong&gt;@Named&lt;/strong&gt;, aby było jasne że nasz kontroler jest kontrolowany przez CDI czyli:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;@Named&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;myPage&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;@ViewScoped&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; MyPageBean &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Jeszcze jedna mała uwaga do &lt;strong&gt;@ViewScoped&lt;/strong&gt;. Oznaczone nim klasy będą odkładane w sesji, ale tylko na czas, gdy użytkownik przebywa na danym widoku. Jeśli opuści stronę &lt;strong&gt;@ViewScoped&lt;/strong&gt;, instancja zostanie usnięta z sesji i zniszczona.&lt;/p&gt;
&lt;p&gt;Powoduje to jednak pewien problem, klasa musi być &lt;a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/io/Serializable.html"&gt;Serializable&lt;/a&gt; jak i wszystkie jej pola, no chyba że mają inne scope to wtedy zależy. Jest to głównie problem z serwisami ale wtedy można użyć adnotacji &lt;strong&gt;@Singleton&lt;/strong&gt; na nich i nie martwić się takimi problemami. O ile są bezstanowe ;-)&lt;/p&gt;
&lt;p&gt;I jeszcze jedna uwaga. Jeśli użyjemy wersji CDI &lt;strong&gt;@ViewScoped&lt;/strong&gt; (czyli mamy moduł Seam Faces w zależnościach) to wtedy &lt;strong&gt;Weld&lt;/strong&gt; (referencyjna implementacja CDI) wykonuje walidację czy wszystkie zależności klasy i sama klasa są serializowalne jeśli jest &lt;strong&gt;@ViewScoped&lt;/strong&gt;. W przypadku używania &lt;strong&gt;@ManagedBean&lt;/strong&gt; nie ma takiej walidacji i spokojnie możemy pakować do sesji obiekty, które nie są serializowalne ;-)&lt;/p&gt;
&lt;p&gt;Pozdrawiam&lt;br /&gt;
--&lt;br /&gt;
Łukasz&lt;br /&gt;&lt;a href="http://www.lenart.org.pl"&gt;www.lenart.org.pl&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/34"&gt;java&lt;/a&gt;&lt;/div&gt;&lt;div class="field-item odd"&gt;&lt;a href="/taxonomy/term/37"&gt;szkielety&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 15 Jun 2012 10:54:52 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2144 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2144#comments</comments>
</item>
<item>
 <title>JSF 2.0 a parametry żądania GET</title>
 <link>http://jdn.pl/node/2136</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;Możecie wierzyć lub nie, ale spece od JSFa odkryli, że świat webowy to nie tylko postback i w JSF 2.0 wprowadzili w miarę poprawną obsługę parametrów żądania &lt;strong&gt;GET&lt;/strong&gt;. Co to znaczy? Znaczy tyle, że mając żądanie o postaci:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/mypage.jsf?id=1&amp;amp;client=internal&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;możemy coś z tym zrobić :D&lt;/p&gt;
&lt;p&gt;Może wydawać się dziwne, ale z tego co ja rozumiem, to do tej pory, obsługa żądań &lt;strong&gt;GET&lt;/strong&gt; nie była możliwa, znaczy może i była możliwa, ale polegała bardziej na sztuczkach niż na wsparciu samego szkieletu JSF. Tak to czasami bywa, gdy jedyny punktu widzenia jaki mamy to nasz własny i stąd wychodzi pasztet :P&lt;/p&gt;
&lt;p&gt;Wróćmy jednak do JSF 2.0 i obsługi żądań &lt;strong&gt;GET&lt;/strong&gt; z parametrami. Aby obsłużyć powyższe żądanie po stronie JSF 2.0 musimy zmodyfikować stronę &lt;strong&gt;mypage.xhtml&lt;/strong&gt; i uzupełnić ją o odpowiednie metadata, tak jak poniżej:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="xml geshifilter-xml" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:metadata&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:viewParam&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;id&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.clientId}&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;required&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;                     &lt;span style="color: #000066;"&gt;requiredMessage&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;Proszę użyć linku ‘Edit’&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:viewParam&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;client&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.clientType}&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:event&lt;/span&gt; &lt;span style="color: #000066;"&gt;type&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;preRenderView&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;listener&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.initClient&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/f:metadata&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Trochę wyjaśnień:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;
&lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:viewParam&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt; pozwala na zdefiniowanie jakie parametry żądania GET są wymagane, aby otworzyć daną stronę
&lt;/li&gt;
&lt;li&gt;
&lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:event&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt; pozwala określić jaka metoda mam być wywołana po ustawieniu parametrów i w jakiej fazie - w 99% przypadków, będzie to &lt;strong&gt;preRenderView&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;W zbliżającym się wydaniu &lt;a href="http://jdevelopment.nl/jsf-22/"&gt;JSF 2.2&lt;/a&gt; dodano bardziej sensowny tag &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:viewAction&lt;/span&gt; &lt;span style="color: #000066;"&gt;action&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.initClient}&amp;quot;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;, ale to jeszcze przyszłość ;-)&lt;/p&gt;
&lt;p&gt;Kilka dodatkowych uwag do powyższego kodu. Powyższa metoda &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;#{myPage.initClient}&lt;/code&gt;&lt;/span&gt; zostania wywałana dla każdego żądania, również AJAX, przy czym dla żądania AJAX dwa razy (tak, zgadza się - 2x). Niestety nie jest to żaden feature tylko błąd ;-) Aby go rozwiązać trzeba przesunać &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:event&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt; poza sekcję &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:metadata&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;, jak poniżej:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="xml geshifilter-xml" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:metadata&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:viewParam&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;id&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.clientId}&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;                     &lt;span style="color: #000066;"&gt;requiredMessage&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;Proszę użyć linku ‘Edit’&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:viewParam&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;client&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.clientType}&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/f:metadata&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:event&lt;/span&gt; &lt;span style="color: #000066;"&gt;type&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;preRenderView&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;listener&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.initClient&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Kolejne uwagi, sekcji &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:metadata&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt; nie można umieścić gdzie się chce, musi to być zaraz pod elementem &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:view&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt; w innym przypadku dziwne rzeczy mogą się dziać ;-)&lt;br /&gt;
Jeśli stosujemy szablony, to należy utworzyć odpowiedni punkt wstrzykiwania sekcji metadata, jak poniżej, w przykładowym szablonie &lt;strong&gt;default.xhtml&lt;/strong&gt;:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="xml geshifilter-xml" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #00bbdd;"&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #00bbdd;"&gt;    &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;html&lt;/span&gt; &lt;span style="color: #000066;"&gt;xmlns&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;      &lt;span style="color: #000066;"&gt;xmlns:h&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;http://java.sun.com/jsf/html&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;      &lt;span style="color: #000066;"&gt;xmlns:ui&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;http://java.sun.com/jsf/facelets&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;      &lt;span style="color: #000066;"&gt;xmlns:f&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;http://java.sun.com/jsf/core&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:view&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;ui:insert&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;metadata&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;h:head&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #808080; font-style: italic;"&gt;&amp;lt;!-- css, js, etc … --&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/h:head&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;h:body&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;ui:insert&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;content&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/h:body&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/f:view&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/html&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;W powyższym przykładzie są dwie sekcje: &lt;strong&gt;metadata&lt;/strong&gt; i &lt;strong&gt;content&lt;/strong&gt;, które możemy odpowiednio wypełnić już w docelowych plikach .xhtml, jak dla przykładu w &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;mypage.xhtml&lt;/code&gt;&lt;/span&gt; poniżej:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="xml geshifilter-xml" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style="color: #000066;"&gt;version&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;encoding&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;ui:composition&lt;/span&gt; &lt;span style="color: #000066;"&gt;xmlns&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;                &lt;span style="color: #000066;"&gt;xmlns:ui&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;http://java.sun.com/jsf/facelets&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;                &lt;span style="color: #000066;"&gt;xmlns:f&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;http://java.sun.com/jsf/core&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;                &lt;span style="color: #000066;"&gt;xmlns:h&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;http://java.sun.com/jsf/html&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;                &lt;span style="color: #000066;"&gt;xmlns:a4j&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;http://richfaces.org/a4j&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;                &lt;span style="color: #000066;"&gt;template&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;WEB-INF/templates/default.xhtml&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;ui:define&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;metadata&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:metadata&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:viewParam&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;id&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.clientId}&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;required&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;                     &lt;span style="color: #000066;"&gt;requiredMessage&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;Proszę użyć linku ‘Edit’&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:viewParam&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;client&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.clientType}&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/f:metadata&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:event&lt;/span&gt; &lt;span style="color: #000066;"&gt;type&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;preRenderView&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;listener&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;#{myPage.initClient&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/ui:define&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;ui:define&lt;/span&gt; &lt;span style="color: #000066;"&gt;name&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;content&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;  &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;h1&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Moja super strona&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/h1&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/ui:define&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/ui:composition&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;I tada, gotowe :-)&lt;/p&gt;
&lt;p&gt;Prawie ;-) Jak pisałem wcześniej, metoda &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;#{myPage.initClient}&lt;/code&gt;&lt;/span&gt; zostanie wywołana dla każdego żądania AJAX, niestety ze względu na kolejny błąd w JSF, ilość żądań będzie wynosiła &lt;strong&gt;n + 1&lt;/strong&gt;, gdzie &lt;strong&gt;n&lt;/strong&gt; to liczba żądań AJAX jakie do tej pory zostały wykonane do strony :P&lt;br /&gt;
Oczywiście dotyczy to stron &lt;code&gt;@ViewScoped&lt;/code&gt;. Aby obejść problem, to musimy pomijać żądania AJAX w metodzie &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;#{myPage.initClient}&lt;/code&gt;&lt;/span&gt;, jak to robię poniżej:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;@Named&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;myPage&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;@ViewScoped&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; MyPageBean &lt;span style="color: #000000; font-weight: bold;"&gt;implements&lt;/span&gt; &lt;span style="color: #003399;"&gt;Serializable&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    @Inject&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; FacesContext ctx&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #003399;"&gt;Long&lt;/span&gt; clientId&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; ClientType clientType&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000066; font-weight: bold;"&gt;void&lt;/span&gt; initClient&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #666666; font-style: italic;"&gt;// pomijamy AJAX&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #000000; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;ctx.&lt;span style="color: #006633;"&gt;getPartialViewContext&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;isAjaxRequest&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        loadClientFromDB&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #666666; font-style: italic;"&gt;// getters, setters&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Ktoś może spytać po co tyle kombinacji ? Sam się zastanawiam, ale jeśli chce się mieć poprawną obsługę parametrów żądania, to nie ma innej drogi. Znaczy można w setterze do np. clientId dodać logikę, ale szybko się przekonamy jakie to jest niebezpieczne. Po drugie w takim przypadku musimy ręcznie wyciągać parametry z FacesContext, gdyż parametry mogą być ustawiane w nieprzewidywalnej kolejności.&lt;/p&gt;
&lt;p&gt;Jeszcze jedna uwaga, jeśli np. umieścimy sekcję gdzieś głębiej w hierarchi drzewa JSF, albo zapomnimy o &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:view&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt; czy coś jeszcze głupszego, to może się okazać, że nasza metoda i cały bean są tworzone jeśli jesteśmy na innej stronie, ale mamy na niej zdefiniowany link do &lt;strong&gt;myPage&lt;/strong&gt; ;-)&lt;/p&gt;
&lt;p&gt;Tak więc, jedynie słuszny sposób jak narazie to ten zaprezentowany powyżej.&lt;/p&gt;
&lt;p&gt;Pozdrawiam&lt;br /&gt;
--&lt;br /&gt;
Łukasz&lt;br /&gt;&lt;a href="//www.lenart.org.pl/”"&gt;www.lenart.org.pl&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/34"&gt;java&lt;/a&gt;&lt;/div&gt;&lt;div class="field-item odd"&gt;&lt;a href="/taxonomy/term/37"&gt;szkielety&lt;/a&gt;&lt;/div&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/44"&gt;projektowanie&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 09 Apr 2012 11:36:10 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2136 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2136#comments</comments>
</item>
<item>
 <title>JSF 2.0 i Ajax a redirect</title>
 <link>http://jdn.pl/node/2134</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;To kolejny z mini postów o moich doświadczeniach w pracy z JSFem 2.0, czyli bitwa trwa dalej :-)&lt;br /&gt;
Sprawa jest dość prosta, nie raz zdarza nam się, że w pracy z aplikacją webową, potrzebujemy wykonać przekierowanie (aka redirect) to innej strony. W przypadku zwykłego żądania przychodzącego ze strony JSF nie jest to problem. Robimy proste:&lt;br /&gt;
&lt;span class="geshifilter"&gt;&lt;code class="java geshifilter-java"&gt;FacesContext.&lt;span style="color: #006633;"&gt;getCurrentInstance&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;getExternalContext&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;redirect&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;/page.jsf&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Niestety, takie rozwiązanie nie zadziała dla wywołań ajaxowych, bo w sumie co miałbym z tym zrobić klient JavaScript? Oczekuje odpowiedzi w formacie:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="xml geshifilter-xml" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style="color: #000066;"&gt;version&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;encoding&lt;/span&gt;=&lt;span style="color: #ff0000;"&gt;&amp;quot;UTF-8&amp;quot;&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;partial-response&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    .....&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/partial-response&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Rozwiązanie jest dość prost choć brak dla niego oficjalnej dokumentacji ;-)&lt;/p&gt;
&lt;p&gt;Pierwszym krokiem jest sprawdzenie czy mamy do czynienia ze zwykłym żądaniem czy też jest to żądanie przychodzące z &lt;span class="geshifilter"&gt;&lt;code class="xml geshifilter-xml"&gt;&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;f:ajax&lt;/span&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;. Aby to wykryć musimy sprawdzić czy jest odpowiedni nagłówek HTTP:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #000066; font-weight: bold;"&gt;boolean&lt;/span&gt; isAjaxRequest&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;HttpServletRequest request&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;quot;partial/ajax&amp;quot;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;equalsIgnoreCase&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;request.&lt;span style="color: #006633;"&gt;getHeader&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;Faces-Request&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Skąd dostać HttpServletRequest będąc w środku JSFa ?&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;HttpServletRequest request &lt;span style="color: #339933;"&gt;=&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;HttpServletRequest&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; FacesContext.&lt;span style="color: #006633;"&gt;getCurrentInstance&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    .&lt;span style="color: #006633;"&gt;getExternalContext&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;getRequest&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Jeśli już wiemy, że mamy do czynienia z Ajaxem to pozostaje tylko odesłać odpowiednio przygotowany partial, do tego posłuże się poniższą metodą:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; &lt;span style="color: #000066; font-weight: bold;"&gt;void&lt;/span&gt; sendAjaxRedirect&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;HttpServletRequest request, HttpServletResponse response, &lt;span style="color: #003399;"&gt;String&lt;/span&gt; url&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;throws&lt;/span&gt; &lt;span style="color: #003399;"&gt;IOException&lt;/span&gt; &lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #003399;"&gt;String&lt;/span&gt; url &lt;span style="color: #339933;"&gt;=&lt;/span&gt; &lt;span style="color: #003399;"&gt;MessageFormat&lt;/span&gt;.&lt;span style="color: #006633;"&gt;format&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;{0}://{1}:{2,number,####0}{3}&amp;quot;&lt;/span&gt; &lt;span style="color: #339933;"&gt;+&lt;/span&gt; url,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            request.&lt;span style="color: #006633;"&gt;getScheme&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            request.&lt;span style="color: #006633;"&gt;getServerName&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            request.&lt;span style="color: #006633;"&gt;getServerPort&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;,&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            request.&lt;span style="color: #006633;"&gt;getContextPath&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #003399;"&gt;PrintWriter&lt;/span&gt; pw &lt;span style="color: #339933;"&gt;=&lt;/span&gt; response.&lt;span style="color: #006633;"&gt;getWriter&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    pw.&lt;span style="color: #006633;"&gt;println&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;&amp;lt;?xml version=&lt;span style="color: #000099; font-weight: bold;"&gt;\&amp;quot;&lt;/span&gt;1.0&lt;span style="color: #000099; font-weight: bold;"&gt;\&amp;quot;&lt;/span&gt; encoding=&lt;span style="color: #000099; font-weight: bold;"&gt;\&amp;quot;&lt;/span&gt;UTF-8&lt;span style="color: #000099; font-weight: bold;"&gt;\&amp;quot;&lt;/span&gt;?&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    pw.&lt;span style="color: #006633;"&gt;println&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;&amp;lt;partial-response&amp;gt;&amp;lt;redirect url=&lt;span style="color: #000099; font-weight: bold;"&gt;\&amp;quot;&lt;/span&gt;&amp;quot;&lt;/span&gt; &lt;span style="color: #339933;"&gt;+&lt;/span&gt; url &lt;span style="color: #339933;"&gt;+&lt;/span&gt; &lt;span style="color: #0000ff;"&gt;&amp;quot;&lt;span style="color: #000099; font-weight: bold;"&gt;\&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;/redirect&amp;gt;&amp;lt;/partial-response&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    pw.&lt;span style="color: #006633;"&gt;flush&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;I gotowe! Wyżej wymienionych przykładów można użyć np. w ViewHandler lub w ExceptionHandler, a można też wydzielić do osobnej klasy i wstrzykiwać je sobie tam gdzie potrzebujemy (&lt;a href="http://www.jcp.org/en/jsr/summary?id=299"&gt;CDI&lt;/a&gt; rulez :-) ).&lt;/p&gt;
&lt;p&gt;Jedna drobna uwaga, w wielu komponentach JSFa mamy dostęp do instancji &lt;span class="geshifilter"&gt;&lt;code class="java geshifilter-java"&gt;FacesContext&lt;/code&gt;&lt;/span&gt; i nie musimy wykonywać tego brzydkiego wywołania &lt;span class="geshifilter"&gt;&lt;code class="java geshifilter-java"&gt;FacesContext.&lt;span style="color: #006633;"&gt;getCurrentInstance&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;. Jeśli nie mamy a jest to bean &lt;a href="http://www.jcp.org/en/jsr/summary?id=299"&gt;CDI&lt;/a&gt; (czyli &lt;a href="http://www.jcp.org/en/jsr/summary?id=299"&gt;CDI&lt;/a&gt; nim zarządza, co niestety nie zawsze jest prawdą dla składowych JSFa ;-) to możemy wstrzyknąć sobie ów context:&lt;br /&gt;
&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;@Inject&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; FacesContext context&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Można również użyć biblioteki &lt;a href="https://github.com/softwaremill/softwaremill-common"&gt;softwaremill-common&lt;/a&gt; i magicznego &lt;span class="geshifilter"&gt;&lt;code class="java geshifilter-java"&gt;D.&lt;span style="color: #006633;"&gt;inject&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;/code&gt;&lt;/span&gt; ale to może opisze przy innej okazji.&lt;/p&gt;
&lt;p&gt;Pozdrawiam&lt;br /&gt;
--&lt;br /&gt;
Łukasz&lt;br /&gt;&lt;a href="http://www.lenart.org.pl/"&gt;www.lenart.org.pl&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/33"&gt;generalnie&lt;/a&gt;&lt;/div&gt;&lt;div class="field-item odd"&gt;&lt;a href="/taxonomy/term/34"&gt;java&lt;/a&gt;&lt;/div&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/37"&gt;szkielety&lt;/a&gt;&lt;/div&gt;&lt;div class="field-item odd"&gt;&lt;a href="/taxonomy/term/44"&gt;projektowanie&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 13 Mar 2012 12:06:25 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2134 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2134#comments</comments>
</item>
<item>
 <title>JSF 2.0 i Ajax</title>
 <link>http://jdn.pl/node/2130</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;Dość tych żalów, przjedźmy do mojego problemu. Poniżej prezentuje drobny wycinek strony XHTML, zawierający dwa formularze oraz mechanizm odświeżania wyników za pomocą &amp;lt;f:ajax/&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="html4strict geshifilter-html4strict" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;lt;h:form &lt;span style="color: #000066;"&gt;id&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;form1&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;lt;h:panelGroup &lt;span style="color: #000066;"&gt;id&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;searchPanel&amp;quot;&lt;/span&gt; layout&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;block&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;lt;h:outputLabel &lt;span style="color: #000066;"&gt;for&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;searchValue&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;Search value:&lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:outputLabel&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;lt;h:inputText &lt;span style="color: #000066;"&gt;id&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;filterValue&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;#{bean.searchValue}&amp;quot;&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;lt;h:commandButton &lt;span style="color: #000066;"&gt;value&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;Search&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;action&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;#{bean.search}&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;id&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;doSearch&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&amp;lt;f:ajax execute&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;form1&amp;quot;&lt;/span&gt; render&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;results :form2&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;         &lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:commandButton&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:panelGroup&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;lt;h:dataTable &lt;span style="color: #000066;"&gt;id&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;results&amp;quot;&lt;/span&gt; &lt;span style="color: #000066;"&gt;value&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;#{bean.results}&amp;quot;&lt;/span&gt; var&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;result&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;lt;h:column&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&amp;lt;f:facet &lt;span style="color: #000066;"&gt;name&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;header&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;Value&lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;f:facet&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;             &lt;span style="color: #009900;"&gt;&amp;lt;h:outputText &lt;span style="color: #000066;"&gt;value&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;#{result}&amp;quot;&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:column&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:dataTable&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:form&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;lt;h:form &lt;span style="color: #000066;"&gt;id&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;form2&amp;quot;&lt;/span&gt; rendered&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;#{not empty bean.results}&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;lt;h:commandLink &lt;span style="color: #000066;"&gt;action&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;#{bean.createPrint}&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;lt;h:graphicImage &lt;span style="color: #000066;"&gt;value&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;images/print.png&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:commandLink&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:form&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Krótkie wyjaśnienie dla powyższego kodu, jak widać &lt;strong&gt;form1&lt;/strong&gt; zawiera jedno pole do wyszukiwania oraz przycisk &lt;strong&gt;Search&lt;/strong&gt;. Po kliknięciu w przycisk, formularz &lt;strong&gt;form1&lt;/strong&gt; zostanie przesłany za pomocą Ajaxa do Managed Bean &lt;strong&gt;bean&lt;/strong&gt; (atrybut execute wskazuje na form1). Następnie zwrócona odpowiedź zostanie użyta do wyrenderowania &lt;strong&gt;results&lt;/strong&gt; i &lt;strong&gt;form2&lt;/strong&gt; (atrybut render zawiera dwa id: &lt;strong&gt;results&lt;/strong&gt; i &lt;strong&gt;form2&lt;/strong&gt;).&lt;/p&gt;
&lt;p&gt;Drobne wyjaśnienie co do zapisu atrybutu &lt;strong&gt;render&lt;/strong&gt;, jedno z id zawiera dwukropek na początku. Wynika to z tego, że &lt;strong&gt;form2&lt;/strong&gt; jest po zasięgiem &lt;strong&gt;form1&lt;/strong&gt;, czyli w innym scopie i aby Ajax wiedział o tym podaje się właśnie &lt;strong&gt;:&lt;/strong&gt; na początku id elementu. Oczywiście można było zapisać to też tak &lt;code&gt;render=":form1:results :form2"&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Niestety powyższy kod zawiera drobny błąd, jeśli spróbujecie go użyć i wynik wyszukiwania będzie pusty (#{empty results}) to formularz &lt;strong&gt;form2&lt;/strong&gt; będzie dalej pokazywany. Dlaczego ?&lt;/p&gt;
&lt;p&gt;Wynika to z działania JSFa i Ajaxa (powinno być Ajaxa dżejesofowego, ale chyba jasne ;-) ), teoretycznie &lt;strong&gt;form2&lt;/strong&gt; zawiera atrybut &lt;strong&gt;rendered&lt;/strong&gt; i jeśli był by to zwykły request, który przeładowuje stronę to wszystko działało by pięknie. W przypadku jednak Ajaxa, atrybut rendered nie jest brany pod uwagę na elemencie, który jest podany jako id. Dopiero elementy w nim zawarte podlegąją tej logice.&lt;/p&gt;
&lt;p&gt;Wystarczy dodać jeden element więcej i problem rozwiąże się sam, czyli tak jak poniżej:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="html4strict geshifilter-html4strict" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;lt;h:panelGroup &lt;span style="color: #000066;"&gt;id&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;form2&amp;quot;&lt;/span&gt; layout&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;block&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;lt;h:form rendered&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;#{not empty bean.results}&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;lt;h:commandLink &lt;span style="color: #000066;"&gt;action&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;#{bean.createPrint}&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&amp;lt;h:graphicImage &lt;span style="color: #000066;"&gt;value&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;=&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;images/print.png&amp;quot;&lt;/span&gt;&lt;span style="color: #ff0000;"&gt;&amp;quot;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:commandLink&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:form&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;lt;&lt;span style="color: #66cc66;"&gt;/&lt;/span&gt;h:panelGroup&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Pozdrawiam&lt;br /&gt;
--&lt;br /&gt;
Łukasz &lt;a href="http://www.lenart.org.pl/"&gt;www.lenart.org.pl&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/37"&gt;szkielety&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Wed, 29 Feb 2012 08:18:18 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2130 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2130#comments</comments>
</item>
<item>
 <title>A może tak JDO</title>
 <link>http://jdn.pl/node/2126</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;Właśnie, ilekroć pada pytanie co zastosować do persystencji danych w aplikacji javowej w połączeniu z bazą relacyjną, z reguły odpowiedzią jest Hibernate, JPA, no może czasami (ale to bardzo rzadko), czyste JDBC ;-)&lt;br /&gt;
A jakiś czas temu, firma odpowiedzialna za powstanie Javy (dla młodzieży, nie chodzi o Oracle'a ;-), wymyśliła jak to powinno wyglądać i przygotowała &lt;a href="http://jcp.org/en/jsr/detail?id=12"&gt;JSR-12&lt;/a&gt; - po numerku widać, że było to dawno temu ;-) Było to lata świetlne przed Hibernatem.&lt;/p&gt;
&lt;p&gt;Tak właśnie powstał standard Java Data Objects, w skrócie JDO. Pozwalał on na mapowanie obiektów nie tylko do baz danych ale również do innych repozytoriów danych - LDAP, pliki Excel, NoSQL, etc. Głównym założeniem było oderwanie się od relacyjnych baz danych i to już w 2000 roku! Niestety, dziadek Sun nie był tak mocny aby przeforsować swoją ideę, bo było ona nie na rękę wielkim graczom rynku  baz danych w tamtych czasach. I tak to dzisiaj odkrywamy koło po raz drugi za pomocą JPA ;-)&lt;/p&gt;
&lt;p&gt;JDO zostało przekazane jakiś czas temu pod skrzydła &lt;a href="http://db.apache.org/"&gt;ASF&lt;/a&gt; i jest rozwijane w ramach &lt;a href="http://db.apache.org/jdo"&gt;Apache DB&lt;/a&gt;. Jest kilka implementacji specyfikacji JDO ale najnowszą wspiera tylko &lt;a href="http://www.datanucleus.org/products/"&gt;DataNucleus&lt;/a&gt;. I tak na marginesie, JDO i DataNucleus jest używane w ramach &lt;a href="https://appengine.google.com"&gt;Google AppEngine&lt;/a&gt; ;-)&lt;/p&gt;
&lt;p&gt;Skąd moje zainteresowanie tematem ? Wracając z ostatniego &lt;a href="http://devoxx.com/"&gt;Devoxxa&lt;/a&gt; jakoś tak mnie naszło, aby przypomnieć i poczytać sobie o tej technologii - właśnie w związku z AppEngine. A druga sposobność pojawiła się kilak dni temu, kiedy to Sebastian &lt;a href="http://groups.google.com/group/polish-java-user-group/browse_frm/thread/954789495d426712"&gt;napisał&lt;/a&gt; na grupie PJUG, że ma problem z JDO.&lt;/p&gt;
&lt;p&gt;Poniżej zaprezentuje kroki jakie wykonałem, aby otrzymać działający przykład oparty o JDO w ramach JavaSE. Nie będę tu przytaczał dokumentacji, co i jak, bo kod jest prosty. A jak ktoś chce poczytać więcej, czemu JDO jest lepsze od JPA i innych wynalazków to zapraszam do lektury dokumentacji pod w/w linkami.&lt;/p&gt;
&lt;p&gt;Przytoczę tylko jedną zasadniczą różnicę. W przypadku Hibernate'a / JPA mamy do czynienia z klasami proxy, które opakowują nasze encje, stąd np. problem z Lazy Initialization czy z porównywaniem instancji (&lt;strong&gt;instanceof&lt;/strong&gt;). W przypadku JDO jest tzw. proces rozszerzania klas (ang. enhancer), który zmienia byetcode klasy encji, dodając do niego wymagane elementy potrzebne do utworzenia encji zarządzalnej przez JDO. Jest to dalej nasza klasa i &lt;strong&gt;instanceof&lt;/strong&gt; zadziała, możemy również  zapomnieć o Lazy Initialisation Exception :P&lt;/p&gt;
&lt;p&gt;Do tego dochodzi możliwość zarządzania wszystkimi aspektami z poziomu API, nawet możliwość definiowania nowych klas i ich rozszerzanie w loci ;-)&lt;/p&gt;
&lt;p&gt;Przejdźmy do kodu, oczywiście kod podstawowy wygenerowałem za pomocą komendy:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="bash geshifilter-bash" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;mvn archetype:generate&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;teraz uzupełniam pom.xml o zależności i dodaje plugin enhancera, celem automatycznego rozszerzania klas&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="xml geshifilter-xml" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;build&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;plugins&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;plugin&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.datanucleus&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;maven-datanucleus-plugin&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3.0.0-release&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;configuration&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;api&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;JDO&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/api&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;log4jConfiguration&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;${project.basedir}/resources/log4j.properties&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/log4jConfiguration&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;verbose&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;true&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/verbose&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;props&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;${project.basedir}/resources/jdo.properties&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/props&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/configuration&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;executions&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;execution&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;phase&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;compile&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/phase&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;goals&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;goal&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;enhance&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/goal&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/goals&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/execution&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/executions&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/plugin&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/plugins&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/build&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;dependencies&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;javax.jdo&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;jdo-api&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3.0&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.datanucleus&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;datanucleus-core&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3.0.2&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;scope&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;runtime&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/scope&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.datanucleus&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;datanucleus-api-jdo&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3.0.2&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.datanucleus&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;datanucleus-rdbms&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;3.0.2&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;mysql&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;mysql-connector-java&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;5.1.9&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;org.testng&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/groupId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;testng&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/artifactId&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;5.14.9&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/version&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;scope&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;test&lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/scope&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/dependency&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;lt;/dependencies&lt;span style="color: #000000; font-weight: bold;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Najważniejszym elementem jest plugin &lt;strong&gt;maven-datanucleus-plugin&lt;/strong&gt;, który wykonuje rozszerzanie klasy w fazie kompilacji. Bez niego JDO nie będzie działać. Dostępny jest plugin do Eclipse'a, jak również w ramach pluginu do AppEngine istnieje wbudowana funkcja Enhancera.&lt;/p&gt;
&lt;p&gt;Teraz pasuje napisać jakiś model, który będzie zapisywany w bazie danych.&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;@PersistenceCapable&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; Person &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    @PrimaryKey&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    @Persistent&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;valueStrategy &lt;span style="color: #339933;"&gt;=&lt;/span&gt; IdGeneratorStrategy.&lt;span style="color: #006633;"&gt;INCREMENT&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000066; font-weight: bold;"&gt;long&lt;/span&gt; id &lt;span style="color: #339933;"&gt;=&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    @Persistent&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #003399;"&gt;String&lt;/span&gt; name &lt;span style="color: #339933;"&gt;=&lt;/span&gt; &lt;span style="color: #000066; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    @Persistent&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000066; font-weight: bold;"&gt;int&lt;/span&gt; age &lt;span style="color: #339933;"&gt;=&lt;/span&gt; &lt;span style="color: #cc66cc;"&gt;0&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; Person&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #003399;"&gt;String&lt;/span&gt; name, &lt;span style="color: #000066; font-weight: bold;"&gt;int&lt;/span&gt; age&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #000000; font-weight: bold;"&gt;this&lt;/span&gt;.&lt;span style="color: #006633;"&gt;name&lt;/span&gt; &lt;span style="color: #339933;"&gt;=&lt;/span&gt; name&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #000000; font-weight: bold;"&gt;this&lt;/span&gt;.&lt;span style="color: #006633;"&gt;age&lt;/span&gt; &lt;span style="color: #339933;"&gt;=&lt;/span&gt; age&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #666666; font-style: italic;"&gt;// gettery i settery, equals, hashCode, toString&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Adnotacje chyba są dość zrozumiałe, a jak nie to proszę pytać w komentarzach ;-) Rzecz, na którą chce wam zwrócić uwagę to brak domyślnego konstruktora, który niestety trzeba dodawać w przypadku Hibernate'a i JPA, dla JDO nie jest to problemem ;-)&lt;/p&gt;
&lt;p&gt;Kolejna klasa służy do zapisu/odczytu obiektów z bazy danych, jako że jest to prosty przykład oparty na JavaSE, dochodzi trochę śmieci związanych z transakcjami, ale łatwych do wyeliminowania stosując np. wzorzec &lt;a href="http://en.wikipedia.org/wiki/Command_pattern"&gt;Command&lt;/a&gt; ;-)&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt; PersonPersister &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; List&lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt;Person&lt;span style="color: #339933;"&gt;&amp;gt;&lt;/span&gt; list&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        PersistenceManager pm &lt;span style="color: #339933;"&gt;=&lt;/span&gt; createPM&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            Transaction tx &lt;span style="color: #339933;"&gt;=&lt;/span&gt; pm.&lt;span style="color: #006633;"&gt;currentTransaction&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            tx.&lt;span style="color: #006633;"&gt;begin&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            Query query &lt;span style="color: #339933;"&gt;=&lt;/span&gt; pm.&lt;span style="color: #006633;"&gt;newQuery&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;Person.&lt;span style="color: #000000; font-weight: bold;"&gt;class&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            List&lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt;Person&lt;span style="color: #339933;"&gt;&amp;gt;&lt;/span&gt; list &lt;span style="color: #339933;"&gt;=&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;List&lt;span style="color: #339933;"&gt;&amp;lt;&lt;/span&gt;Person&lt;span style="color: #339933;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; query.&lt;span style="color: #006633;"&gt;execute&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            tx.&lt;span style="color: #006633;"&gt;commit&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; list&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #003399;"&gt;Exception&lt;/span&gt; e&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #000000; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;pm.&lt;span style="color: #006633;"&gt;currentTransaction&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;isActive&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                pm.&lt;span style="color: #006633;"&gt;currentTransaction&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;rollback&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            e.&lt;span style="color: #006633;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: #003399;"&gt;Collections&lt;/span&gt;.&lt;span style="color: #006633;"&gt;emptyList&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;finally&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            pm.&lt;span style="color: #006633;"&gt;close&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;public&lt;/span&gt; Person persist&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;Person person&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        PersistenceManager pm &lt;span style="color: #339933;"&gt;=&lt;/span&gt; createPM&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            Transaction tx &lt;span style="color: #339933;"&gt;=&lt;/span&gt; pm.&lt;span style="color: #006633;"&gt;currentTransaction&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            tx.&lt;span style="color: #006633;"&gt;begin&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            Person persisted &lt;span style="color: #339933;"&gt;=&lt;/span&gt; pm.&lt;span style="color: #006633;"&gt;makePersistent&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;person&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            tx.&lt;span style="color: #006633;"&gt;commit&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; persisted&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #003399;"&gt;Exception&lt;/span&gt; e&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #000000; font-weight: bold;"&gt;if&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;pm.&lt;span style="color: #006633;"&gt;currentTransaction&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;isActive&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;                pm.&lt;span style="color: #006633;"&gt;currentTransaction&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;rollback&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            e.&lt;span style="color: #006633;"&gt;printStackTrace&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; &lt;span style="color: #000066; font-weight: bold;"&gt;null&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;finally&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            pm.&lt;span style="color: #006633;"&gt;close&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #000000; font-weight: bold;"&gt;private&lt;/span&gt; PersistenceManager createPM&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #003399;"&gt;Properties&lt;/span&gt; properties &lt;span style="color: #339933;"&gt;=&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span style="color: #003399;"&gt;Properties&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #000000; font-weight: bold;"&gt;try&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            properties.&lt;span style="color: #006633;"&gt;load&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;getClass&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;getResource&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;/jdo.properties&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;.&lt;span style="color: #006633;"&gt;openStream&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;catch&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #003399;"&gt;IOException&lt;/span&gt; e&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color: #009900;"&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;            &lt;span style="color: #000000; font-weight: bold;"&gt;throw&lt;/span&gt; &lt;span style="color: #000000; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span style="color: #003399;"&gt;RuntimeException&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #0000ff;"&gt;&amp;quot;File 'jdo.properties' not found&amp;quot;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        PersistenceManagerFactory pmf &lt;span style="color: #339933;"&gt;=&lt;/span&gt; JDOHelper.&lt;span style="color: #006633;"&gt;getPersistenceManagerFactory&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;properties&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;        &lt;span style="color: #000000; font-weight: bold;"&gt;return&lt;/span&gt; pmf.&lt;span style="color: #006633;"&gt;getPersistenceManager&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;    &lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;&lt;span style="color: #009900;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;W sumie kod też powinien być zrozumiały, cała magia jest w jednej linijce:&lt;/p&gt;
&lt;p&gt;&lt;div class="geshifilter"&gt;&lt;pre class="java geshifilter-java" style="font-family:monospace;"&gt;&lt;ol&gt;&lt;li style="font-family: monospace; font-weight: normal;"&gt;&lt;div style="font-family: monospace; font-weight: normal; font-style: normal"&gt;PersistenceManagerFactory pmf &lt;span style="color: #339933;"&gt;=&lt;/span&gt; JDOHelper.&lt;span style="color: #006633;"&gt;getPersistenceManagerFactory&lt;/span&gt;&lt;span style="color: #009900;"&gt;&amp;#40;&lt;/span&gt;properties&lt;span style="color: #009900;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color: #339933;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;można to porównać do EntityManagerFactory z JPA, a dostępne metody można porównać na tej &lt;a href="http://db.apache.org/jdo/jdo_v_jpa_api.html"&gt;stronie&lt;/a&gt;. Z powyższego widać, że JDO nie jest wcale trudniejsze od Hibernate'a czy JPA, działa podobnie a daje o wiele większe możliwości. &lt;/p&gt;
&lt;p&gt;Nie wspominał tu o &lt;a href="http://db.apache.org/jdo/fetchgroups.html"&gt;Fetch Groups&lt;/a&gt;, czyli czymś co można porównać do FetchType.LAZY i FetchType.EAGER ale z o wiele większymi możliwościami, np. definiowanie w trakcie działania aplikacji jak i co ma być pobierane za jednym razem z bazy (czyli dynamiczny LAZY i EAGER ;-)&lt;/p&gt;
&lt;p&gt;Albo definiowanie klas w trakcie działania aplikacji, rozszerzenie ich i dodanie to bazy danych. Możliwości, o których można pomarzyć w przypadku JPA ;-)&lt;/p&gt;
&lt;p&gt;Cały kod aplikacji jest dostępny w &lt;a href="https://github.com/lukaszlenart/jdo-demo"&gt;repozytorium&lt;/a&gt; na GitHubie.&lt;/p&gt;
&lt;p&gt;Pozdrawiam&lt;br /&gt;
--&lt;br /&gt;
Łukasz&lt;br /&gt;&lt;a href="http://www.lenart.org.pl/"&gt;http://www.lenart.org.pl/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;PS. Cześć druga do RESTeasy jest prawie gotowa ;-)&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/34"&gt;java&lt;/a&gt;&lt;/div&gt;&lt;div class="field-item odd"&gt;&lt;a href="/taxonomy/term/44"&gt;projektowanie&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Thu, 15 Dec 2011 10:01:00 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2126 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2126#comments</comments>
</item>
<item>
 <title>Global Day of Coderetreat</title>
 <link>http://jdn.pl/node/2124</link>
 <description>&lt;div class="field field-name-body field-type-text-with-summary field-label-hidden"&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;p&gt;Początkiem grudnia na całym świecie odbędzie się kilkadziesiąt imprez pod wspólnym hasłem &lt;a href="http://coderetreat.com/global_day.html"&gt;Global Day of Coderetreat&lt;/a&gt;, czyli wspólnego uczenia się kodowania za pomocą TDD i Pair-Programming. Jak do tej pory w Polsce odbyło się kilka pojedynczych sesji Coderetreat, jedna była prowadzona przez samego Corey'a Haines, było to podczas konferencji &lt;a href="http://agilece.com/"&gt;AgileCE 2010&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Z tego co można zaobserwować na &lt;a href="http://coderetreat.ning.com/events/event/search?q=poland"&gt;stronie GDCR&lt;/a&gt; do udziału w zabawie zgłosiły się trzy miasta - Kraków, Warszawa i Poznań. Tak więc można spokojnie wyszukać najbliższe miejsce i zapisać się do udziału w zabawie.&lt;/p&gt;
&lt;p&gt;Czym jest Coderetreat ?&lt;/p&gt;
&lt;p&gt;Tak jak pisałem - jest to zabawa, piszemy Grę w Życie (Game of Life) stosując praktyki TDD i programowanie w parach. Piszemy w dowolnym języku, co chyba jest najlepszym sposobem na poznanie np. Rubiego dla programistów Java ;-)&lt;br /&gt;
Cały wydarzenie jest podzielone na kilka 45-minutowych sesji, pomiędzy którymi pary są mieszane, czyli każdą kolejną sesję rozpoczynasz kodować z kimś innym ;-)&lt;/p&gt;
&lt;p&gt;Podczas GDCR planowane jest połączenie video między różnymi lokalizacjami, aby na bieżąco uczestniczyć w spotkaniach na całym świecie.&lt;/p&gt;
&lt;p&gt;Niestety nie mam informacji co jest planowane w Warszawie i w Poznaniu, ale podczas &lt;a href="http://coderetreat.sckrk.com/"&gt;GDCR&lt;/a&gt; w Krakowie, organizatorzy ugoszczą wszystkich uczestników obiadem, będzie dostępna kawa jak również okazjonalne koszulki i to nawet dwie dla każdego - jak uda wszystko się dopiąć. Wieczorem planowane jest mała impreza, gdzie przy piwie będzie można porozmawiać nie tylko o kodowaniu. Całe wydarzenie jest darmowe, wystarczy się zarejestrować.&lt;/p&gt;
&lt;p&gt;Organizatorem jest grupa &lt;a href="http://sckrk.com/"&gt;Software Craftsmanship in Kraków&lt;/a&gt; przy wsparciu &lt;a href="http://lunarlogicpolska.com/"&gt;Lunar Logic Polska&lt;/a&gt;, &lt;a href="http://www.abb.pl/"&gt;ABB&lt;/a&gt; i &lt;a href="http://applicake.com/"&gt;Applicake&lt;/a&gt;. Partnerem globalnym jest &lt;a href="http://www.jetbrains.com/"&gt;JetBrains&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Liczba miejsc jest ograniczona, więc zapisz się już dziś, jeśli chcesz spędzić wolną sobotę na wspólnym kodowaniu ;-)&lt;/p&gt;
&lt;p&gt;Pozdrawiam&lt;br /&gt;
--&lt;br /&gt;
Łukasz&lt;br /&gt;&lt;a href="http://www.lenart.org.pl/"&gt;http://www.lenart.org.pl/&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="field field-name-taxonomy-vocabulary-4 field-type-taxonomy-term-reference field-label-above"&gt;&lt;div class="field-label"&gt;etykiety:&amp;nbsp;&lt;/div&gt;&lt;div class="field-items"&gt;&lt;div class="field-item even"&gt;&lt;a href="/taxonomy/term/54"&gt;spotkania&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 21 Nov 2011 11:46:00 +0000</pubDate>
 <dc:creator>Łukasz Lenart</dc:creator>
 <guid isPermaLink="false">2124 at http://jdn.pl</guid>
 <comments>http://jdn.pl/node/2124#comments</comments>
</item>
</channel>
</rss>
