lunes, 2 de noviembre de 2009

Obtener nueva IP

@echo off
ipconfig /release

netsh interface IP set address "internet" static 1.2.3.4 255.0.0.0 1.2.3.5 5

netsh interface ip set address name="internet" source=dhcp

ipconfig /renew





http://bandaancha.eu/tema/1651022/reconectar-jdownloader

miércoles, 12 de agosto de 2009

Pergem exception

http://www.javamexico.org/blogs/avali2/causas_y_solucion_de_java_lang_outofmemoryerror_permgen_space_failure

http://spaquet.blogspot.com/2006/07/liferay-glassfish-part-ii-configuring.html

martes, 16 de junio de 2009

Liferay: Mi visor 2


## Número de resultado que mostraremos por página

#set ($numResults4Page = 2)



#set ($muvas = $portal.getClass().forName("es.muvas.MuvasSemanticServices").newInstance())

#set($tags= $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "tags", false))



#set($minusTags= $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "minusTags", false))



#set ($page = $getterUtil.getInteger($httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "page", false)))



#set ($renderUrlWithoutPage = $stringUtil.remove($httpUtil.decodeURL($request.attributes.CURRENT_URL), "&page=$page",""))

#set ($renderUrlWithoutPage = $stringUtil.remove($httpUtil.decodeURL($request.attributes.CURRENT_URL), "page=$page",""))



#if ($page == 0)

#set ($page = 1)

#end



#set ($company = ""+$companyId)



#set ($renderUrl = $request.get("render-url"))

#set ($namespace = $request.get("portlet-namespace"))



## Comienzo div principal

<div class="results-grid">



#set($articlesVisorBaseUrl = "/web/guest/article/-/journal_content/56_INSTANCE_2ABK/")

#set($searchContainer = $muvas.searchJournalArticles($company, $tags, $minusTags, ""))

#set ($results = $searchContainer.getResults($numResults4Page, $page))

#set ($numPages = $searchContainer.getNumPages($numResults4Page))

#foreach ($result in $results)

#set ($articleUrl = $articlesVisorBaseUrl + $result.groupId +  "/" + $result.articleId)



#set($muvasArticle = $muvas.getMuvasArticle($result.groupId, $result.articleId))

<h3>$result.title</h3>



#if($muvasArticle.getIGImage())

          <a class="mini_photo" href="$muvasArticle.imageURL"><img alt="$muvasArticle.getIGImage().description" title="$muvasArticle.getIGImage().name" src="/image/image_gallery?img_id=${muvasArticle.getIGImage().smallImageId}"></a>

#end



<div>

$muvasArticle.description

</div>



<div>

<a title="Ver artículo: $result.title" href="$articleUrl">$result.title</a>

</div>



#end



#if ($searchContainer.length > 0)

<div class="taglib-search-iterator-page-iterator-bottom">

    <div class="taglib-page-iterator">



#set ($last= $results.size() - 1)

        <div class="search-results">

#set ($beginIndex = $results.get(0).index)

#set ($lastIndex = $results.get($last).index)

#if ($beginIndex == $lastIndex)

Mostrando resultado $beginIndex de $searchContainer.length resultados.

#else

Mostrando resultados $beginIndex - $lastIndex de $searchContainer.length resultados.

#end

        </div>

        <div class="search-pages">

            <div class="delta-selector"> Items per Page

                <select>

                    <option  value="5">5</option>

                    <option  value="10">10</option>

                    <option selected="selected" value="20">20</option>

                    <option  value="30">30</option>

                    <option  value="50">50</option>

                    <option  value="75">75</option>

                </select>

            </div>





<script type="text/javascript">

function _submitMyPageIterator() {

var curValue = jQuery("option:selected", this).val();

var href = "${renderUrlWithoutPage}&page="+curValue;

location.href = href;

}

jQuery(

function() {

jQuery('.page-selector-select').change(_submitMyPageIterator);

}

);

</script>





            <div class="page-selector"> Página

                <select class="page-selector-select">

#foreach ($i in [1..$numPages])

#if ($i == $page)

                    <option selected="selected" value="$i">$i</option>

#else

                    <option value="$i">$i</option>

#end

#end

                </select> de $numPages

            </div>

            <div class="page-links">



#set ($prev = $page - 1)

#set ($next = $page + 1)





#if ($page == 1)

                <span class="first"> Primero </span>

                <span class="previous"> Anterior </span>

