Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

2 Problems: EJB & Encoding Farsi

  Asked By: Dale    Date: Oct 17    Category: Java    Views: 1786
  

I encountered 2 problems while developing my ejb webapp

1-seems like I was not able to change the content of my primary key field with the CMP regular set methods. the EJB container responded with the following error:
nested exception is:
javax.ejb.EJBException: A CMP field that is a member of the primary key can only be set in ejbCreate [EJB 2.0 Spec. 10.3.5].;

pls. tell me what to do if the PK content needs to be changed.

2-I was not able to update the MySQL table with the struts regular textfield with farsi characters. ofcourse I can get farsi characters from mysql to my web page into the textfield but the reverse action is not possible.
I think there is no deficiency on the database side, cause my table's charset is: utf8 and its collation is set to: utf8_persian_ci


good to say: I use EJB 2.0, MySQL 5.0, JBoss 4.0
Looking for your quick replies.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Maliha Malik     Answered On: Oct 17

Answer of encoding  problem:

I think your problem is not database  connection. You must override reset() and validate() abstract methods  of your form bean as following:



public void reset(ActionMapping actionMapping, HttpServletRequest request) {

try {

request.setCharacterEncoding("UTF-8");

}

catch (UnsupportedEncodingException e) {

e.printStackTrace();

}

super.reset(actionMapping, request);

}



public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {

try {

request.setCharacterEncoding("UTF-8");

} catch (UnsupportedEncodingException e) {

e.printStackTrace(); .

}

return super.validate(actionMapping, request); //

}

 
Answer #2    Answered By: Edward Jones     Answered On: Oct 17

Thanks for your code, but actually it didn't help alot cause now instead of previous unreadable text i have only the questionmark characters  like ??? ???? and that's while i also have the meta tag of:
<meta.......content=......charset=utf-8..> in my page
i think there's still a part missing

 
Didn't find what you were looking for? Find more on 2 Problems: EJB & Encoding Farsi Or get search suggestion and latest updates.




Tagged: