You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Me...@t-systems.com on 2011/10/06 12:21:51 UTC
set a TextField Componet to readonly
I want to set a TextField Componet to readonly. I have overriden isEnabled and onDisabled methods. but it did'nt work
private TextField vehicleTypeField(final String id, final TBPosition position)
{
final TextField field = new TextField(id, vehicleTypeModel(position))
{
private static final long serialVersionUID = -7101271673345103957L;
@Override
public boolean isVisible()
{
return isVehicleTypeVisible();
}
@Override
protected void onDisabled(final ComponentTag tag)
{
String vehicleType = "E"; //only for Test
if (vehicleType.equalsIgnoreCase("E"))
tag.put("readonly", "readonly");
}
@Override
public boolean isEnabled()
{
// return position.getVehicleType().equalsIgnoreCase("E");
// only for test
String vehicleType = "E";
return !vehicleType.equalsIgnoreCase("E");
}
};
field.add(new ValueHelperOnDoubleClickBehavior(popupPanelVehicleType, HelperValues.VEHICLE_TYPES));
return field;
}
could you please help me.
best regards
Mehmet
AW: set a TextField Componet to readonly
Posted by Me...@t-systems.com.
here vehicleTypeModel(position):
private IModel vehicleTypeModel(final TBPosition position)
{
return new Model()
{
private static final long serialVersionUID = 1L;
@Override
public Object getObject()
{
return position.getVehicleType();
}
@Override
public void setObject(final Object object)
{
position.setVehicleType((String) object);
}
};
}
-----Ursprüngliche Nachricht-----
Von: splitshade [mailto:martin.dilger@googlemail.com]
Gesendet: Donnerstag, 6. Oktober 2011 12:54
An: users@wicket.apache.org
Betreff: Re: set a TextField Componet to readonly
The interesting part is not visible in your source, the Method: vehicleTypeModel(position)
You could use some kind of readOnlyModel here -> Please check ReadOnlyPropertyModel for example.
regards
Martin
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/set-a-TextField-Componet-to-readonly-tp3877659p3877723.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: set a TextField Componet to readonly
Posted by Pranav kacholia <pr...@gmail.com>.
<input type="text" readonly="true" wicket:id="whatever />
Works in most major browsers ...
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/set-a-TextField-Componet-to-readonly-tp3877659p3879930.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: set a TextField Componet to readonly
Posted by Me...@t-systems.com.
Hi,
ReadOnlyPropertyModel will be problematic, because than the TextFiled always has to be readonly. But I do have the need that the TextFiled only has to be readonly in the case of vehicleType = "E".
Please find again the code:
private TextField vehicleTypeField(final String id, final TBPosition position)
{
final TextField field = new TextField(id, vehicleTypeModel(position))
{
private static final long serialVersionUID = -7101271673345103957L;
@Override
public boolean isVisible()
{
return isVehicleTypeVisible();
}
@Override
protected void onDisabled(final ComponentTag tag)
{
String vehicleType = "E"; //only for Test
if (vehicleType.equalsIgnoreCase("E"))
tag.put("readonly", "readonly");
}
@Override
public boolean isEnabled()
{
// return position.getVehicleType().equalsIgnoreCase("E");
// only for test
String vehicleType = "E";
return !vehicleType.equalsIgnoreCase("E");
}
};
field.add(new ValueHelperOnDoubleClickBehavior(popupPanelVehicleType, HelperValues.VEHICLE_TYPES));
return field;
}
private IModel vehicleTypeModel(final TBPosition position)
{
return new Model()
{
private static final long serialVersionUID = 1L;
@Override
public Object getObject()
{
return position.getVehicleType();
}
@Override
public void setObject(final Object object)
{
position.setVehicleType((String) object);
}
};
}
-----Ursprüngliche Nachricht-----
Von: splitshade [mailto:martin.dilger@googlemail.com]
Gesendet: Donnerstag, 6. Oktober 2011 12:54
An: users@wicket.apache.org
Betreff: Re: set a TextField Componet to readonly
The interesting part is not visible in your source, the Method: vehicleTypeModel(position)
You could use some kind of readOnlyModel here -> Please check ReadOnlyPropertyModel for example.
regards
Martin
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/set-a-TextField-Componet-to-readonly-tp3877659p3877723.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: set a TextField Componet to readonly
Posted by splitshade <ma...@googlemail.com>.
The interesting part is not visible in your source,
the Method: vehicleTypeModel(position)
You could use some kind of readOnlyModel here -> Please check
ReadOnlyPropertyModel for example.
regards
Martin
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/set-a-TextField-Componet-to-readonly-tp3877659p3877723.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org