#else

                <a class="first" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", 1)"> Primero </a>

                <a class="previous" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $prev)"> Anterior </a>

#end



#if ($numPages == $page)

                <span class="next"> Siguiente </span>

                <span class="last"> Último </span>

#else

                <a class="next" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $next)"> Siguiente </a>

                <a class="last" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $numPages)"> Último </a>

#end

            </div>

        </div>

    </div>

</div>

#end



</div>

Liferay: Mi visor


## Número de resultado que mostraremos por página

#set ($numResults4Page = 2)



#set ($muvas = $portal.getClass().forName("es.muvas.MuvasSemanticServices").newInstance())

#set($tags= $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "tags", false))



#set($minusTags= $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "minusTags", false))



#set ($page = $getterUtil.getInteger($httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "page", false)))



#set ($renderUrlWithoutPage = $stringUtil.remove($httpUtil.decodeURL($request.attributes.CURRENT_URL), "&page=$page",""))

#set ($renderUrlWithoutPage = $stringUtil.remove($httpUtil.decodeURL($request.attributes.CURRENT_URL), "page=$page",""))



#if ($page == 0)

#set ($page = 1)

#end



#set ($company = ""+$companyId)



#set ($renderUrl = $request.get("render-url"))

#set ($namespace = $request.get("portlet-namespace"))



## Comienzo div principal

<div class="results-grid">

<table class="taglib-search-iterator">

<tr class="portlet-section-header results-header">

<th class="col-1">#</th>

<th class="col-2">Nombre</th>

<th class="col-3">Contenido</th>

</tr>



#set($articlesVisorBaseUrl = "/web/guest/article/-/journal_content/56_INSTANCE_2ABK/")

#set($searchContainer = $muvas.searchJournalArticles($company, $tags, $minusTags, ""))

#set ($results = $searchContainer.getResults($numResults4Page, $page))

#set ($numPages = $searchContainer.getNumPages($numResults4Page))

#foreach ($result in $results)

#set ($articleUrl = $articlesVisorBaseUrl + $result.groupId +  "/" + $result.articleId)



#if ($velocityCount % 2 == 0)

<tr class="portlet-section-alternate results-row alt"

onmouseover="this.className = 'portlet-section-alternate-hover results-row alt hover';" onmouseout="this.className = 'portlet-section-alternate results-row alt';">

<td align="left" class="col-1" colspan="1" valign="middle">

$result.index.

</td>

<td align="left" class="col-2" colspan="1" valign="middle">

$result.titlehighlight

</td>

<td align="left" class="col-3" colspan="1" valign="middle">

$result.content

<br />

<span style="font-size: xx-small;">

<br /><a title="Ver artículo: $result.title" href="$articleUrl">$result.title</a>

</span>

</td>

</tr>

#else

<tr class="portlet-section-body results-row"

onmouseover="this.className = 'portlet-section-body-hover results-row hover';" onmouseout="this.className = 'portlet-section-body results-row';">

<td align="left" class="col-1" colspan="1" valign="middle">

$result.index.

</td>

<td align="left" class="col-2" colspan="1" valign="middle">

$result.titlehighlight

</td>

<td align="left" class="col-3" colspan="1" valign="middle">

$result.content

<br />

<span style="font-size: xx-small;">

<br /><a title="Ver artículo: $result.title" href="$articleUrl">$result.title</a>

</span>

</td>

</tr>

#end

#end

</table>

#if ($searchContainer.length > 0)

<div class="taglib-search-iterator-page-iterator-bottom">

    <div class="taglib-page-iterator">



#set ($last= $results.size() - 1)

        <div class="search-results">

#set ($beginIndex = $results.get(0).index)

#set ($lastIndex = $results.get($last).index)

#if ($beginIndex == $lastIndex)

Mostrando resultado $beginIndex de $searchContainer.length resultados.

#else

Mostrando resultados $beginIndex - $lastIndex de $searchContainer.length resultados.

#end

        </div>

        <div class="search-pages">

            <div class="delta-selector"> Items per Page

                <select>

                    <option  value="5">5</option>

                    <option  value="10">10</option>

                    <option selected="selected" value="20">20</option>

                    <option  value="30">30</option>

                    <option  value="50">50</option>

                    <option  value="75">75</option>

                </select>

            </div>





<script type="text/javascript">

function _submitMyPageIterator() {

var curValue = jQuery("option:selected", this).val();

var href = "${renderUrlWithoutPage}&page="+curValue;

location.href = href;

}

jQuery(

function() {

jQuery('.page-selector-select').change(_submitMyPageIterator);

}

);

</script>





            <div class="page-selector"> Página

                <select class="page-selector-select">

#foreach ($i in [1..$numPages])

#if ($i == $page)

                    <option selected="selected" value="$i">$i</option>

#else

                    <option value="$i">$i</option>

#end

#end

                </select> de $numPages

            </div>

            <div class="page-links">



#set ($prev = $page - 1)

#set ($next = $page + 1)





#if ($page == 1)

                <span class="first"> Primero </span>

                <span class="previous"> Anterior </span>

#else

                <a class="first" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", 1)"> Primero </a>

                <a class="previous" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $prev)"> Anterior </a>

#end



#if ($numPages == $page)

                <span class="next"> Siguiente </span>

                <span class="last"> Último </span>

#else

                <a class="next" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $next)"> Siguiente </a>

                <a class="last" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $numPages)"> Último </a>

#end

            </div>

        </div>

    </div>

</div>

#end

</div>

Liferay: Mi buscador avanzado


## Número de resultado que mostraremos por página

#set ($numResults4Page = 2)



#set ($muvas = $portal.getClass().forName("es.muvas.MuvasSemanticServices").newInstance())





#set($museum = $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "museum", false))

#set($author = $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "author", false))

#set($type = $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "type", false))

#set($topic = $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "topic", false))

#set($search = $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "search", false))



#set ($page = $getterUtil.getInteger($httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "page", false)))



#set ($renderUrlWithoutPage = $stringUtil.remove($httpUtil.decodeURL($request.attributes.CURRENT_URL), "&page=$page",""))



#if ($page == 0)

#set ($page = 1)

#end



#set ($company = ""+$companyId)



#set ($renderUrl = $request.get("render-url"))

#set ($namespace = $request.get("portlet-namespace"))





#set ($museums = $muvas.findMuseums())

#set ($authors = $muvas.findAuthors())

#set ($types = $muvas.fingTypes())

#set ($topics = $muvas.fingTopics())



<form action="$renderUrl" method="get" name="${namespace}fm2">

    <label for="museum">Museo: </label>

                <select name="museum" id="museum">

#if($museum == "")

                    <option selected="selected"  value="">Todas</option>

#else

                    <option  value="">Todas</option>

#end

#foreach ($each in $museums)

#if($museum == $each.id)

                    <option selected="selected" value="$each.id">$each.title</option>

#else

                    <option  value="$each.id">$each.title</option>

#end

#end

                </select>

    <label for="author">Autor: </label>

                <select name="author" id="author">

#if($author == "")

                    <option selected="selected"  value="">Todas</option>

#else

                    <option  value="">Todas</option>

#end

#foreach ($each in $authors)

#if($author == $each.id)

                    <option selected="selected" value="$each.id">$each.title</option>

#else

                    <option  value="$each.id">$each.title</option>

#end

#end

                </select>

    <label for="type">Tipo: </label>

                <select name="type" id="type">

#if($type == "")

                    <option selected="selected"  value="">Todas</option>

#else

                    <option  value="">Todas</option>

#end

#foreach ($each in $types)

#if($type ==$each)

                    <option selected="selected" value="$each">$each</option>

#else

                    <option  value="$each">$each</option>

#end

#end

                </select>

    <label for="topic">Tema: </label>

                <select name="topic" id="topic">

#if($topic == "")

                    <option selected="selected"  value="">Todas</option>

#else

                    <option  value="">Todas</option>

#end

#foreach ($each in $topics)

#if($topic == $each)

                    <option selected="selected" value="$each">$each</option>

#else

                    <option  value="$each">$each</option>

#end

#end

                </select>



    <label for="search">Búsqueda: </label>

              <input type="text" value="$!search" id="search" name="search"/>



    <input type="submit" value="Buscar"/>

</form>



#if ($search && $search.trim() != "")



<div class="results-grid">

<table class="taglib-search-iterator">

<tr class="portlet-section-header results-header">

<th class="col-1">#</th>

<th class="col-2">Nombre</th>

<th class="col-3">Contenido</th>

</tr>



#set($articlesVisorBaseUrl = "/web/guest/article/-/journal_content/56_INSTANCE_2ABK/")

$museum

$author

$type

$topic

$muvas.searchJournalArticlesPiece($company, "", "", "", "", $search).length





#set($searchContainer = $muvas.searchJournalArticlesPiece($company, $museum, $author, $type, $topic, $search))

#set ($results = $searchContainer.getResults($numResults4Page, $page))

#set ($numPages = $searchContainer.getNumPages($numResults4Page))

#foreach ($result in $results)

#set ($articleUrl = $articlesVisorBaseUrl + $result.groupId +  "/" + $result.articleId)



#if ($velocityCount % 2 == 0)

<tr class="portlet-section-alternate results-row alt"

onmouseover="this.className = 'portlet-section-alternate-hover results-row alt hover';" onmouseout="this.className = 'portlet-section-alternate results-row alt';">

<td align="left" class="col-1" colspan="1" valign="middle">

$result.index.

</td>

<td align="left" class="col-2" colspan="1" valign="middle">

$result.titlehighlight

</td>

<td align="left" class="col-3" colspan="1" valign="middle">

$result.content

<br />

<span style="font-size: xx-small;">

<br /><a title="Ver artículo: $result.title" href="$articleUrl">$result.title</a>

</span>

</td>

</tr>

#else

<tr class="portlet-section-body results-row"

onmouseover="this.className = 'portlet-section-body-hover results-row hover';" onmouseout="this.className = 'portlet-section-body results-row';">

<td align="left" class="col-1" colspan="1" valign="middle">

$result.index.

</td>

<td align="left" class="col-2" colspan="1" valign="middle">

$result.titlehighlight

</td>

<td align="left" class="col-3" colspan="1" valign="middle">

$result.content

<br />

<span style="font-size: xx-small;">

<br /><a title="Ver artículo: $result.title" href="$articleUrl">$result.title</a>

</span>

</td>

</tr>

#end

#end

</table>

#if ($searchContainer.length > 0)

<div class="taglib-search-iterator-page-iterator-bottom">

    <div class="taglib-page-iterator">



#set ($last= $results.size() - 1)

        <div class="search-results">

#set ($beginIndex = $results.get(0).index)

#set ($lastIndex = $results.get($last).index)

#if ($beginIndex == $lastIndex)

Mostrando resultado $beginIndex de $searchContainer.length resultados.

#else

Mostrando resultados $beginIndex - $lastIndex de $searchContainer.length resultados.

#end

        </div>

        <div class="search-pages">

            <div class="delta-selector"> Items per Page

                <select>

                    <option  value="5">5</option>

                    <option  value="10">10</option>

                    <option selected="selected" value="20">20</option>

                    <option  value="30">30</option>

                    <option  value="50">50</option>

                    <option  value="75">75</option>

                </select>

            </div>





<script type="text/javascript">

function _submitMyPageIterator() {

var curValue = jQuery("option:selected", this).val();

var href = "${renderUrlWithoutPage}&page="+curValue;

location.href = href;

}

jQuery(

function() {

jQuery('.page-selector-select').change(_submitMyPageIterator);

}

);

</script>





            <div class="page-selector"> Página

                <select class="page-selector-select">

#foreach ($i in [1..$numPages])

#if ($i == $page)

                    <option selected="selected" value="$i">$i</option>

#else

                    <option value="$i">$i</option>

#end

#end

                </select> de $numPages

            </div>

            <div class="page-links">



#set ($prev = $page - 1)

#set ($next = $page + 1)





#if ($page == 1)

                <span class="first"> Primero </span>

                <span class="previous"> Anterior </span>

#else

                <a class="first" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", 1)"> Primero </a>

                <a class="previous" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $prev)"> Anterior </a>

#end



#if ($numPages == $page)

                <span class="next"> Siguiente </span>

                <span class="last"> Último </span>

#else

                <a class="next" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $next)"> Siguiente </a>

                <a class="last" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $numPages)"> Último </a>

#end

            </div>

        </div>

    </div>

</div>

#end

</div>

#end

Liferay: Mi buscador


## Número de resultado que mostraremos por página

#set ($numResults4Page = 2)



#set ($muvas = $portal.getClass().forName("es.muvas.MuvasSemanticServices").newInstance())

#set($search = $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "search", false))



#set ($page = $getterUtil.getInteger($httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "page", false)))



#set ($renderUrlWithoutPage = $stringUtil.remove($httpUtil.decodeURL($request.attributes.CURRENT_URL), "&page=$page",""))



#if ($page == 0)

#set ($page = 1)

#end



#set ($company = ""+$companyId)



