Showing posts with label stackoverflow. Show all posts
Showing posts with label stackoverflow. Show all posts

Tuesday, January 08, 2013

Internet Explorer 9 (IE9) Table White Space Issues

I was tasked with fixing a problem in our product where one of our data tables (HTML) was rendering on IE9 with spaces randomly scattered throughout the table this resulted in the data being in the wrong columns, or headers appearing in the wrong place. I originally thought I might there might be "holes", or null values in my data which was resulting in the error. I was wrong.

It is actually a bug in IE9.

The issue shows up, most often, when using AJAX when there is partial page rendering. It seems according to forum remarks to be focused on white space between table tag elements like line breaks, spaces, or carriage returns. So if you use HTML tidy, you will screw up your output. Nice one Microsoft!

Fortunately, there are "fixes" out there to help you get along. Here is the fix which I slightly modified from an answer on stackoverflow. A shout out goes to Blago for his recursive function listed below.

You can implement it this way.
Here are some references on the issue if you are interested.

Saturday, January 05, 2013

Using GlassFish 3.1.1 Embedded with JUnit 4.x and HtmlUnit 2.x

Introduction

I was looking for an example of how to use GlassFish Embedded Maven plugin to integrate with HtmlUnit(JUnit) for doing testing. I was surprised that I really didn't find anything that seemed very complete. There were a number of examples that showed how to use the Embedded EJB Container in tests, but nothing that really showed how to use the Maven plugin. While searching I came across a question on stackoverflow asking how about Unit testing a Java Servlet. I decided to kill two birds with one stone; (1) write up a good example for Glassfish, and (2) help someone else with a complete solution

The testing here is implemented as part of the integration-test lifecycle of Maven. This does not replace standard JUnit testing of your code, but rather provides testing of your web application as you would expect in deployment. Consider this a valuable supplement to your testing strategy.

The complete project is located here: image-servlet.

Requirements

  1. First make sure that you configure the Maven plugin. Complete details can be found in Oracle GlassFish Server Embedded Server Guide
  2. Next, configure the surefire plugin to skip its normal test cycle.
  3. Add a dependencies for JUnit and HtmlUnit to the pom.xml
  4. Write your tests. This is one example.
  5. Execute mvn:install.

Conclusion

You should see the GlassFish server start, deploy your application, execute the unit tests, undeploy the application, and shutdown gracefully.

There is a complete project on Bitbucket which demonstrates the entire process from start to finish doing a complete set of integration tests using HtmlUnit.

The project was developed using NetBeans 7.2.1, and GlassFish 3.1.2.

The complete project is located here: image-servlet.

Wednesday, January 02, 2013

<ui:repeat/>, Templates, and @ConversationScope

Fishy Dates
I was going through stackoverflow when I came across: ui:repeat does not work in JSF 2.0? I know that their had been some issues which I detailed in JSF Tip of the Day: <ui:repeat /> Usage Example so I took a look. I resolved the basic issue and printed out a pretty page with some data. The solution is  on  stackoverflow so I won't repeat myself too much.

The modified version which includes a conversation portion and some other bells and whistles is available for download.

The code for the solution is available stackoverflow-uirepeat-example

The project was developed using NetBeans 7.2.1 on GlassFish 3.1.2 on JSF 2.1 (Mojarra) and Weld 1.0.




Popular Posts