Hibernate và NHibernate, mini guide
Khi cần thông tin tham khảo về Hibernate, cách tốt nhất là đến web site của Hibernate và các site khác hoặc vào đây để tìm cho nhanh:
http://tssblog.techtarget.com/index.php/interoperability/mini-guide-hibernate-and-nhibernate/
1 comment Tháng Bảy 23, 2007
What Spring Web Flow Offers JSF Developers
Khi đọc các bài chỉ trích JSF, mọi người thấy hầu hết tập trung vào:
- Component nhưng không thực là component
- Một loài khủng long (nặng nề, chỉ có trong quá khứ, đã bị diệt chủng) và so sánh với EJB2
- ….
Nỗ lực để sửa sai và phát triển JSF của cộng đồng ủng hộ JSF rất đáng nể,từ Facelets, Seam … và bây giờ đến Springframeworks với đóng góp của Spring web flows. Chi tiết của blog do tác giả của Spring web flows, Keith Donald , rất tuyệt vời và là câu trả lời thuyết phục cho rất nhiều issue của JSF.
Add comment Tháng Bảy 9, 2007
Wicket user try JSF
Một bài viết so sánh giữa Wicket và JSF, dưới cái nhìn của một Wicket user, rất đáng theo dõi. Tuy tôi không thích Wicket vì phải code Java quá nhiều, nhưng các ý kiến của tác giả quả là rất hợp lý và đáng xem xét học hỏi.
Chi tiết có thể xem ở http://ptrthomas.wordpress.com/2007/05/14/a-wicket-user-tries-jsf/
Add comment Tháng Bảy 9, 2007
Java Server Face, new direction for web development !
Java Server Face resources:
- Using with Spring and Hibernate: Đây là một bài của Rick Hightower, rất đáng để tham khảo, đặc biệt cho những ai đang sử dụng Spring framework. Tham khảo tại đây
- JSF Resources: www.jsfcentral.com
- Cho người mới bắt đầu, cần những giải pháp? xem ở đây http://jsftutorials.net/ , một trang rất đáng giá. hoặc ở đây http://jsffaq.com/.
- Oracle support JSF với những custom componets: http://otn.oracle.com/jsf
- Không thể bỏ qua Apache Myfaces.
2 comments Tháng Mười Hai 7, 2005
Export database sang excel, dung cong nghe web
Export database sang excel, dung cong nghe web
http://jroller.com/page/coreteam/?anchor=export_data_from_mysql_to
Day la cach khong dung DisplayTag, chi nen dung khi can mot format dac biet cua file excel
Add comment Tháng Chín 24, 2005
JasperReport: Fill, Create PDF,-attach to email, send
JasperPrint jasperPrint = JasperFillManager.fillReport(pathToJapserReportFilename, parameters, jrBeanArrayDataSource);
byte[] pdfBytes = JasperExportManager.exportReportToPdf(jasperPrint);
mailer.sendMail(MAIL_FROM, to_email_address, subject, MAIL_BODY, pdfBytes, filename + “.pdf”, “application/pdf”);
The actual emailing part is a little more complex. You’ll need a javax.activation.DataSource implementation that handles byte[]’s.
Here’s one I wrote, or you can use org.apache.commons.mail.ByteArrayDataSource.
public static DataSource getDataSource(final byte[] bytes, final String theContentType) {
return new DataSource() {
public InputStream getInputStream()
{
return new ByteArrayInputStream(bytes);
}
public OutputStream getOutputStream()
{
throw new UnsupportedOperationException();
}
public String getContentType() {
return theContentType;
}
public String getName() {
throw new UnsupportedOperationException();
}
};
}
And then here’s the code from my MailerBean (this is running inside JBoss).
Once you have the datasource working, this is all pretty standard Java mailing stuff.
public void sendMail(String from,String to,String subject,String bodyText,
byte[] theAttachmentBytes, String theFilename, String theContentType)
{
javax.mail.Session session = null;
try {
session = (Session)PortableRemoteObject.narrow(new InitialContext().lookup(“java:Mail”), Session.class);
} catch (javax.naming.NamingException e) {
e.printStackTrace();
}
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
InternetAddress[] toAddress = {new InternetAddress(to)};
message.setRecipients(Message.RecipientType.TO, toAddress);
message.setSubject(subject);
message.setSentDate(new Date());
// create and fill the first message part
MimeBodyPart body = new MimeBodyPart();
body.setText(bodyText);
body.setDisposition(Part.INLINE);
body.setHeader(“Content-Type”, “text/plain”);
// turn the File into a Part
MimeBodyPart part = new MimeBodyPart();
part.setFileName(theFilename);
part.setDisposition(Part.ATTACHMENT);
DataSource dataSource = getDataSource(theAttachmentBytes, theContentType);
part.setDataHandler(new DataHandler(dataSource));
// set the header for the content type, using the type
// determined by the file name to mime type mapper that
// is inherent in the FileDataSource.
//part.setHeader(“Content-Type”, dataSource.getContentType());
part.setHeader(“Content-Type”, dataSource.getContentType());
// set the transfer encoding so that binary data will
// come through cleanly. in cases where the content
// type is a “text” type you may not need to do base64
// encoding, but it’s simple and safe to always encode
// attachments.
part.setHeader(“Content-Transfer-Encoding”, “base64″);
Multipart multipart = new MimeMultipart();
message.setContent(multipart);
message.setHeader(“Content-Type”, multipart.getContentType());
Multipart mp = new MimeMultipart();
mp.addBodyPart(body);
mp.addBodyPart(part);
// add the Multipart to the message
message.setContent(mp);
Transport.send(message);
} catch (javax.mail.MessagingException e) {
Debug.error(“MailerBean.sendHtmlMail”, e);
}
Add comment Tháng tám 16, 2005
JasperReports voi Hibernate, again
Day la mot trang rat hay noi ve cach dung JasperReports voi Hibernate
http://www.jroller.com/page/wakaleo/?anchor=using_hibernate_queries_with_jasperreports
Add comment Tháng tám 12, 2005
Tutorial for WebApps using JasperReports on Tomcat
1 comment Tháng tám 1, 2005
Fonts for JasperReport
Set JVM với tham số -Djava.awt.fonts tới thư mục chứa font.
Add comment Tháng tám 1, 2005
JasperReport on Unix/Linux environments with X-Window
Một trong những vấn đề developer thường gặp trong môi trường *nix là conflict của jasperreports với X-Window. Để tránh vấn đề này, các giải pháp có thể là:
- Chạy JVM với tham số -Djava.awt.headless=true
- Trong TomCat, dùng tham số này bằng cách thay đổi tham số trong catarina.sh. Cụ thể như sau: Tomcat
Đặt dòng lệnh này trong startup script:
CATALINA_OPTS=”$CATALINA_OPTS -Djava.awt.headless=true” hay có thể dùng cách khác bằng cách đặt trong ./bin/catalina.sh
# ----- Execute The Requested Command ----------------------------------------- echo "Using CATALINA_BASE: $CATALINA_BASE"echo "Using CATALINA_HOME: $CATALINA_HOME"echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"echo "Using JAVA_HOME: $JAVA_HOME" if [ "$1" = "jpda" ] ; then if [ -z "$JPDA_TRANSPORT" ]; then JPDA_TRANSPORT="dt_socket" fi if [ -z "$JPDA_ADDRESS" ]; then JPDA_ADDRESS="8000" fi if [ -z "$JPDA_OPTS" ]; then JPDA_OPTS="-Xdebug -Xrunjdwp:transport=$JPDA_TRANSPORT,address=$JPDA_ADDRESS,server=y,suspend=n" fi CATALINA_OPTS="$CATALINA_OPTS $JPDA_OPTS" shiftfiCATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=true"
- Trong chương trình java, có thể đặt lệnh set trong đoạn Init của web/app với câu lệnh sau: system.setProperty(“java.awt.headless”, “true”)
- Trong môi trường Ecclipse, dùng
eclipse -vmargs -Djava.awt.headless=true
Hy vọng các giải pháp này sẽ giúp mình giải quyết ổn thoả mọi chuyện
Add comment Tháng tám 1, 2005