#set ($renderUrl = $request.get("render-url"))

#set ($namespace = $request.get("portlet-namespace"))



<form action="$renderUrl" method="get" name="${namespace}fm2">

    <label for="search">Búsqueda: </label>

              <input type="text" value="$!search" name="search"/>



    <input type="submit" value="Buscar"/>

</form>



#if ($search && $search.trim() != "")



<div class="results-grid">

<table class="taglib-search-iterator">

<tr class="portlet-section-header results-header">

<th class="col-1">#</th>

<th class="col-2">Nombre</th>

<th class="col-3">Contenido</th>

</tr>



#set($articlesVisorBaseUrl = "/web/guest/article/-/journal_content/56_INSTANCE_2ABK/")

#set($searchContainer = $muvas.searchJournalArticles($company, $search))

#set ($results = $searchContainer.getResults($numResults4Page, $page))

#set ($numPages = $searchContainer.getNumPages($numResults4Page))

#foreach ($result in $results)

#set ($articleUrl = $articlesVisorBaseUrl + $result.groupId +  "/" + $result.articleId)



#if ($velocityCount % 2 == 0)

<tr class="portlet-section-alternate results-row alt"

onmouseover="this.className = 'portlet-section-alternate-hover results-row alt hover';" onmouseout="this.className = 'portlet-section-alternate results-row alt';">

<td align="left" class="col-1" colspan="1" valign="middle">

$result.index.

</td>

<td align="left" class="col-2" colspan="1" valign="middle">

$result.titlehighlight

</td>

<td align="left" class="col-3" colspan="1" valign="middle">

$result.content

<br />

<span style="font-size: xx-small;">

<br /><a title="Ver artículo: $result.title" href="$articleUrl">$result.title</a>

</span>

</td>

</tr>

#else

<tr class="portlet-section-body results-row"

onmouseover="this.className = 'portlet-section-body-hover results-row hover';" onmouseout="this.className = 'portlet-section-body results-row';">

<td align="left" class="col-1" colspan="1" valign="middle">

$result.index.

</td>

<td align="left" class="col-2" colspan="1" valign="middle">

$result.titlehighlight

</td>

<td align="left" class="col-3" colspan="1" valign="middle">

$result.content

<br />

<span style="font-size: xx-small;">

<br /><a title="Ver artículo: $result.title" href="$articleUrl">$result.title</a>

</span>

</td>

</tr>

#end

#end

</table>

#if ($searchContainer.length > 0)

<div class="taglib-search-iterator-page-iterator-bottom">

    <div class="taglib-page-iterator">



#set ($last= $results.size() - 1)

        <div class="search-results">

#set ($beginIndex = $results.get(0).index)

#set ($lastIndex = $results.get($last).index)

#if ($beginIndex == $lastIndex)

Mostrando resultado $beginIndex de $searchContainer.length resultados.

#else

Mostrando resultados $beginIndex - $lastIndex de $searchContainer.length resultados.

#end

        </div>

        <div class="search-pages">

            <div class="delta-selector"> Items per Page

                <select>

                    <option  value="5">5</option>

                    <option  value="10">10</option>

                    <option selected="selected" value="20">20</option>

                    <option  value="30">30</option>

                    <option  value="50">50</option>

                    <option  value="75">75</option>

                </select>

            </div>





<script type="text/javascript">

function _submitMyPageIterator() {

var curValue = jQuery("option:selected", this).val();

var href = "${renderUrlWithoutPage}&page="+curValue;

location.href = href;

}

jQuery(

function() {

jQuery('.page-selector-select').change(_submitMyPageIterator);

}

);

</script>





            <div class="page-selector"> Página

                <select class="page-selector-select">

#foreach ($i in [1..$numPages])

#if ($i == $page)

                    <option selected="selected" value="$i">$i</option>

#else

                    <option value="$i">$i</option>

#end

#end

                </select> de $numPages

            </div>

            <div class="page-links">



#set ($prev = $page - 1)

#set ($next = $page + 1)





#if ($page == 1)

                <span class="first"> Primero </span>

                <span class="previous"> Anterior </span>

#else

                <a class="first" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", 1)"> Primero </a>

                <a class="previous" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $prev)"> Anterior </a>

#end



#if ($numPages == $page)

                <span class="next"> Siguiente </span>

                <span class="last"> Último </span>

#else

                <a class="next" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $next)"> Siguiente </a>

                <a class="last" href="$httpUtil.addParameter($renderUrlWithoutPage, "page", $numPages)"> Último </a>

