You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Fridolin Jackstadt (JIRA)" <ji...@apache.org> on 2009/04/16 16:30:15 UTC
[jira] Created: (WICKET-2227) CheckBoxConverter does not support
Integer type
CheckBoxConverter does not support Integer type
-----------------------------------------------
Key: WICKET-2227
URL: https://issues.apache.org/jira/browse/WICKET-2227
Project: Wicket
Issue Type: Improvement
Components: wicket
Affects Versions: 1.4-RC2
Reporter: Fridolin Jackstadt
Maybe it is possible to change the function?
Is it possible to convert "1" to true? this would enable support for Integer-Models
public Object convertToObject(String value, Locale locale)
{
if ("on".equals(value) || "true".equals(value) || "1".equals(value))
{
return Boolean.TRUE;
}
else
{
return Boolean.FALSE;
}
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WICKET-2227) CheckBoxConverter does not support
Integer type
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg resolved WICKET-2227.
-----------------------------------
Resolution: Won't Fix
Assignee: Igor Vaynberg
this function is used to convert browser values back to a boolean. will your browser send "1" back to the server when a checkbox is checked?
> CheckBoxConverter does not support Integer type
> -----------------------------------------------
>
> Key: WICKET-2227
> URL: https://issues.apache.org/jira/browse/WICKET-2227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.4-RC2
> Reporter: Fridolin Jackstadt
> Assignee: Igor Vaynberg
>
> Maybe it is possible to change the function?
> Is it possible to convert "1" to true? this would enable support for Integer-Models
> public Object convertToObject(String value, Locale locale)
> {
> if ("on".equals(value) || "true".equals(value) || "1".equals(value))
> {
> return Boolean.TRUE;
> }
> else
> {
> return Boolean.FALSE;
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (WICKET-2227) CheckBoxConverter does not support
Integer type
Posted by "Fridolin Jackstadt (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12700099#action_12700099 ]
Fridolin Jackstadt commented on WICKET-2227:
--------------------------------------------
May this is a better solution?
package org.apache.wicket.markup.html.form;
import org.apache.log4j.Logger;
import org.apache.wicket.model.IModel;
public class IntegerCheckBox extends CheckBox {
private static Logger logger = Logger.getLogger(IntegerCheckBox.class);
public IntegerCheckBox(final String id) {
this(id, null);
}
public IntegerCheckBox(final String id, IModel<Integer> model) {
super(id);
setDefaultModel(model);
if (model.getObject() instanceof Integer) {
setType(Integer.class);
}
else {
logger.warn("Using IntegerCheckBox with not Integer model. Please use CheckBox instead.");
}
}
@Override
protected String getModelValue() {
Object test = getDefaultModelObject();
if (test instanceof Integer) {
return Boolean.toString(((Integer) test).intValue() != 0);
}
else {
return super.getModelValue();
}
}
}
> CheckBoxConverter does not support Integer type
> -----------------------------------------------
>
> Key: WICKET-2227
> URL: https://issues.apache.org/jira/browse/WICKET-2227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.4-RC2
> Reporter: Fridolin Jackstadt
> Assignee: Igor Vaynberg
>
> Maybe it is possible to change the function?
> Is it possible to convert "1" to true? this would enable support for Integer-Models
> public Object convertToObject(String value, Locale locale)
> {
> if ("on".equals(value) || "true".equals(value) || "1".equals(value))
> {
> return Boolean.TRUE;
> }
> else
> {
> return Boolean.FALSE;
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Reopened: (WICKET-2227) CheckBoxConverter does not support
Integer type
Posted by "Fridolin Jackstadt (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Fridolin Jackstadt reopened WICKET-2227:
----------------------------------------
No, it is also called from "onComponentTag" to convert the string value of the model object to a Boolean value.
If the type of the CheckBox is Integer the IntegerConverter is used to convert the Integer to String, and then the CheckboxConverter to convert the String to Boolean.
So it is not possible to set the type of Checkbox to Integer.class and use the value "1" as true.
The CheckboxConverter in this case is used before any String ist send back from the browser!
> CheckBoxConverter does not support Integer type
> -----------------------------------------------
>
> Key: WICKET-2227
> URL: https://issues.apache.org/jira/browse/WICKET-2227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.4-RC2
> Reporter: Fridolin Jackstadt
> Assignee: Igor Vaynberg
>
> Maybe it is possible to change the function?
> Is it possible to convert "1" to true? this would enable support for Integer-Models
> public Object convertToObject(String value, Locale locale)
> {
> if ("on".equals(value) || "true".equals(value) || "1".equals(value))
> {
> return Boolean.TRUE;
> }
> else
> {
> return Boolean.FALSE;
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WICKET-2227) CheckBoxConverter does not support
Integer type
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2227?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg resolved WICKET-2227.
-----------------------------------
Resolution: Won't Fix
the checkbox is a formcomponent<boolean>, so it expects an imodel<boolean>. you can do two things
provide your own converter, or provide a model wrapper that maps between integer and boolean however you want.
> CheckBoxConverter does not support Integer type
> -----------------------------------------------
>
> Key: WICKET-2227
> URL: https://issues.apache.org/jira/browse/WICKET-2227
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.4-RC2
> Reporter: Fridolin Jackstadt
> Assignee: Igor Vaynberg
>
> Maybe it is possible to change the function?
> Is it possible to convert "1" to true? this would enable support for Integer-Models
> public Object convertToObject(String value, Locale locale)
> {
> if ("on".equals(value) || "true".equals(value) || "1".equals(value))
> {
> return Boolean.TRUE;
> }
> else
> {
> return Boolean.FALSE;
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.