2009/12/01 15:32 MiPlatform
크리에이티브 커먼즈 라이선스
Creative Commons License
휴... 오랜만에 miplatform을 하게 되었습니다. ㅜㅡ

화면에 있는 내용들을 Excel 파일로 Export하는 부분에서 문제가 발생하였습니다. ㅠㅡ
한 1달 전쯤에 이 사실을 알게 되었는데, 00화재 프로젝트 하느라 시간이 없어서 모른체 하고 있었습니다. 크크
그런데 이게 자꾸 신경쓰이더라고요 ㅎ 그래서 시간 내서 00생명으로 난입했습니다.

이거 오랜만에 miplatform하려고 하니까 기억이 안나더라고요 ㅠㅡ
또 제가 노트북을 자주 밀어버리는 바람에 다시 설치하고 설정 잡느라 힘들었습니다. ㅠㅜ

암튼, 일단 문제가 발생된 부분의 로그를 살펴보니까 아래와 같은 에러가 납니다.
왜 Script가 있는데 이런 에러가 발생하는지...
한참을 이것 저것 해다가 결국에는.... 찾았습니다.

SCMLE (2484): -2085605072:Script Method을 찾는데 실패 하였습니다.ds_title.ClearData().
SCMLE (2484): -2085605072:Script Method을 찾는데 실패 하였습니다.ds_title.AddRow().
SCMLE (2484): -2085605072:Script Method을 찾는데 실패 하였습니다.ds_title.SetColumn(0, "TITLE", titleNm).
SCMLE (2484): -2085605072:Script Method을 찾는데 실패 하였습니다.ds_search_1.ClearData().
SCMLE (2484): -2085605072:Script Method을 찾는데 실패 하였습니다.ds_title.ClearData().
SCMLE (2484): -2085605072:Script Method을 찾는데 실패 하였습니다.ds_title.AddRow().
SCMLE (2484): -2085605072:Script Method을 찾는데 실패 하였습니다.ds_title.SetColumn(0, "TITLE", titleNm).
SCMLE (2484): -2085605072:Script Method을 찾는데 실패 하였습니다.ds_search_1.ClearData().

문제의 원인은 include 시킨 javascript 들이 문제였더군요...

Method는 있는데 이런 메시지가 나온다면 include 했던 파일들을 비교해보시면 되실 것 같습니다. :") 참고로, ds_title이라는 것은 문제의 원인이 되었던 메소드에서 사용했던 변수들입니다.

여러 사람이 개발을 같이 하다보니까... 이런 문제가...
동일한 메소드 이름을 다른 2개의 javascript 파일에서 사용했는데 이 2개의 파일을 include하는 바람에 충돌이 났던거 같습니다... ㅡ_-;;




posted by 조금까칠한남자
2009/03/10 14:03 CodeIN/Web
크리에이티브 커먼즈 라이선스
Creative Commons License
    //holidays
   var holidays = row.insertCell(1);
   var holiEl = document.createElement('input');
   holiEl.type = "text";
   holiEl.name = "rdate";
   holiEl.id = "rdate";
   holiEl.size="12";
   holiEl.contentEditable='false';
  //holiEl.contenteditable='false';   
    //위에 녹색 글씨처럼 contenteditable을 사용하면 안되고..
   // 빨간색 글씨 처럼 contentEditable 해야 된다..

위 소스는 table에서 insertRow 할때 cell을 row에 추가하는 소스이다.
그런데... 위에 설명한 것 처럼 작동이 된다... -0-;;
이런.. 원래 이런거니? ㅎ
그런데;;;
아래 것은 왜 되는거니?? 아흑 ㅠㅜ

<input type="text" id="textKey" name="textKey" size="30%" value=<%= toKorean[grouping/4][grouping%4]  %> contenteditable="false">

'CodeIN > Web' 카테고리의 다른 글

X internet 이란  (0) 2009/03/26
[java/jsp]한글 깨짐  (0) 2009/03/19
[javascript] contentEditable  (0) 2009/03/10
[javascript]submit()  (0) 2009/03/10
[jsp]forward  (0) 2009/03/08
[javascript] confirm 사용법  (2) 2009/03/01
posted by 조금까칠한남자
2009/03/10 13:22 CodeIN/Web
크리에이티브 커먼즈 라이선스
Creative Commons License

