Archive for June, 2011

svn ignore or exclude target folder

Problem: How to ignore target and other folders during svn synchronization in eclipse


First of all, the best practice is not to check in any folders which could be modified outside subversion context e.g. target, logs etc.

To avoid these folders appear every time when you synchronise add them to svn:ignore, usually by right clicking and selecting the target to add to svn:ignore or from project properties.

Leave a comment

Maven web resources filtering

Problem: How to perform maven filtering for resources inside webapp

Solution: To acheive this, we need to add the below plugin inside pom.xml and include the resources that need to be filtered, in this example, its *.html

<!– Enabling and configuring web resources filtering –>
<!– include any other file types as needed –>

once the resources are filtered, pom specific settings will be available in the html, for example version of the project can be accessed from the html as ${project.version}

Leave a comment


Problem: How to use jquery to set the values of selected dropdown  and selected checkboxes inside html/jsp


Inside your jsp, add script tag and define functions that will called during the events from dropdown(onchange) and onclick for checkboxes

var drpdown;
var myArray;

function selectDropdown() {
drpdown = $(“#select-dropdown”).val();



function showCheckbox(){
//get checkboxes
myArray = new Array(2);
if ($(‘#n-width:checked’).val() !== undefined)
myArray[0] = $(‘#cb1’).text();
if ($(‘#n-height:checked’).val() !== undefined)
myArray[1] = $(‘#cb2’).text();



once the above script is added in head, define body and a table inside to create dropdown and checkbox elements



Select From Dropdown:
<select id=”select-dropdown” onchange=”selectDropdown();”>
<option selected=”selected”></option>
<option >OPTION1</option>
<option >OPTION2</option>
<label for=”r-left” id=”cb1″>CHECKBOX1</label>
<input type=”checkbox” id=”n-width”  onclick=”showCheckbox();”/>
<label for=”r-left” id=”cb2″>CHECKBOX2</label>
<input type=”checkbox” id=”n-height” onclick=”showCheckbox();”/>



Upon changing the dropdown, selectDropdown will be called and we are using jquery inside selectDropdown to get the value of teh dropdown. Similarly for checkboxes, showCheckbox will be called and using jquery, i am getting the values for selected checkboxes

Leave a comment

Hibernate Criteria setResultTransformer

Problem: How to loop through a resultset with the column alias names defined in the native SQL, instead of accessing the resultset by column index in hibernate


Sometimes, accessing the resultset by the names of the columns is much convenient than accessing the result set by index, say a row’s first column as get(0) and second column by get(1).

In this case, when using hibernate, calling setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list(),  causes it to return a list of Maps.

For example,

Query query1 = session.createSQLQuery(query.toString()).setParameter(“PRODID”, prodid).setParameter(“PRODTYPE”, prodtype);

//Convert the Query object to a list of maps

List iter1 = query1.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP).list();
Map<String,Object> map= new HashMap<String,Object>();
for (Object object : iter1)
map= (Map<String,Object>)object;






1 Comment