Akdora’s Blog

Programming, Oracle, Life, Fun

Turkish Character Problem (Türkçe Karakter Problemi) February 23, 2009

When we write jsp pages, we add the following code to the page to encode the characters in desired charset.

<%@ page contentType="text/html;charset=iso-8859-9"%>

Although to add this code, we sometimes face up the character problem.  Expecially, if we change the mimeType of the page. I mean, export the page as excel.

(If you want to export any data in a excel file from jsp, change the mimetpye of the jsp and write your data in table tags)

if (pageType != null && pageType.equalsIgnoreCase("excel")) {
   String mimeType = "application/vnd.ms-excel;charset=ISO-8859-9";
   response.setContentType(mimeType);
   String filename = "MyExcelFile";
   response.setHeader("Content-Disposition","attachment;filename=" + filename + ".xls");
   //System.out.println(response.getCharacterEncoding());
}

When you get this problem, try to add the following code in the HEAD tag of the page. It will fixed up.

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">

 I searched this simple code for a long time:), because it think that the first code enough to encode the charset. But it is not.

Advertisements
 

How to use Ext.Ajax.request with Response Text? February 6, 2009

If we want to query something via ajax and show a response on the screen, we can use Ext.Ajax.request class of ExtJS. It provides a simple way to make Ajax requests with maximum flexibility. We will set the action url and get a response from action. Then, we will show the response on the screen. Let’s do it.

Firstly, I am writing the JSP page:

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<link rel="stylesheet" type="text/css" href="/xx/resources/extjs/css/ext-all.css">
<script type="text/javascript" src="/xx/resources/extjs/ext-base.js"></script>
<script type="text/javascript" src="/xx/resources/extjs/ext-all-debug.js"></script>
<script type="text/javascript">
Ext.onReady(function() {

 function fn_AKExt( message, title ){
   Ext.Msg.show({
      title: title,
      msg: message ,
      buttons: Ext.MessageBox.OK,
      icon: Ext.MessageBox.INFO
     });
 } (more...)
 

Live Combo Search with ExtJS February 4, 2009

Filed under: Ajax,ExtJS,Java,PL/SQL — Akdora @ 10:39 am
Tags: , , , , , , , , , , , , , , ,

Live Combo Search with ExtJS

 

If you trying to list thousands of data in a combobox, then you have a problem. I faced this problem a while ago. I was developing the presentation layer with ExtJS. ExtJS has a live search solution for this situation. Check the web page: http://extjs.com/deploy/dev/examples/form/forum-search.html

I will explain the whole story from beginning to end about this online dynamic checkbox control. I will use Oracle XE 10g, Java-Struts with JPS pages and ExtJS. We will pass the data with JSON. You may make some changes in the code. It all depends on you. My metod is just a suggestion.

 

Lets create a procedure that returns a cursor. It also takes an input parameter that’s our search string. We have 60000 rows in  table company. It is also recommended to create an Function-Based Index (FBI) on “lower(t. company_name)”.

s

(more…)