처음 javascript를 공부하면서 왜 submit()를 따로 사용할까 궁금해 했었다..
이런.. 왜이리 복잡해... ㅎ
이제야 왜 사용하는지 알게 되었다 ㅎㅎ


function fileSaved(){
    var lastRow = sTable.rows.length;
    var rdateText = document.getElementsByTagName("tr")[lastRow-1].cells[1].firstChild;
    var whichDayText = document.getElementsByTagName("tr")[lastRow-1].cells[2].firstChild;   
    if( rdateText.value == "" || whichDayText.value == "" ){
        alert("저장할 값을 입력하지 않으셨습니다.");
        return;
    }
    alert("파일이 저장되었습니다");   
}
<form id="sForm" name="sForm" method="post" action="saveHolidays.jsp">
    <input type="submit" value="Save" onclick="fileSaved();">
</form>

위와 같은 경우는 rdateText.value와 whichDayText.value가 값이 아무것도 없더라도 submit이 되어버린다.

function fileSaved(){
    var lastRow = sTable.rows.length;
    var rdateText = document.getElementsByTagName("tr")[lastRow-1].cells[1].firstChild;
    var whichDayText = document.getElementsByTagName("tr")[lastRow-1].cells[2].firstChild;   
    if( rdateText.value == "" || whichDayText.value == "" ){
        alert("저장할 값을 입력하지 않으셨습니다.");
        return;
    }
    alert("파일이 저장되었습니다");
    document.sForm.submit();
}
<form id="sForm" name="sForm" method="post" action="saveHolidays.jsp">
    <input type="button" value="Save" onclick="fileSaved();">          
</form>

위와 같은 경우는 rdateText.value나 whichDayText.value가 아무값도 없을 때는 return이 되어버리므로 submit이 되지 않는다.

다 아는 사실이지만 나는 몰랐다 ㅎ
왜 submit()을 사용하는지를 ㅎㅎ
미안~





'CodeIN > Web' 카테고리의 다른 글

[java/jsp]한글 깨짐  (0) 2009/03/19
[javascript] contentEditable  (0) 2009/03/10
[javascript]submit()  (0) 2009/03/10
[jsp]forward  (0) 2009/03/08
[javascript] confirm 사용법  (2) 2009/03/01
JavaScript String Replace All  (3) 2009/02/20
posted by 조금까칠한남자
2009/03/01 23:56 CodeIN/Web
크리에이티브 커먼즈 라이선스
Creative Commons License



if(confirm("정말 삭제 하시겠습니까?")){        
      <!-- 이 부분에 "확인" 클릭시 수행해야 하는 기능을 넣는다. -->
}   

"확인"을 누르면 return 값이 true가 나오므로 위 소스가 실행된다.







'CodeIN > Web' 카테고리의 다른 글

[javascript]submit()  (0) 2009/03/10
[jsp]forward  (0) 2009/03/08
[javascript] confirm 사용법  (2) 2009/03/01
JavaScript String Replace All  (3) 2009/02/20
[javascript] dynamic 테이블 생성시 event 추가 하는 방법  (0) 2009/02/18
[javascript] checkbox 활성화/비활성화  (0) 2009/02/16
posted by 조금까칠한남자
2009/02/20 14:14 CodeIN/Web
크리에이티브 커먼즈 라이선스
Creative Commons License
The JavaScript function for String Replace replaces the first occurrence in the string. The function is similar to the php function str_replace and takes two simple parameters. The first parameter is the pattern to find and the second parameter is the string to replace the pattern with when found. The javascript function does not Replace All...
str = str.replace(”find”,”replace”)

To ReplaceAll you have to do it a little differently. To replace all occurrences in the string, use the g modifier like this:
str = str.replace(/find/g,”replace”)

posted by 조금까칠한남자
2009/02/18 10:05 CodeIN/Web
크리에이티브 커먼즈 라이선스
Creative Commons License
It doesn't, because the onclick property of your HTMLElement object is
called as a method, and you've set it to a string value:

