non ascii characters urlencoded by simple get
seamfrappe Nov 20, 2009 1:08 AMGreetings!
My configuration is Seam 2.2.0.GA with IceFaces 1.8.2 on JBoss 5.1
I'm working with non ascii characters and with a ice:form
When I submit data by a partialSubmit, the dates and fields with non ascii characters behaves ok.
BUT when I use a submit button things goes wrong and I get a URLEncoded value in my form fields.
i.e.:
| If I enter -> I got
------------------------------
| Muñoz -> Mu%C3%B1oz
-------------------------------
| 12/12/1980 -> 12%2F12%2F1980
--------------------------------
I believe that this issue has relation with:
http://seamframework.org/Community/WhyEntitypagexmlParameter
and
http://seamframework.org/Community/DateFormatErrorInPagexmlParamsASeamIssue
If I use a converter with the Dates and the non ascii characters all works fine.
I'm fighting against seam page.xml or components.xml, or other configuration to find a seam-friendly solution to this issue.
Thank you.
My Form and my converters are below:
----------------------------------------
<ice:form id="pacienteSearch" styleClass="edit" partialSubmit="true">
<ice:panelGroup id="searchGroup" styleClass="formBorderHighlight">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="iceDatTblColHdr2"><ice:outputText
id="listPacienteId" value="Búsqueda simple" /></td>
</tr>
</table>
<ice:panelGroup id="listPanelGroupPacienteId" styleClass="edit">
Debes capturar todos los campos:
<hr />
<s:decorate id="sexodecId" template="layout/display.xhtml">
<ui:define name="label">#{messages.genero}</ui:define>
<ice:selectOneRadio id="logic"
value="#{pacienteList.paciente.sexo}" partialSubmit="false"
style="width: 225px;height: 12px; vertical-align:middle; display:inline"
required="true">
<f:selectItem itemLabel="#{messages.genero_femenino}" itemValue="FEMENINO" />
<f:selectItem itemLabel="#{messages.genero_masculino}" itemValue="MASCULINO" />
</ice:selectOneRadio>
</s:decorate>
<s:decorate id="apPaternodecId" template="layout/display.xhtml">
<ui:define name="label">#{messages.apPaterno}</ui:define>
<ice:inputText id="apPaterno"
value="#{pacienteList.paciente.apPaterno}" partialSubmit="false"
required="true"/>
</s:decorate>
<s:decorate id="nacimientodecId" template="layout/display.xhtml">
<ui:define name="label">#{messages.fechaNacimiento}</ui:define>
<ice:selectInputDate id="nacimiento"
value="#{pacienteList.paciente.nacimiento}" renderAsPopup="true"
partialSubmit="false" renderMonthAsDropdown="true"
renderYearAsDropdown="true" style="width: 225px; display:inline"
required="true" /><ice:message style="color:red;" id="nacimientoError" for="nacimiento"/>
</s:decorate>
</ice:panelGroup>
<s:decorate id="searchdecId" template="layout/display.xhtml">
<ice:commandButton id="search" value="#{messages.search}"
action="/PacienteList.xhtml" partialSubmit="true" />
<ice:commandButton id="reset" value="#{messages.reset}"
action="#{pacienteList.reset()}" partialSubmit="true" />
</s:decorate>
</ice:panelGroup>
</ice:form>
------------------- Date converter -------------------------
@Name("jbSeam4413Converter")
@BypassInterceptors
@Converter
public class JbSeam4413 implements javax.faces.convert.Converter {
@Logger
private Log log;
public Object getAsObject(FacesContext context, UIComponent component,
String value) throws ConverterException {
log.info("JbSeam4413.getAsObject called (" + value +")");
if(value == null || value.trim().length() == 0)
return null;
Date date = null;
try {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
date = sdf.parse(URLDecoder.decode(value,"UTF-8"));
} catch (ParseException e) {
e.printStackTrace();
FacesMessage message = new FacesMessage();
message.setDetail("javax.faces.converter.DateTimeConverter.DATE");
message.setSummary("javax.faces.converter.DateTimeConverter.DATE_detail");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(message);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
FacesMessage message = new FacesMessage();
message.setDetail("javax.faces.converter.DateTimeConverter.DATE");
message.setSummary("javax.faces.converter.DateTimeConverter.DATE_detail");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(message);
}
return date;
}
public String getAsString(FacesContext context, UIComponent component,
Object value) throws ConverterException {
log.info("JbSeam4413.getAsString called");
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
return sdf.format(value);
}
}
-------------------------- Non ascii field converter --------------------------
@Name("trimInputFields")
@BypassInterceptors
@Converter
public class TrimInputFields implements javax.faces.convert.Converter{
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if(StringUtils.isEmpty(value)){
return null;
} else {
try {
return URLDecoder.decode(value,"UTF-8");
} catch (UnsupportedEncodingException e) {
FacesMessage message = new FacesMessage();
message.setDetail("javax.faces.converter.STRING");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(message);
}
}
}
public String getAsString(FacesContext context, UIComponent component, Object value) {
if(value!=null){
try {
return URLDecoder.decode(value.toString().trim(),"UTF-8");
} catch (UnsupportedEncodingException e) {
FacesMessage message = new FacesMessage();
message.setDetail("javax.faces.converter.STRING");
message.setSummary(e.getLocalizedMessage());
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(message);
}
} else {
return null;
}
}
}
My configuration is Seam 2.2.0.GA with IceFaces 1.8.2 on JBoss 5.1
I'm working with non ascii characters and with a ice:form
When I submit data by a partialSubmit, the dates and fields with non ascii characters behaves ok.
BUT when I use a submit button things goes wrong and I get a URLEncoded value in my form fields.
i.e.:
| If I enter -> I got
------------------------------
| Muñoz -> Mu%C3%B1oz
-------------------------------
| 12/12/1980 -> 12%2F12%2F1980
--------------------------------
I believe that this issue has relation with:
http://seamframework.org/Community/WhyEntitypagexmlParameter
and
http://seamframework.org/Community/DateFormatErrorInPagexmlParamsASeamIssue
If I use a converter with the Dates and the non ascii characters all works fine.
I'm fighting against seam page.xml or components.xml, or other configuration to find a seam-friendly solution to this issue.
Thank you.
My Form and my converters are below:
----------------------------------------
<ice:form id="pacienteSearch" styleClass="edit" partialSubmit="true">
<ice:panelGroup id="searchGroup" styleClass="formBorderHighlight">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="iceDatTblColHdr2"><ice:outputText
id="listPacienteId" value="Búsqueda simple" /></td>
</tr>
</table>
<ice:panelGroup id="listPanelGroupPacienteId" styleClass="edit">
Debes capturar todos los campos:
<hr />
<s:decorate id="sexodecId" template="layout/display.xhtml">
<ui:define name="label">#{messages.genero}</ui:define>
<ice:selectOneRadio id="logic"
value="#{pacienteList.paciente.sexo}" partialSubmit="false"
style="width: 225px;height: 12px; vertical-align:middle; display:inline"
required="true">
<f:selectItem itemLabel="#{messages.genero_femenino}" itemValue="FEMENINO" />
<f:selectItem itemLabel="#{messages.genero_masculino}" itemValue="MASCULINO" />
</ice:selectOneRadio>
</s:decorate>
<s:decorate id="apPaternodecId" template="layout/display.xhtml">
<ui:define name="label">#{messages.apPaterno}</ui:define>
<ice:inputText id="apPaterno"
value="#{pacienteList.paciente.apPaterno}" partialSubmit="false"
required="true"/>
</s:decorate>
<s:decorate id="nacimientodecId" template="layout/display.xhtml">
<ui:define name="label">#{messages.fechaNacimiento}</ui:define>
<ice:selectInputDate id="nacimiento"
value="#{pacienteList.paciente.nacimiento}" renderAsPopup="true"
partialSubmit="false" renderMonthAsDropdown="true"
renderYearAsDropdown="true" style="width: 225px; display:inline"
required="true" /><ice:message style="color:red;" id="nacimientoError" for="nacimiento"/>
</s:decorate>
</ice:panelGroup>
<s:decorate id="searchdecId" template="layout/display.xhtml">
<ice:commandButton id="search" value="#{messages.search}"
action="/PacienteList.xhtml" partialSubmit="true" />
<ice:commandButton id="reset" value="#{messages.reset}"
action="#{pacienteList.reset()}" partialSubmit="true" />
</s:decorate>
</ice:panelGroup>
</ice:form>
------------------- Date converter -------------------------
@Name("jbSeam4413Converter")
@BypassInterceptors
@Converter
public class JbSeam4413 implements javax.faces.convert.Converter {
@Logger
private Log log;
public Object getAsObject(FacesContext context, UIComponent component,
String value) throws ConverterException {
log.info("JbSeam4413.getAsObject called (" + value +")");
if(value == null || value.trim().length() == 0)
return null;
Date date = null;
try {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
date = sdf.parse(URLDecoder.decode(value,"UTF-8"));
} catch (ParseException e) {
e.printStackTrace();
FacesMessage message = new FacesMessage();
message.setDetail("javax.faces.converter.DateTimeConverter.DATE");
message.setSummary("javax.faces.converter.DateTimeConverter.DATE_detail");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(message);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
FacesMessage message = new FacesMessage();
message.setDetail("javax.faces.converter.DateTimeConverter.DATE");
message.setSummary("javax.faces.converter.DateTimeConverter.DATE_detail");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(message);
}
return date;
}
public String getAsString(FacesContext context, UIComponent component,
Object value) throws ConverterException {
log.info("JbSeam4413.getAsString called");
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
return sdf.format(value);
}
}
-------------------------- Non ascii field converter --------------------------
@Name("trimInputFields")
@BypassInterceptors
@Converter
public class TrimInputFields implements javax.faces.convert.Converter{
public Object getAsObject(FacesContext context, UIComponent component, String value) {
if(StringUtils.isEmpty(value)){
return null;
} else {
try {
return URLDecoder.decode(value,"UTF-8");
} catch (UnsupportedEncodingException e) {
FacesMessage message = new FacesMessage();
message.setDetail("javax.faces.converter.STRING");
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(message);
}
}
}
public String getAsString(FacesContext context, UIComponent component, Object value) {
if(value!=null){
try {
return URLDecoder.decode(value.toString().trim(),"UTF-8");
} catch (UnsupportedEncodingException e) {
FacesMessage message = new FacesMessage();
message.setDetail("javax.faces.converter.STRING");
message.setSummary(e.getLocalizedMessage());
message.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ConverterException(message);
}
} else {
return null;
}
}
}