JDev

Code, jstlOctober 26, 2006 12:15 pm

It’s very easy to concatenate strings and combine expressions in JSTL.

Here is an example

<c:set var="query" value="${nextAction}?item=${param.item}"/>

Anything not enclosed in ${…} is treated like a literal, and expressions inside the curly brackets are evaluated. So if ${nextAction} has the value of "viewCart.do" and ${param.item} has the value of "1234", the value of the query variable will be as follows:

viewCart.do?item=1234

Also, you can concatenate a variable to itself as follows:

<c:set var=’myVar’ value=’myValue’>
<c:set var=’myVar’ value= ‘${myVar} and some other value’ />

 This can be useful if you deal with iterations. An example:

<c:forTokens var="token" delims=":" items="a:b:c:d:e">
         <c:set var=’myVar‘ value=’${myVar} ${token} and’ />           
</c:forTokens>

<c:out value=’${myVar}’/> outputs ‘a and b and c and d and e and‘.

You can skip the last iteration using the varStatus variable:

<c:forTokens var="token" delims=":" items="a:b:c:d:e" varStatus=’vs‘>     
         <c:set var=’where’ value=’${where} workorder_id = ${token}’ />            
         <c:if test = "${!vs.last}">            
             <c:set var=’myVar’ value=’${myVar} ${token} and’ /> 
        </c:if>            
</c:forTokens>

 

Visit http://www.ekcsoft.com/coding/java/jstl_parameters to learn how to display and sort all request parameters with JSTL.

 

php, mysqlOctober 21, 2006 7:31 pm

The easiest way to search for full words in mysql is to use regular expressions. According to this article you need to use these markers - [[:<:]], [[:>:]]

that stand for word boundaries.

First, build a variable from the search parameter :

$val = addslashes($_GET[’search’]);               

Construct a regular expression pattern: 

$reg =’[[:<:]]’. $val .’[[:>:]]’ ;           

Finally, build a sql statement:

Select comments from table1 where comments REGEXP ‘$reg’ 

 So far, it has worked for me.

javaOctober 13, 2006 2:21 pm

Go to Windows->Preferences

In the preferences window, expand Java->Editor.

Make sure the Editor is selected.

On the right side panel, under the Appearance tab, make sure the check-box Show line numbers is checked.

Click Ok to save the new setting. 

 

cssOctober 8, 2006 3:24 pm

The first important rule is that vertical margins collapse. That means that when a browser calculates the vertical distance between two adjacent elements, the largest margin will be applied, and the other one will be ignored. On the other hand, horizontal margins are added together to work out the total horizontal distance between two elements.

javascriptOctober 6, 2006 6:55 pm

If you have a string with possible multiple spaces between words, and you want to convert the string to an array, use a split() method with the following regular expression : /\s*/  .

Example:

var str = "aa   bb    cc  dd";
var ar = str.split(/ \s*/)
;

 The resulting array will contain 4 elements : aa, bb, cc, dd.

A pattern to strip tags:

str.replace(/<\/?[^>]+>/gi, ‘’);

 Have not checked it yet. It is being used in the prototype library.

 

Code, javascriptOctober 2, 2006 5:56 pm

I had an issue in Internet Explorer and Ajax with utf-8 encoding. IE did not handle a Russian language string encoding properly even though the page had the utf-8 character set. It turns out you need to use the javascript encodeURI function for the URL.