element.onclick = 'alert("something")'; // doesn't work

Your options include (but are not limited to):


1. element.setAttribute('onclick', 'alert("hi")');

2. function elClick() { alert('hi'); } // create a function object - put
this in your global scope to avoid closure memory leaks
....
// elsewhere...
element.onclick = elClick;

3.
element.onclick = new Function('alert("hi");');

DOM Table로 dynami 테이블을 생성할 때 event를 추가하는 방법이다.
posted by 조금까칠한남자
2009/02/16 11:41 CodeIN/Web
크리에이티브 커먼즈 라이선스
Creative Commons License

흐미.. 정말 웹은.... -0-;;


function delRow(){
    var sTable = document.getElementById("sTable");
    var lastRow = sTable.rows.length;
    if(confirm("정말 삭제 하시겠습니까?")){ 
        //테이블에서 checkbox중 check된 것만 삭제     
        for( var i=1 ; i < lastRow ; i++ ){                       
            if(document.getElementsByTagName("tr")[i].cells[0].firstChild.checked){                                       
                sTable.deleteRow(i);
                break;               
            }
        }       
    }   
}
function enabledAll(){
    var sTable = document.getElementById("sTable");
    var lastRow = sTable.rows.length;   
    for( var i=1 ; i < lastRow ; i++ ){
     //tag가 tr인 것중에서 첫번째 cell(여기서는 checkbox)을 disabled=false로 만들어라.
     //이것때문에 고생 좀 했다... false라는 것 "false"라고 하면은 안되더라.그냥 "true"는 되는데 -0-;;;.
    document.getElementsByTagName("tr")[i].cells[0].firstChild.disabled=false;       
    }
}

function disabledOthers(){   
    var sTable = document.getElementById("sTable");
    var lastRow = sTable.rows.length;       
    for( var i=1 ; i < lastRow ; i++ ){ 
        //checkbox중에서 checked 된것을 제외한 나머지를 disabled=true로만든다.        
        if(!document.getElementsByTagName("tr")[i].cells[0].firstChild.checked){
            document.getElementsByTagName("tr")[i].cells[0].firstChild.disabled="true";
        }       
    }
}


<td><input type="checkbox" id="chk" name="chk" onclick="disabledOthers();" ></td>
<input type="button" value="삭제" onclick="delRow();enabledAll();">


posted by 조금까칠한남자
2009/02/13 18:37 CodeIN/Web
크리에이티브 커먼즈 라이선스
Creative Commons License
동적으로 생성한 테이블에서 checkbox에 체크된 것만 삭제 하기 위한 소스이다.
이것도 동작하지 않는 소스이며, 단지 이해를 돕기 위한 것이다.

function delRow(){      
   var sTable = document.getElementById('sTable');
   var lastRow = sTable.rows.length;
  
   if(confirm("정말 삭제 하시겠습니까?]")){       
       for( var i=1 ; i < lastRow ; i++ ){
            // 가장 중요한 부분이다.
            // getElementsByTagName("tr")을 이용해서 tag가 "tr"인 모든 것들을 배열로 받는다.
            // for문을 돌면서 각 "tr"라인의 cells[0].firstChild가 check되어 있는지 확인
            // 체크가 되어 있다면 deleteRow를 이용해서 삭제 한다.
           if( document.getElementsByTagName("tr")[i].cells[0].firstChild.checked){
               sTable.deleteRow(i);
           }
       }       
   }   
   return;
}

<table id="sTable">
<tr>     
    <th><input type="checkbox"></th>                                             
    <th>휴일</th>
    <th>내용</th>     
    <th>수정</th>                                                                             
</tr>
<%
    int i=1;                 
    for(String key : ini.get(section).keySet()){
%>
  <tr id="tableLine">
    <td><input type="text" id="rdate" name="rdate" value="<%=key %>"></td>                     
    <td><input type="text" id="whichDay" value="<%=ini.get(section).fetch(key) %>"></td>
    <td><input type="button" id="modifyButton" name="modifyButton" value="수정"></td>                                         
    </tr>
<%         
    i++;
    }
%>
</table> 
<input type="button" id="removeButton" name="removeButton" value="삭제" onclick="delRow()">



posted by 조금까칠한남자
2009/02/13 15:07 CodeIN/Web
크리에이티브 커먼즈 라이선스
Creative Commons License
Tutorials - DOM Table Add Row - 설명이 잘되어 있는 사이트 위 링크는 예제와 함께 소스를 소개해놔서 이해하기가 더 쉽다.

HTML DOM Table Object - 기타 DOM관련된 자료가 있는 링크

아래 소스는 테이블에 row를 추가 할 때 각 cell에 필요한 부분을 넣는 소스이다.
쓸데 없는 옵션들은 다 제거를 하였으며, 실행 가능한 소스는 아님을 밝힌다.
이해를 돕기 위한 소스일 뿐이다. 이것을 각자에 맞게 응용하면 된다.

대충 색깔만 맵핑 시켜도 이해가 쉬울 것 같다.
function addRow(){   
    var sTable = document.getElementById("sTable");
    //테이블의 마지막에 row를 추가하기 위한 작업
    var lastRow = sTable.rows.length;
    var iteration = lastRow;
    var row = sTable.insertRow(lastRow);
   
    //text를 추가 하는 방법
    var count = row.insertCell(0);
    var textNode = document.createTextNode(iteration);
    count.appendChild(textNode);

    //input 을 추가하는 방법
    var holidays = row.insertCell(1);
    var holiEl = document.createElement('input');
    holiEl.type = "text";
    holiEl.name = "rdate";
    holiEl.id = "rdate";
    holiEl.size="12";
    holidays .appendChild(holiEl);

    //button을 추가하는 방법
    var removeBtn = row.insertCell(4);
    var removeBtnEl = document.createElement('intput');
    removeBtnEl.type = "button";
    removeBtnEl.name = "removeButton";
    removeBtnEl.id = "removeButton";
    removeBtnEl.value = "삭제";   
    removeBtn.appendChild(removeBtnEl);   
}
</script>

<form id="sForm" method="post" action="Holidays.jsp">                   
            <table id="sTable">
              <tr>
                        <td><input type="text" id="rdate"></td>                       
                        <td><input type="text" id="whichDay"></td>
                        <td><input type="button" id="removeButton" value="삭제"></td>
                    </tr>
            </table>
            <p>           
                <input type="button" name="adding" value="추가" onclick="addRow()">
            </p>
</form>


posted by 조금까칠한남자
2009/02/12 10:44 CodeIN/Web
크리에이티브 커먼즈 라이선스
Creative Commons License
혼자 해결해보려고 했지만 아직 개념이 부족한 상태라 또 카페에 질문한 후에 답변을 받고 대략 어떻게 동작이 되는지 이해를 한 후에 정리를 해본다.


function setEachValues(index){
    var sh = document.getElementsByName("SH")[index];   
    var t = document.getElementsByName("TT")[index];
    t.value = sh.options[sh.selectedIndex].text;
}

for(int i=0 ; i < 10 ; i++ ){
   <select name="SH" onChange="setEachValues(<%=i%>);">
      <option value="1">1시</option>
      <option value="2">2시</option>
      <option value="3">3시</option>
   </select>
   <input type="text" name="TT">
}

소스를 간단히 정리를 하면은 select box와 input text를 for문을 이용해서 각 10개 생성한후
select box에서 어떤 값을 선택하면 이 값을 input text에 보여주는 것이다.

위 소스가 작동한다는 보장은 하지 않는다 나는 개념을 정리하기 위한 것이기 때문이다.

for문을 이용해서 select box와 input text가 10개씩 생성이 되었고, 10개의 select box는 "SH"라는 name을, 10개의 input text는 "TT"라는 name을 사용하고 있다.
이럴 때 getElementsByName을 이용하여 처리를 하는데
getElementsByName의 return값은 배열이라고 한다.

그렇기 때문에 document.getElementsByName("SH")라고 하면 name이 "SH" 인 것들을 배열로 return하는 것 같다.(이것은 내 생각일뿐이다 ㅎㅎ)










posted by 조금까칠한남자
prev 1 2 next