@echo off
SETLOCAL
Set USERNAME=userid
Set PASSWORD=ps
Set SID=artd
Set DATA_FILE=outdat
@rem Check all value exist before we start the process
if "%USERNAME%" == "" goto formaterror
if "%PASSWORD%" == "" goto formaterror
if "%SID%" == "" goto formaterror
if "%DATA_FILE%" == "" goto formaterror
goto main
:formaterror
echo Usage: import [username] [password] [sid] [data_filename]
@echo off
goto finish
:main
SQLPLUS %USERNAME%/%PASSWORD%@%SID%
cd ..
imp %USERNAME%/%PASSWORD%@%SID% file=%DATA_FILE%.dmp log=%USERNAME%imp.log fromuser=%USERNAME% touser=%USERNAME% ignore=y
:finish
Thursday, November 27, 2008
DB - Export Oracle DB Script
@echo off
SETLOCAL
Set USERNAME=userid
Set PASSWORD=ps
Set SID=ARTD
Set OUTPUT_FILE=outdat
@rem Check all value exist before we start the process
if "%USERNAME%" == "" goto formaterror
if "%PASSWORD%" == "" goto formaterror
if "%SID%" == "" goto formaterror
if "%OUTPUT_FILE%" == "" goto formaterror
goto process
:formaterror
echo Usage: export [username] [password] [sid] [output_filename]
@echo off
goto finish
:process
exp %USERNAME%/%PASSWORD%@%SID% file=%OUTPUT_FILE%.dmp log=%USERNAME%exp.log owner=%USERNAME%
:finish
ENDLOCAL
SETLOCAL
Set USERNAME=userid
Set PASSWORD=ps
Set SID=ARTD
Set OUTPUT_FILE=outdat
@rem Check all value exist before we start the process
if "%USERNAME%" == "" goto formaterror
if "%PASSWORD%" == "" goto formaterror
if "%SID%" == "" goto formaterror
if "%OUTPUT_FILE%" == "" goto formaterror
goto process
:formaterror
echo Usage: export [username] [password] [sid] [output_filename]
@echo off
goto finish
:process
exp %USERNAME%/%PASSWORD%@%SID% file=%OUTPUT_FILE%.dmp log=%USERNAME%exp.log owner=%USERNAME%
:finish
ENDLOCAL
Struts - Set : If
<s:set name="isCust" value="%{'true'}"/>
<s:if test="%{#isCust=='true'}">
<td> class="colHeader"> </td>
<td> </td>
</s:if>
<s:if test="%{#isCust=='true'}">
<td> class="colHeader"> </td>
<td> </td>
</s:if>
Struts - Combine 2 value in Textfield
salutation = Mr
firstname = Kiat Hooi
Display value = Mr Kiat Hooi
Tuesday, August 19, 2008
Ibatis - Select
Dao function to call ibatis xml
public List getActionListString type)
{ Map m = new HashMap();
m.put("type",datatype);
return getSqlMapClientTemplate().queryForList("xmlSQL.getActionList", m);
}
xmlSQL file sql statement
<select id="getActionList" parameterClass="java.util.Map" resultClass="com.model.ListingObj">
SELECT ACTION_CODE as Code,ACTION_NAME as Description
FROM RECORD_ACTION C
WHERE TYPE = #datatype:VARCHAR#
<isNotNull prepend="AND" property="state">
STATE_CODE = #state:VARCHAR# </isNotNull> </select>
ListingObj class
public class ListingObj {
private String code;
private String description;
public String getCode() { return code; }
public void setCode(String code) { this.code = code; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }}
public List getActionListString type)
{ Map m = new HashMap();
m.put("type",datatype);
return getSqlMapClientTemplate().queryForList("xmlSQL.getActionList", m);
}
xmlSQL file sql statement
<select id="getActionList" parameterClass="java.util.Map" resultClass="com.model.ListingObj">
SELECT ACTION_CODE as Code,ACTION_NAME as Description
FROM RECORD_ACTION C
WHERE TYPE = #datatype:VARCHAR#
<isNotNull prepend="AND" property="state">
STATE_CODE = #state:VARCHAR# </isNotNull> </select>
ListingObj class
public class ListingObj {
private String code;
private String description;
public String getCode() { return code; }
public void setCode(String code) { this.code = code; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }}
Ibatis - Transaction manual commit
public String updateCustMobile(String mobileNo, String custId)
{ Map m = new HashMap();
m.put("custId",custId);
m.put("mobileNo",mobileNo);
SqlMapClient sqlMap;
try { sqlMap = getSqlMapClientTemplate().getSqlMapClient();
sqlMap.startTransaction();
// Set commit to false for rollback if any exception
sqlMap.getCurrentConnection().setAutoCommit(false);
sqlMap.update("xmlSQL.updateCust", m);
.....
.....
sqlMap.endTransaction();
} catch(Exception e)
{
e.printStackTrace();
} finally {
if(!(sqlMap == null)) sqlMap.endTransaction();
}
return status;
}
{ Map m = new HashMap();
m.put("custId",custId);
m.put("mobileNo",mobileNo);
SqlMapClient sqlMap;
try { sqlMap = getSqlMapClientTemplate().getSqlMapClient();
sqlMap.startTransaction();
// Set commit to false for rollback if any exception
sqlMap.getCurrentConnection().setAutoCommit(false);
sqlMap.update("xmlSQL.updateCust", m);
.....
.....
sqlMap.endTransaction();
} catch(Exception e)
{
e.printStackTrace();
} finally {
if(!(sqlMap == null)) sqlMap.endTransaction();
}
return status;
}
Struts - Table
<display:table name="sessionScope.campList" id="tableReport" pagesize="${page}" requestURI="campSearch.do" class="headertable" style="width:100%;" sort="list">
<display:column paramId="campId" paramProperty="campId" titleKey="campId" headerClass="rowHeader" class="rowContent" sortable="true">
<span id="tagtip<s:property value="%{#rowCounter}"/>" style="display: none;">
<table width="300" class="tooltips"><tr><th colspan="2">Tag List
</th></tr>
<c:forEach var="tag" items="${tableReport.tags}" >
<tr><td>
<c:out value="${tag.tagId}"></c:out></td><td>
<c:out value="${tag.location}"></c:out></td></tr>
</c:forEach></table></span>
<s:div onmouseover="TagToTip('%{'tagtip' + #rowCounter}')" onmouseout="UnTip()">
<c:out value="${tableReport.campId}"></c:out>
</s:div></display:column>
<display:column property="startDate" format="{0,date,dd/MM/yyyy}" titleKey="startDate" headerClass="rowHeader" class="rowContent" sortable="true"/>
<display:column property="startTime" format="{0,date,HH:mm:ss}" titleKey="startTime" headerClass="rowHeader" class="rowContent" sortable="true"/>
<s:set name="rowCounter" value="%{#rowCounter + 1}"/>
</display:table>
***********************
tableReport.tags is a list in sessionScope.campList
tag.tagId is a variable in tags list object
<display:column paramId="campId" paramProperty="campId" titleKey="campId" headerClass="rowHeader" class="rowContent" sortable="true">
<span id="tagtip<s:property value="%{#rowCounter}"/>" style="display: none;">
<table width="300" class="tooltips"><tr><th colspan="2">Tag List
</th></tr>
<c:forEach var="tag" items="${tableReport.tags}" >
<tr><td>
<c:out value="${tag.tagId}"></c:out></td><td>
<c:out value="${tag.location}"></c:out></td></tr>
</c:forEach></table></span>
<s:div onmouseover="TagToTip('%{'tagtip' + #rowCounter}')" onmouseout="UnTip()">
<c:out value="${tableReport.campId}"></c:out>
</s:div></display:column>
<display:column property="startDate" format="{0,date,dd/MM/yyyy}" titleKey="startDate" headerClass="rowHeader" class="rowContent" sortable="true"/>
<display:column property="startTime" format="{0,date,HH:mm:ss}" titleKey="startTime" headerClass="rowHeader" class="rowContent" sortable="true"/>
<s:set name="rowCounter" value="%{#rowCounter + 1}"/>
</display:table>
***********************
tableReport.tags is a list in sessionScope.campList
tag.tagId is a variable in tags list object
Struts - Get session value in jsp
<s:hidden key="refId" id="refId" value="${SESSIONVALUE}"/>
*************
id is important if you want to get the refId value in action class upon form submittion
*************
id is important if you want to get the refId value in action class upon form submittion
Struts - If
<s:if test="${isExist && status != 'FAILED'}">
<fmt:message key="psNote"/></s:if>
****************
fmt:message key is retreive from message.properties file
Struts - Pass value to javascript function
<script type="text/javascript">
displayData("<c:out value='${status}'/>", "<c:out value='${proId}'/>");
</script>
displayData("<c:out value='${status}'/>", "<c:out value='${proId}'/>");
</script>
Struts - Dropdown List
<display:table name="data.cardList" id="dataDetail" pagesize="${page}" requestURI=" style="width:100%">
<display:column headerClass="rowHeader">
<input type="radio" name="ipSelection" />
</display:column>
<display:column titleKey="de.action" headerClass="rowHeader" style="text-align:center">
<select name="action" onchange="setAction('${dataDetail.cardRef}','${dataDetail.cp}')" >
<option> Please select</option>
<c:forEach var="act" items="${actionList}">
<s:if test="${dataDetail.status==act.state}">
<option value="${act.code}"> ${act.description}</option>
</s:if> </c:forEach> </select>
</display:column>
</display:table>
**************************
- dataDetail.cardRef & dataDetail.cp should be the variables in cardList object
- act.code & act.description should be the variables in actionList object
- actionList is store in session
<display:column headerClass="rowHeader">
<input type="radio" name="ipSelection" />
</display:column>
<display:column titleKey="de.action" headerClass="rowHeader" style="text-align:center">
<select name="action" onchange="setAction('${dataDetail.cardRef}','${dataDetail.cp}')" >
<option> Please select</option>
<c:forEach var="act" items="${actionList}">
<s:if test="${dataDetail.status==act.state}">
<option value="${act.code}"> ${act.description}</option>
</s:if> </c:forEach> </select>
</display:column>
</display:table>
**************************
- dataDetail.cardRef & dataDetail.cp should be the variables in cardList object
- act.code & act.description should be the variables in actionList object
- actionList is store in session
Js - Radio Button (Reset)
if (radioLength>0)
{ for(var i = 0; i <radioLength; i++)
{ if(document.forms[0].cardSelection[i].checked==true)
{ alert("checked is true");
document.forms[0].cardSelection[i].checked = false;
} }
}else
{ document.forms[0].cardSelection.checked = false; }
Js - Radio Button (Check)
var radioLength = document.forms[0].cardSelection.length;
var checked = false;
if (radioLength>0)
{
//if radio button more then 1
for(var i = 0; i < radioLength; i++)
{ if(document.forms[0].cardSelection[i].checked)
{ checked = true; break; }
}
}else
{ //if only have 1 radio button
if (document.forms[0].cardSelection.checked==true)
{ checked = true; }
}
var checked = false;
if (radioLength>0)
{
//if radio button more then 1
for(var i = 0; i < radioLength; i++)
{ if(document.forms[0].cardSelection[i].checked)
{ checked = true; break; }
}
}else
{ //if only have 1 radio button
if (document.forms[0].cardSelection.checked==true)
{ checked = true; }
}
Subscribe to:
Posts (Atom)