[ 
https://issues.apache.org/struts/browse/WW-3289?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Fernando Manrique updated WW-3289:
----------------------------------

      Assignee: Fernando Manrique
      Priority: Trivial  (was: Major)
    Issue Type: Temp  (was: Bug)
       Summary: Error when rendering <s:select> tag that contains UTF-8 
characters in "listValue" attribute AFTER client-side validation  (was: Bug 
when rendering <s:select> tag that contains UTF-8 characters in "listValue" 
attribute AFTER client-side validation)

I found a solution to my problem, it is NOT a struts2 bug!

I was including the JSP <s:form> with the <s:include> tag from another JSP, and 
somehow, the first time it rendered the <s:select> tag in the JSP form 
everything was fine.
But AFTER any validation errors the page wouldn't render correctly if the 
<s:select> tag had UTF-8 characters in it.

To solve this problem I make sure I included
<%@ page language="java" contentType="text/html; charset=UTF-8" 
pageEncoding="UTF-8" %>
at the top of ALL my JSPs, and I mean ALL... Even JSPs called with <s:include> 
tag.

Also I had to make sure that inside the standard HTML tag <head> in the main 
JSP, the following meta tag was included:
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
This is to force the browsers to render the page as UTF-8

Thanks for reading!

> Error when rendering <s:select> tag that contains UTF-8 characters in 
> "listValue" attribute AFTER client-side validation
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: WW-3289
>                 URL: https://issues.apache.org/struts/browse/WW-3289
>             Project: Struts 2
>          Issue Type: Temp
>    Affects Versions: 2.1.8
>         Environment: Centos 5.3
> Java 1.6
> Tomcat 6.0.20
> Struts 2.1.8
>            Reporter: Fernando Manrique
>            Assignee: Fernando Manrique
>            Priority: Trivial
>
> Hi:
> I really don't know what component is the one that is failing (I guess the 
> validation interceptor), so I'll try to explain as many details as possible.
> I have my form.jsp as follows:
> <s:form action="saveTeam" namespace="/2" method="post" 
> enctype="multipart/form-data" validate="true">
>    <s:textfield name="team.name" value="%{team.name}" 
> label="%{getText('label.name')}" size="25" required="true" maxlength="50"/>
>    <s:select name="team.stadium.idStadium" value="%{team.stadium.idStadium}" 
> label="%{getText('label.stadium')}" list="stadiums" listKey="idStadium" 
> listValue="name"/>
>    <s:file name="image" label="label.image" accept="image/jpeg"/>
>    <s:hidden name="team.idTeam" value="%{team.idTeam}"/>
>    <s:submit value="%{getText('button.label.submit')}"/>
> </s:form>
> I used the "Preparable interface approach" to repopulate controls when 
> validation fails, and it worked flawlessly, but... in this example, when the 
> name of the stadium has UTF-8 characters (for example: á, ñ, ö), the HTML 
> page doesn't finish rendering AFTER validation errors (the first time, the 
> form.jsp is displayed correctly without problems), and it stops at the 
> <select> tag before the "weird" character.
> This is the HTML code:
> <form id="saveTeam" name="saveTeam" onsubmit="return 
> validateForm_saveTeam();" action="/2/saveTeam.action" method="post" 
> enctype="multipart/form-data" 
> onreset="clearErrorMessages(this);clearErrorLabels(this);">
> <table class="wwFormTable">
>     <tbody><tr errorfor="saveTeam_team_name">
>     <td colspan="2" align="center" valign="top"><span 
> class="errorMessage">You must enter a name!</span></td>
> </tr>
> <tr>
>     <td class="tdLabel"><label for="saveTeam_team_name" 
> class="errorLabel">Name<span class="required">*</span>:</label></td>
>     <td><input name="team.name" size="25" maxlength="50" value="" 
> id="saveTeam_team_name" type="text"></td>
> </tr>
>         <tr>
>     <td class="tdLabel"><label for="saveTeam_team_stadium_idStadium" 
> class="label">Stadium:</label></td>
>     <td><select name="team.stadium.idStadium" 
> id="saveTeam_team_stadium_idStadium">
>     <option value="3" selected="selected">Deportivo Espa
>                 
>                 
>         
> The stadium name is "Deportivo España", but somehow the "ñ" isn't displayed, 
> and everything after that is ignored. 
> I also tried with other characters like á or ö, and every time the <select> 
> tag reaches the firs UTF-8 character it stops displaying the rest of the page.
> This ONLY happens AFTER validation errors. The first time the page is 
> rendered, "Deportivo España" is shown correctly, and if I submit the form 
> without any validation errors it works without problems.
> Also if there aren't any "strange" characters like "ñ", when there are 
> validation errors the select tag displays correctly AFTER validation too.
> I think this is an UTF8 problem...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to