You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andy Pahne <ap...@net22.de> on 2008/02/18 13:03:30 UTC
[4.1] Checkbox component updates value to false regardless of selection
Hello,
I have a problem with what I would consider a very basic use case:
There's a component:
<input jwcid="doHotelSearchCheckbox@Checkbox"
displayName="literal:Hotels"
value="ognl:reservationQuery.searchForHotels"/>
<label jwcid="@FieldLabel"
field="component:doHotelSearchCheckbox">Hotels</label>
Unfortunatly reservationQuery.searchForHotels is updated to 'false' in
the rewind phase, no matter whether the checkbox was selected or not.
Is there something wrong with my component definition?
Thanks,
Andy
--
Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of
selection
Posted by Andy Pahne <ap...@net22.de>.
But iit does not work with 4.1.5, either.
Andy Pahne schrieb:
>
>> Also, which 4.1 version is this with?
>
> It's 4.1.3
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of
selection
Posted by Andy Pahne <ap...@net22.de>.
> Also, which 4.1 version is this with?
It's 4.1.3
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of selection
Posted by Andreas Andreou <an...@gmail.com>.
no - i dont see any problems...
What happens if you update a simple property on your page?
i.e.
<input jwcid="doHotelSearchCheckbox@Checkbox"
displayName="literal:Hotels"
value="ognl:searchForHotelsProperty"/>
Also, which 4.1 version is this with?
On 2/18/08, Andy Pahne <ap...@net22.de> wrote:
>
> Hello,
>
> I have a problem with what I would consider a very basic use case:
>
> There's a component:
>
> <input jwcid="doHotelSearchCheckbox@Checkbox"
> displayName="literal:Hotels"
> value="ognl:reservationQuery.searchForHotels"/>
> <label jwcid="@FieldLabel"
> field="component:doHotelSearchCheckbox">Hotels</label>
>
>
> Unfortunatly reservationQuery.searchForHotels is updated to 'false' in
> the rewind phase, no matter whether the checkbox was selected or not.
>
> Is there something wrong with my component definition?
>
> Thanks,
> Andy
>
>
>
> --
> Andy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of
selection
Posted by Andy Pahne <ap...@net22.de>.
Ulrich Stärk schrieb:
> ...
> Are you sure that those properties really are set to false upon form
> submission and that it's not your business logic behaving strangely? Try
> to add some debug output to your formSubmit method to make sure.
You are right. I stripped down the page and template until there was
nothing more than the two checkboxes and - it works.
Thanks for your kind help and sorry for polluting the list with Tapestry
unrelated issues.
Andy
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of
selection
Posted by Ulrich Stärk <ul...@spielviel.de>.
Andy Pahne schrieb:
> Ulrich Stärk schrieb:
>> it might be the right time now to post your complete page class and page
>> template before we start doing wild guesses...
>
>
> Here you are:
Unless you are calling setSearchForHotels() or
setSearchForHolidayHomes() in your parent class your code should work
just fine. I can see nothing wrong with it.
Are you sure that those properties really are set to false upon form
submission and that it's not your business logic behaving strangely? Try
to add some debug output to your formSubmit method to make sure.
Uli
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of
selection
Posted by Andy Pahne <ap...@net22.de>.
Ulrich Stärk schrieb:
> it might be the right time now to post your complete page class and page
> template before we start doing wild guesses...
Here you are:
Search2.java:
-----------------------------------------------------------------------
public abstract class Search2
extends BaseBookingPage
implements PageBeginRenderListener {
@InitialValue("ognl:true") @Persist
public abstract boolean isSearchForHotels();
public abstract void setSearchForHotels(boolean doIt);
@InitialValue("ognl:true") @Persist
public abstract boolean isSearchForHolidayHomes();
public abstract void setSearchForHolidayHomes(boolean doIt);
@Component(
type = "Form",
id = "bookingForm",
bindings = {
"listener=ognl:listeners.submitForm",
"delegate=ognl:beans.delegate",
"clientValidationEnabled=ognl:false" })
public abstract IComponent getBookingForm();
/* (non-Javadoc)
* @see
org.apache.tapestry.event.PageBeginRenderListener#pageBeginRender(org.apache.tapestry.event.PageEvent)
*/
public void pageBeginRender(PageEvent arg0) {
assertReservationNotLocked();
initializeArrivelDate();
initializeDepartureDate();
// if (passengerModel == null) {
// passengerModel = new IntegerPropertySelectionModel(1, 8);
// }
}
private void initializeArrivelDate() {
if(getArrivalDate() == null) {
Date arrival = DateUtil.addDays(DateUtil.getTodaysMidnight(),
getManager().getReservationStartDateOffsetDays());
setArrivalDate(arrival);
}
}
private void initializeDepartureDate() {
if(getDepartureDate() == null) {
Date departure =
DateUtil.addDays(DateUtil.getTodaysMidnight(),
getManager().getReservationStartDateOffsetDays() + 1);
setDepartureDate(departure);
}
}
/**
* Listener-Methode: Formular-Übermittlung: ReservationQuery-Objekt mit
* den Eingabedaten des Kunden befüllen.
* <p>
* Noch mache ich die Validierung hier von Hand.
*
*/
public IPage submitForm() {
assertReservationNotLocked();
ReservationQuery query = getReservationQuery();
// An- und Abreise
query.setArrivalDate(getArrivalDate());
query.setDepartureDate(getDepartureDate());
calculateNights(query);
query.setLocationSearchTerm(getLocationSearchTerm());
query.setPassengers(getPassengerQty());
// Art der Objekte, die gesucht werden
query.setSearchForHotels(isSearchForHotels());
query.setSearchForHolidayHomes(isSearchForHolidayHomes());
// Validierung ausgelagert
IValidationDelegate delegate = getDelegate();
validate(delegate);
if(isInError()) {
return null;
}
return getNextPage().startNewSearch();
}
protected void calculateNights(ReservationQuery query) {
DateTime arrival = new DateTime(query.getArrivalDate());
DateTime departure = new DateTime(query.getDepartureDate());
Days days = Days.daysBetween(arrival, departure);
int nights = days.getDays();
query.setNights(nights);
}
/**
* Manuelles Validieren der Eingabedaten
*/
protected void validate(IValidationDelegate delegate) {
int days = getManager().getReservationStartDateOffsetDays();
if(getArrivalDate().before(DateUtil.daysFromToday(days - 1))) {
// arrivalDate ist zu früh
delegate.record(getArrivalDatePicker(),
"Buchungen m\u00fcssen mindestens " + days
+ " Tage in der Zukunft liegen");
}
if(getReservationQuery().getNights() == null ||
getReservationQuery().getNights() <= 0 ) {
delegate.record(getArrivalDatePicker(),
"Bitte die Daten für An- und Abreise
\u00fcberpr\u00fcfen");
}
if(isSearchForHotels() == false && isSearchForHolidayHomes() ==
false) {
setErrorMessage("Bitte w\u00e4hlen Sie aus, welche
Unterkunftsarten " +
"gesucht werden sollen");
}
}
/** Anzahl der Passagiere */
public IPropertySelectionModel passengerModel = new
IntegerPropertySelectionModel(1, 8);
/** Datum der Ankunft */
@Persist
public abstract Date getArrivalDate();
public abstract void setArrivalDate(Date arrivalDate);
/** Datum der Abreise */
@Persist
public abstract Date getDepartureDate();
public abstract void setDepartureDate(Date departureDate);
/** Anzahl der mitreisenden Passagiere */
@Persist
public abstract Integer getPassengerQty();
/** Suchbegriff für die Suche nach einer Location */
@Persist
public abstract String getLocationSearchTerm();
public abstract void setLocationSearchTerm(String term);
@InjectPage("booking/List")
public abstract de.net22.oos.web.pages.booking.List getNextPage();
/**
* Tapestry-Komponente: Formularfeld Ankunft
*/
@Component(
bindings = {
"value=ognl:arrivalDate",
"translator=translator:date,pattern=dd.MM.yyyy",
"validators=validators:required"})
public abstract DatePicker getArrivalDatePicker();
/**
* Tapestry-Komponente: Formularfeld Ankunft
*/
@Component(
bindings = {
"value=ognl:departureDate",
"translator=translator:date,pattern=dd.MM.yyyy",
"validators=validators:required"})
public abstract DatePicker getDepartureDatePicker();
@Component(
type = "PropertySelection",
bindings = {
"model=ognl:passengerModel",
"value=ognl:passengerQty",
"validators=validators:required,min=1" })
public abstract IFormComponent getPassengerQtySelection();
}
Search2.html:
-----------------------------------------------------------------------
<span jwcid="@PublicBorder">
<form jwcid="bookingForm">
<table width="100%" border="0">
<tr>
<td width="20"> </td>
<td><span> </span></td>
</tr>
<tr>
<td width="20"></td>
<td>
<table width="100" border="0">
<tr>
<td valign="bottom"><img src="../images/top.gif" width="500"
height="30"></td>
</tr>
<tr>
<td>
<table width="500" border="1" cellpadding="3" cellspacing="0"
bordercolor="#000000" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF">
<span jwcid="@cf:ShowValidationError"
delegate="ognl:beans.delegate" />
<p class="TextNormal">
Bitte geben Sie den Zielort, das Anreisedatum und die
Aufenthaltsdauer an.
</p>
<table width="100%" bgcolor="#FFFFCC" class="formField">
<tr>
<td class="formFieldLabel" nowrap="nowrap">Suche nach:</td>
<td class="formField" nowrap="nowrap" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="87">
<input
jwcid="doHotelSearchCheckbox@Checkbox"
displayName="literal:Hotels"
value="ognl:searchForHotels"/>
<label jwcid="@FieldLabel"
field="component:doHotelSearchCheckbox">Hotels</label>
</td>
<td width="213">
<input
jwcid="doHolidayHomeSearchCheckbox@Checkbox"
displayName="literal:Ferienhäuser/wohnungen"
value="ognl:page.searchForHolidayHomes"/>
<label jwcid="@FieldLabel"
field="component:doHolidayHomeSearchCheckbox">Ferienhäuser/wohnungen</label>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="formFieldLabel" nowrap="nowrap"><label
jwcid="@FieldLabel" field="component:locationSelection">Ort /
Region</label></td>
<td class="formField" nowrap="nowrap" width="300" valign="top">
<input jwcid="locationSelection@TextField"
displayName="literal:Ort / Region"
value="ognl:page.locationSearchTerm"
validators="validators:required[Bitte geben Sie den gewünschten
Ort oder die Region an],minLength=2[Bitte geben Sie den gewünschten Ort
oder die Region an]" /></td>
</tr>
<tr>
<td class="formFieldLabel"><label jwcid="@FieldLabel"
field="component:passengerQtySelection">BlaBlubb</label></td>
<td class="formField"><input jwcid="passengerQtySelection"
displayName="literal:Personenanzahl" /></td>
</tr>
<tr>
<td nowrap="nowrap" class="formFieldLabel"><label
jwcid="@FieldLabel"
field="component:arrivalDatePicker">Ankunft</label></td>
<td width="300" valign="top" nowrap="nowrap"
class="formField"><input
jwcid="arrivalDatePicker" displayName="literal:Tag der Ankunft"
/></td>
</tr>
<tr>
<td class="formFieldLabel" nowrap="nowrap"><label
jwcid="@FieldLabel"
field="component:departureDatePicker">Abreise</label></td>
<td class="formField" nowrap="nowrap" width="300"
valign="top"><input
jwcid="departureDatePicker"
displayName="literal:Tag der Abreise" /></td>
</tr>
</table>
<div align="right">
<input jwcid="@ImageSubmit"
type="image"
image="asset:proceedButton"
value="weiter"
name="weiter"
class="formButton"
/></div>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF">
<div align="center"><img src="../images/test.jpg"
alt="Gute Reise" width="450" height="200"></div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="20"> </td>
<td> </td>
</tr>
</table>
</form>
</span>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of
selection
Posted by Ulrich Stärk <ul...@spielviel.de>.
it might be the right time now to post your complete page class and page
template before we start doing wild guesses...
Uli
Am Mo, 18.02.2008, 15:34, schrieb Andy Pahne:
>
> Nope
>
>
>
> Andreas Andreou schrieb:
>> That's weird...
>> I have so many checkboxes working here...
>>
>> Perhaps you're binding the same object somewhere else?
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of
selection
Posted by Andy Pahne <ap...@net22.de>.
Nope
Andreas Andreou schrieb:
> That's weird...
> I have so many checkboxes working here...
>
> Perhaps you're binding the same object somewhere else?
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of selection
Posted by Andreas Andreou <an...@gmail.com>.
That's weird...
I have so many checkboxes working here...
Perhaps you're binding the same object somewhere else?
On 2/18/08, Andy Pahne <ap...@net22.de> wrote:
>
>
> I tried that, but the page property is updated to false, regardless of
> the checkbox selection.
>
> Andy
>
>
>
>
> Ulrich Stärk schrieb:
> > Bind the value property of your checkbox to a page property.
> >
> > E.g. in your page class:
> >
> > public abstract boolean isChecked();
> > public abstract void setChecked(boolean checked);
> >
> > and in your template:
> >
> > <input jwcid="doHotelSearchCheckbox@Checkbox"
> > displayName="literal:Hotels"
> > value="ognl:checked"/>
> > <label jwcid="@FieldLabel"
> > field="component:doHotelSearchCheckbox">Hotels</label>
> >
> > Uli
> >
> > Am Mo, 18.02.2008, 13:03, schrieb Andy Pahne:
> >> Hello,
> >>
> >> I have a problem with what I would consider a very basic use case:
> >>
> >> There's a component:
> >>
> >> <input jwcid="doHotelSearchCheckbox@Checkbox"
> >> displayName="literal:Hotels"
> >> value="ognl:reservationQuery.searchForHotels"/>
> >> <label jwcid="@FieldLabel"
> >> field="component:doHotelSearchCheckbox">Hotels</label>
> >>
> >>
> >> Unfortunatly reservationQuery.searchForHotels is updated to 'false' in
> >> the rewind phase, no matter whether the checkbox was selected or not.
> >>
> >> Is there something wrong with my component definition?
> >>
> >> Thanks,
> >> Andy
> >>
> >>
> >>
> >> --
> >> Andy
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
>
>
> --
> Andy Pahne
> System Architektur & Software Design
>
> net22 GmbH
> Ehrenbergweg 24
> 32760 Detmold
>
> http://www.net22.de
>
> Email ap@net22.de
> Telefon +49 (5231) 58 06 40
> Mobil +49 (174) 171 68 70
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Andreas Andreou - andyhot@apache.org - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of
selection
Posted by Andy Pahne <ap...@net22.de>.
I tried that, but the page property is updated to false, regardless of
the checkbox selection.
Andy
Ulrich Stärk schrieb:
> Bind the value property of your checkbox to a page property.
>
> E.g. in your page class:
>
> public abstract boolean isChecked();
> public abstract void setChecked(boolean checked);
>
> and in your template:
>
> <input jwcid="doHotelSearchCheckbox@Checkbox"
> displayName="literal:Hotels"
> value="ognl:checked"/>
> <label jwcid="@FieldLabel"
> field="component:doHotelSearchCheckbox">Hotels</label>
>
> Uli
>
> Am Mo, 18.02.2008, 13:03, schrieb Andy Pahne:
>> Hello,
>>
>> I have a problem with what I would consider a very basic use case:
>>
>> There's a component:
>>
>> <input jwcid="doHotelSearchCheckbox@Checkbox"
>> displayName="literal:Hotels"
>> value="ognl:reservationQuery.searchForHotels"/>
>> <label jwcid="@FieldLabel"
>> field="component:doHotelSearchCheckbox">Hotels</label>
>>
>>
>> Unfortunatly reservationQuery.searchForHotels is updated to 'false' in
>> the rewind phase, no matter whether the checkbox was selected or not.
>>
>> Is there something wrong with my component definition?
>>
>> Thanks,
>> Andy
>>
>>
>>
>> --
>> Andy
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
--
Andy Pahne
System Architektur & Software Design
net22 GmbH
Ehrenbergweg 24
32760 Detmold
http://www.net22.de
Email ap@net22.de
Telefon +49 (5231) 58 06 40
Mobil +49 (174) 171 68 70
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: [4.1] Checkbox component updates value to false regardless of
selection
Posted by Ulrich Stärk <ul...@spielviel.de>.
Bind the value property of your checkbox to a page property.
E.g. in your page class:
public abstract boolean isChecked();
public abstract void setChecked(boolean checked);
and in your template:
<input jwcid="doHotelSearchCheckbox@Checkbox"
displayName="literal:Hotels"
value="ognl:checked"/>
<label jwcid="@FieldLabel"
field="component:doHotelSearchCheckbox">Hotels</label>
Uli
Am Mo, 18.02.2008, 13:03, schrieb Andy Pahne:
>
> Hello,
>
> I have a problem with what I would consider a very basic use case:
>
> There's a component:
>
> <input jwcid="doHotelSearchCheckbox@Checkbox"
> displayName="literal:Hotels"
> value="ognl:reservationQuery.searchForHotels"/>
> <label jwcid="@FieldLabel"
> field="component:doHotelSearchCheckbox">Hotels</label>
>
>
> Unfortunatly reservationQuery.searchForHotels is updated to 'false' in
> the rewind phase, no matter whether the checkbox was selected or not.
>
> Is there something wrong with my component definition?
>
> Thanks,
> Andy
>
>
>
> --
> Andy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org