IT정리노트

블로그 이미지

Edward. K

메멘토적 기억능력을 소유한 개발자 노트.

'Programming/JavaScript'에 해당되는 글 44건

제목 날짜
  • 페이지 로딩시 onload event 처 2008.05.15
  • PRE STYLE 2008.04.29
  • \n이 있을 시 자바스크립트 오류가 나기 때문에 "" 로 치환. 2008.04.16
  • [JSLT] Expression Language 2008.03.12
  • JavaScript Code Improver 2007.12.04

페이지 로딩시 onload event 처

Programming/JavaScript 2008. 5. 15. 18:05
반응형

<SCRIPT LANGUAGE="JavaScript">
<!--
    // 페이지 로딩시 onload event 처리..
    function init_event() {
    var now = new Date();
    
}
window.attachEvent('onload',init_event);
//-->
</SCRIPT>
반응형
Posted by Edward. K

PRE STYLE

Programming/JavaScript 2008. 4. 29. 09:42
반응형
<pre style='width:580; word-wrap:break-word;overflow-x:hidden;'>--------<br></pre>

<pre style='width:580; height:180; word-wrap:break-word;overflow-y:auto;'>

<pre style='width:580; height:150; word-wrap:break-word;overflow:hidden;overflow-y:auto;'>
 


overflow-x:hidden;    x,y 축 넘어가면 자동 줄넘김 처리
반응형
Posted by Edward. K

\n이 있을 시 자바스크립트 오류가 나기 때문에 "" 로 치환.

Programming/JavaScript 2008. 4. 16. 10:53
반응형

function removeStrip(src){
    //\n이 있을 시 자바스크립트 오류가 나기 때문에 "" 로 치환.
    var strip = new RegExp();
    strip = /[\r][\n][""]/gi;
    
    var s = src.replace(strip, "");
    return src.replace(strip, "");
}

반응형
Posted by Edward. K

[JSLT] Expression Language

Programming/JavaScript 2008. 3. 12. 10:18
반응형
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html

Expression Language

A primary feature of JSP technology version 2.0 is its support for an expression language (EL). An expression language makes it possible to easily access application data stored in JavaBeans components. For example, the JSP expression language allows a page author to access a bean using simple syntax such as ${name} for a simple variable or ${name.foo.bar} for a nested property.

The test attribute of the following conditional tag is supplied with an EL expression that compares the number of items in the session-scoped bean named cart with 0:

<c:if test="${sessionScope.cart.numberOfItems > 0}"> 
  ...
</c:if>

The JSP expression evaluator is responsible for handling EL expressions, which are enclosed by the ${ } characters and can include literals. Here's an example:

<c:if test="${bean1.a < 3}" >
  ...
</c:if>