#end

            </div>

        </div>

    </div>

</div>

#end

</div>

#end

miércoles, 10 de junio de 2009

Liferay- Formulario desde plantilla de velocity

Quería realizar un JournalArticle que contuviese una búsqueda, para ello necesitaba enviar un formulario desde velocity. Para ello:





## Accedemos al parametro que contiene la busqueda
#set($search = $request.parameters.search)

#set ($renderUrl = $request.get("render-url"))
#set ($namespace = $request.get("portlet-namespace"))
<form action="$renderUrl" method="post" name="${namespace}fm2">
<label for="search">Búsqueda: </label>
<input type="text" value="$!search" name="${namespace}search"/>
<input type="submit" value="Send"/>
</form>



Y si preferimos enviar el formulario usando el método "get" nos servirá para invocarlo desde la URL, la forma sería:




#set($search = $httpUtil.getParameter($httpUtil.decodeURL($request.attributes.CURRENT_URL), "search"))

#set ($renderUrl = $request.get("render-url"))
#set ($namespace = $request.get("portlet-namespace"))

<form action="$renderUrl" method="get" name="${namespace}fm2">
    <label for="search">Búsqueda: </label>
              <input type="text" value="$!search" name="search"/>

    <input type="submit" value="Send"/>
</form>

jueves, 30 de abril de 2009

Acceder a servicios de Liferay desde plantilla de velocity

Existe 2 opciones

La primera necesita:
  1. Usando el "liferay-ext", modificar el fichero "portal_ext.proporties" y cambiar la entrada: "journal.template.velocity.restricted.variables= " es decir no debe tener valor o al menos no contener "serviceLocator" con ello tendremos una variable que nos permite acceder a servicios de Liferay.
  2. Si deseamos acceder a un servicio propio deberemos crearlo e insertalo usando "liferay-ext"
  3. Finalmente para acceder: desde dentro de la plantilla:

    #set ($tagsService = $serviceLocator.findService("com.liferay.portlet.tags.service.TagsAssetLocalService"))
    #set ($journalArticleResourceService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleResourceLocalService"))



    #set ($longGroupId = $getterUtil.getLong($groupId))
    #set ($articleResourcePK = $journalArticleResourceService.getArticleResourcePrimKey($longGroupId, $reserved-article-id.data))
    #set ($tagsAsset = $tagsService.getAsset("com.liferay.portlet.journal.model.JournalArticle", $articleResourcePK))
    #set ($tagsEntries = $tagsAsset.getEntries())

    Tags:
    #foreach( $entry in $tagsEntries )
    #set ($tag = $entry.getName())
    #if($velocityCount!=1), #end
    $tag
    #end

Con esa plantilla accemos a todos los tags del artículo actual y los escribimos.

La segunda alternativa no requiere modificar el fichero "portal_ext.properties" y consiste en:

#set ($tagsService = $portal.getClass().forName("com.liferay.portlet.tags.service.TagsAssetLocalServiceUtil").getMethod("getService", null).invoke(null, null))
#set ($journalArticleResourceService = $portal.getClass().forName("com.liferay.portlet.journal.service.JournalArticleResourceLocalServiceUtil").getMethod("getService", null).invoke(null, null))

Con ello accedemos también a los servicios.


Otro ejemplo, acceder al usuario que escribio el artículo e imprimir su nombre

#set ($userService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($user = $userService.getUserById($getterUtil.getLong($reserved-article-author-id.getData())))
$user.getScreenName()



Ejemplo propio


#set ($museumService = $serviceLocator.findService("com.muvac.service.MuseumLocalService"))


#set ($museum= $museumService.findById($museo.data))




Autor: ${autor.data}
Museo: ${museo.data}


Datos del museo

$museum.name
$museum.description

miércoles, 18 de marzo de 2009

Documentación sobre JSF y otros

Framework AME (Endesa)
MADEJA (Junta de Andalucía), apartado sobre JSF.

Editores de imágenes javascript

Pixastic (opensource)

Ubiquity (aún sólo una idea)



Picnik (comercial, sólo puede usarse a través de la Web no como librería). No es javascript sino flash.
Sumo (comercial, Web) No es javascript sino flash.
Aviary (comercial, Web, flash)

"Memory leaks" en Java

How to Fix Memory Leaks in Java
Depurar fugas de memoria en Java (Tomcat)