Tuesday, February 10, 2015

How to update JSF library in JBoss

1. Download the expected version of JSF library.
jsf-api
https://repository.jboss.org/nexus/content/groups/public/org/jboss/spec/javax/faces/jboss-jsf-api_2.1_spec/

jsf-impl
https://repository.jboss.org/nexus/content/groups/public-jboss/com/sun/faces/jsf-impl/

2. Copy the newly downloaded JSF jar into the following folder
jsf-api
<JBoss_AS>/modules/javax/faces/api/main
<JBoss_EAP>/modules/system/layers/base/javax/faces/api/main

jsf-impl
<JBoss_AS>/modules/com/sun/jsf-impl/main
<JBoss_EAP>/modules/system/layers/base/com/sun/jsf-impl/main

3. Modify module.xml with the new jar file name.
jsf-api
    <resources>
        <resource-root path="jboss-jsf-api_2.1_spec-2.1.19.1.Final-redhat-1.jar"/>
    </resources>
jsf-impl
    <resources>
        <resource-root path="jsf-impl-2.1.19-redhat-2.jar"/>
    </resources>

4. Restart JBoss


Done!!


Tuesday, February 3, 2015

How to display loop count in velocity

The following syntax will loop the map and display the value in the map.

#foreach($abc in $abcMap)
   $abc.get("a")  $abc.get("b")  $abc.get("c")
#endbbb


To display the loop count, just need to add velocityCount.

#foreach($abc in $abcMap)
   $velocityCount $abc.get("a")  $abc.get("b")  $abc.get("c")
#endbbb



Done!!

Thursday, January 15, 2015

How to display null as empty string with Apache Velocity

We used the following Syntax to display attribute's value in Apache Velocity.
$myValue


But the problem is that, we the value carried by the attribute is null.
Velocity is not displaying an empty string or "null",
it display the attribute name that is being used.

attribute: [ $myValue1, $myValue2, $myValue3, $myValue4 ]
value:      [ "First", null, "Third", "" ]
Output:   [ First, $myValue2, Third,  ]


To display the NULL value as an empty string. we just need to add "!" after "$"

attribute: [ $!myValue1, $!myValue2, $!myValue3, $!myValue4 ]
value:      [ "First", null, "Third", "" ]
Output:   [ First, , Third,  ]


Done!!

Tuesday, January 13, 2015

How to retrieve value in map with Apache Velocity

Assuming we have a HashMap with the following value

HashMap myMap = new HashMap();
myMap.put("k1", "v1");
myMap.put("k2", "v2");
myMap.put("k3", "v3");


put the HashMap into the VelocityContext.

VelocityContext context = new VelocityContext();
context.put("myMap", myMap);


To retrieve the map value in the Velocity template (.vm file),
Use the following syntax to retrieve map value with constant key.

$myMap.get("k1");
$myMap.get("k2");
$myMap.get("k3");


Use the following syntax to retrieve map value with dynamic key.

$myMap.get($mapKey1);
$myMap.get($mapKey2);
$myMap.get($mapKey3);


Done!!

Saturday, December 6, 2014

How to increase JBoss Server memory and heap size when running JBoss with Eclipse Server Plugin

1. in Server view, double click on the selected configured JBoss runtime

2. click on Open launch configuration

3. in the VM arguments section, change to the desired settings

4. Click OK when finish editing the VM arguments.


Done!!

LinkWithin

Related Posts Plugin for WordPress, Blogger...