Any value that does not begin with ${ is treated as a literal and is parsed to the expected type using the PropertyEditor for the type:

<c:if test="true" >
...
</c:if>

Literal values that contain the ${ characters must be escaped as follows:

<mytags:example attr1="an expression is ${'${'}true}" /> 

Deactivating Expression Evaluation

Because the pattern that identifies EL expressions--${ }--was not reserved in the JSP specifications before JSP 2.0, there may be applications where such a pattern is intended to pass through verbatim. To prevent the pattern from being evaluated, you can deactivate EL evaluation.

To deactivate the evaluation of EL expressions, you specify the isELIgnored attribute of the page directive:

<%@ page isELIgnored ="true|false" %> 

The valid values of this attribute are true and false. If it is true, EL expressions are ignored when they appear in static text or tag attributes. If it is false, EL expressions are evaluated by the container.

The default value varies depending on the version of the web application deployment descriptor. The default mode for JSP pages delivered using a Servlet 2.3 or earlier descriptor is to ignore EL expressions; this provides backward compatibility. The default mode for JSP pages delivered with a Servlet 2.4 descriptor is to evaluate EL expressions; this automatically provides the default that most applications want. You can also deactivate EL expression evaluation for a group of JSP pages (see Deactivating EL Expression Evaluation).

Using Expressions

EL expressions can be used:

  • In static text
  • In any standard or custom tag attribute that can accept an expression

The value of an expression in static text is computed and inserted into the current output. If the static text appears in a tag body, note that an expression will not be evaluated if the body is declared to be tagdependent (see body-content Attribute).

There are three ways to set a tag attribute value:

  • With a single expression construct:
  • <some:tag value="${expr}"/>

    The expression is evaluated and the result is coerced to the attribute's expected type.

  • With one or more expressions separated or surrounded by text:
  • <some:tag value="some${expr}${expr}text${expr}"/>

    The expressions are evaluated from left to right. Each expression is coerced to a String and then concatenated with any intervening text. The resulting String is then coerced to the attribute's expected type.

  • With text only:
  • <some:tag value="sometext"/>

    In this case, the attribute's String value is coerced to the attribute's expected type.

Expressions used to set attribute values are evaluated in the context of an expected type. If the result of the expression evaluation does not match the expected type exactly, a type conversion will be performed. For example, the expression ${1.2E4} provided as the value of an attribute of type float will result in the following conversion:

Float.valueOf("1.2E4").floatValue()  

See section JSP2.8 of the JSP 2.0 specification for the complete type conversion rules.

Variables

The web container evaluates a variable that appears in an expression by looking up its value according to the behavior of PageContext.findAttribute(String). For example, when evaluating the expression ${product}, the container will look for product in the page, request, session, and application scopes and will return its value. If product is not found, null is returned. A variable that matches one of the implicit objects described in Implicit Objects will return that implicit object instead of the variable's value.

Properties of variables are accessed using the . operator and can be nested arbitrarily.

The JSP expression language unifies the treatment of the . and [] operators. expr-a.identifier-b is equivalent to expr-a["identifier-b"]; that is, the expression expr-b is used to construct a literal whose value is the identifier, and then the [] operator is used with that value.

To evaluate expr-a[expr-b], evaluate expr-a into value-a and evaluate expr-b into value-b. If either value-a or value-b is null, return null.

  • If value-a is a Map, return value-a.get(value-b). If !value-a.containsKey(value-b), then return null.
  • If value-a is a List or array, coerce value-b to int and return value-a.get(value-b) or Array.get(value-a, value-b), as appropriate. If the coercion couldn't be performed, an error is returned. If the get call returns an IndexOutOfBoundsException, null is returned. If the get call returns another exception, an error is returned.
  • If value-a is a JavaBeans object, coerce value-b to String. If value-b is a readable property of value-a, then return the result of a get call. If the get method throws an exception, an error is returned.

Implicit Objects

The JSP expression language defines a set of implicit objects:

  • pageContext: The context for the JSP page. Provides access to various objects including:
    • servletContext: The context for the JSP page's servlet and any web components contained in the same application. See Accessing the Web Context.
    • session: The session object for the client. See Maintaining Client State.
    • request: The request triggering the execution of the JSP page. See Getting Information from Requests.
    • response: The response returned by the JSP page. See Constructing Responses.

In addition, several implicit objects are available that allow easy access to the following objects:

  • param: Maps a request parameter name to a single value
  • paramValues: Maps a request parameter name to an array of values
  • header: Maps a request header name to a single value
  • headerValues: Maps a request header name to an array of values
  • cookie: Maps a cookie name to a single cookie
  • initParam: Maps a context initialization parameter name to a single value

Finally, there are objects that allow access to the various scoped variables described in Using Scope Objects.

  • pageScope: Maps page-scoped variable names to their values
  • requestScope: Maps request-scoped variable names to their values
  • sessionScope: Maps session-scoped variable names to their values
  • applicationScope: Maps application-scoped variable names to their values

When an expression references one of these objects by name, the appropriate object is returned instead of the corresponding attribute. For example, ${pageContext} returns the PageContext object, even if there is an existing pageContext attribute containing some other value.

Literals

The JSP expression language defines the following literals:

  • Boolean: true and false
  • Integer: as in Java
  • Floating point: as in Java
  • String: with single and double quotes; " is escaped as \", ' is escaped as \', and \ is escaped as \\.
  • Null: null

Operators

In addition to the . and [] operators discussed in Variables, the JSP expression language provides the following operators:

  • Arithmetic: +, - (binary), *, / and div, % and mod, - (unary)
  • Logical: and, &&, or, ||, not, !
  • Relational: ==, eq, !=, ne, <, lt, >, gt, <=, ge, >=, le. Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.
  • Empty: The empty operator is a prefix operation that can be used to determine whether a value is null or empty.
  • Conditional: A ? B : C. Evaluate B or C, depending on the result of the evaluation of A.

The precedence of operators highest to lowest, left to right is as follows:

  • [] .
  • () - Used to change the precedence of operators.
  • - (unary) not ! empty
  • * / div % mod
  • + - (binary)
  • < > <= >= lt gt le ge
  • == != eq ne
  • && and
  • || or
  • ? :

Reserved Words

The following words are reserved for the JSP expression language and should not be used as identifiers.

and   eq   gt   true   instanceof
or    ne   le   false  empty
not   lt   ge   null   div   mod

Note that many of these words are not in the language now, but they may be in the future, so you should avoid using them.

Examples

Table 12-2 contains example EL expressions and the result of evaluating them.

Table 12-2 Example Expressions
EL Expression
Result
${1 > (4/2)}
false
${4.0 >= 3}
true
${100.0 == 100}
true
${(10*10) ne 100}
false
${'a' < 'b'}
true
${'hip' gt 'hit'}
false
${4 > 3}
true
${1.2E4 + 1.4}
12001.4
${3 div 4}
0.75
${10 mod 4}
2
${empty param.Add}
True if the request parameter named Add is null or an empty string
${pageContext.request.contextPath}
The context path
${sessionScope.cart.numberOfItems}
The value of the numberOfItems property of the session-scoped attribute named cart
${param['mycom.productId']}
The value of the request parameter named mycom.productId
${header["host"]}
The host
${departments[deptName]}
The value of the entry named deptName in the departments map
${requestScope['javax.servlet.
forward.servlet_path']}
The value of the request-scoped attribute named javax.servlet.
forward.servlet_path

Functions

The JSP expression language allows you to define a function that can be invoked in an expression. Functions are defined using the same mechanisms as custom tags (See Using Custom Tags and Chapter 15).

Using Functions

Functions can appear in static text and tag attribute values.

To use a function in a JSP page, you use a taglib directive to import the tag library containing the function. Then you preface the function invocation with the prefix declared in the directive.

For example, the date example page index.jsp imports the /functions library and invokes the function equals in an expression:

<%@ taglib prefix="f" uri="/functions"%>
...
    <c:when
      test="${f:equals(selectedLocaleString,
        localeString)}" >

Defining Functions

To define a function you program it as a public static method in a public class. The mypkg.MyLocales class in the date example defines a function that tests the equality of two Strings as follows:

package mypkg;
public class MyLocales {

  ...
  public static boolean equals( String l1, String l2 ) {
    return l1.equals(l2);
  }
}

Then you map the function name as used in the EL expression to the defining class and function signature in a TLD. The following functions.tld file in the date example maps the equals function to the class containing the implementation of the function equals and the signature of the function:

<function>
  <name>equals</name>
  <function-class>mypkg.MyLocales</function-class>
  <function-signature>boolean equals( java.lang.String,
    java.lang.String )</function-signature>
</function>

A tag library can have only one function element that has any given name element.

반응형
Posted by Edward. K

JavaScript Code Improver

Programming/JavaScript 2007. 12. 4. 08:40
반응형

한줄로 된 자바스크립트를 정리해주는 프로그램이라고 하네요..

유용할듯...


Hot! Deluxe Menus: Dynamic Menu, Dynamic Tree, Dynamic Tabs

5.0
De Luxe Menu. The most powerful DHTML Menu on the Web! Create a cross-browser, search engine friendly, fast-loading web interface of any desired complexity and appearance. You don't need any in-depth knowledge of HTML or Javascript to develop web menus with Deluxe Menu. By simply changing a menu parameter file, you can create any navigation system in minutes. Deluxe Menu comes with an easy-to-use GUI wizard and hundreds of pre-designed templates in Vista, XP, Win98, Ms Office, Linux, MacOs styles. that allows you to generate and test the menu in just a few mouse clicks.
Free Trial Platform(s): Linux, Windows, FreeBSD, Mac OSX, Sun Solaris Date: Nov, 01 2006
DOWNLOAD
VISIT
DETAIL

JavaScript Code Improver


Cannot read your own JavaScript code?
Cannot find that closing brace?
Lost all hope of making head or tail of the JavaScript code inherited from your colleague?
Or just curious of how JavaScript works?


Try JavaScript Code Improver!

With JavaScript Code Improver you are just one click away from making any JavaScript clear, easily comprehensible and ready for printing thus saving the time you spend on editing, debugging and modifying it. Forget about all problems resulting from those illegible JavaScripts!

Compare how the same piece of code looks before:

<script language="JavaScript">var i=0,s="",k=0;function foo(){for(j=0;j<10;j++){for(i=0;i<10;i++){s="string1";k=Math.floor(Math.random()*10);}for(i=20;i>9;i--){s="string2";k=i;}}}</script>
 

and after processing by JavaScript Code Improver:

<script language="JavaScript">
var i = 0, s = "", k = 0;
function foo()
{
    for(j = 0; j < 10; j++)
    {
        for(i = 0; i < 10; i++)
        {
            s = "string1";
            k = Math.floor( Math.random()*10 );
        }
        for(i = 20; i > 9; i--)
        {
            s = "string2";
            k = i;
        }
    }
}
</script>

You can see the difference, can’t you?

The program’s flexible settings let you structure the code in any way you like. So, even if your JavaScript code is pretty comprehensible, you can just give it more professional or just more pleasant feel.

So, download JavaScript Code Improver now and test.

DOWNLOAD

Author: info ( at ) jcay.com
반응형
Posted by Edward. K
이전페이지 다음페이지
블로그 이미지

메멘토적 기억능력을 소유한 개발자 노트.

by Edward. K

공지사항

    최근...

  • 포스트
  • 댓글
  • 트랙백
  • 더 보기

태그

  • 플래시 게임
  • iBATIS
  • rocketdock
  • 캡쳐툴
  • 색상코드표
  • tomcat
  • STS
  • 이클립스
  • android
  • 사업 이야기
  • 전자정부프레임워크
  • 가상화폐무료
  • EkNote
  • toad
  • egov
  • Flash Player
  • flex
  • Graphic
  • 중독성게임
  • 컴퓨터 관리
  • ERwin
  • sqlgate
  • 개한민국
  • Jboss
  • 이미지 편집
  • 미네르바
  • netbeans
  • EditPlus
  • eclipse plugin
  • Eclipse

글 보관함

«   2025/08   »
일 월 화 수 목 금 토
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

링크

카테고리

분류 전체보기 (792)
행운이와함께 (1)
EkNote Project (18)
ARIS (0)
Android (2)
LINK (39)
UML (9)
Programming (154)
Cobol (0)
ASP (0)
CSS (5)
C_C++ (2)
IBatis (2)
JSP (3)
JAVA (76)
JavaScript (44)
PHP (2)
Utility (76)
Protable (3)
MobileProgram (4)
SKT (0)
KTF (0)
LGT (0)
자료들 (4)
DB (82)
mongoDB (0)
MySQL (8)
Oracle (61)
MSSQL (4)
Graphic (8)
Flash (3)
PhotoShop (3)
SourceFactory (4)
Collection (73)
작가의기막힌상상력 (14)
미소를찾아보는공간 (44)
내심장은작동중일까 (6)
멀더와스컬리의노트 (3)
이건어디에사용할까 (6)
Edward (275)
나만 알기엔 아까워 (100)
기억하기 위한 기록 (123)
시선이 머무는 공간 (50)
숨기고 싶은 이야기 (2)

카운터

Total
Today
Yesterday
방명록 : 관리자 : 글쓰기
Edward. K's Blog is powered by daumkakao
Skin info material T Mark3 by 뭐하라
favicon

IT정리노트

메멘토적 기억능력을 소유한 개발자 노트.

  • 태그
  • 링크 추가
  • 방명록

관리자 메뉴

  • 관리자 모드
  • 글쓰기
  • 분류 전체보기 (792)
    • 행운이와함께 (1)
    • EkNote Project (18)
    • ARIS (0)
    • Android (2)
    • LINK (39)
    • UML (9)
    • Programming (154)
      • Cobol (0)
      • ASP (0)
      • CSS (5)
      • C_C++ (2)
      • IBatis (2)
      • JSP (3)
      • JAVA (76)
      • JavaScript (44)
      • PHP (2)
    • Utility (76)
      • Protable (3)
    • MobileProgram (4)
      • SKT (0)
      • KTF (0)
      • LGT (0)
      • 자료들 (4)
    • DB (82)
      • mongoDB (0)
      • MySQL (8)
      • Oracle (61)
      • MSSQL (4)
    • Graphic (8)
      • Flash (3)
      • PhotoShop (3)
    • SourceFactory (4)
    • Collection (73)
      • 작가의기막힌상상력 (14)
      • 미소를찾아보는공간 (44)
      • 내심장은작동중일까 (6)
      • 멀더와스컬리의노트 (3)
      • 이건어디에사용할까 (6)
    • Edward (275)
      • 나만 알기엔 아까워 (100)
      • 기억하기 위한 기록 (123)
      • 시선이 머무는 공간 (50)
      • 숨기고 싶은 이야기 (2)

카테고리

PC화면 보기 티스토리 Daum

티스토리툴바