You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by David Canteros <da...@gmail.com> on 2012/07/10 21:44:30 UTC
changing grid-model using ajax
Hi guys!
I'm looking for help with a rare case. I have a zone, a form (with a
checkbox) and a grid. The form and the grid are enclosed by the zone.
<t:zone t:id="targetsZone" t:update="show">
<t:form t:id="filterTargetsForm" t:zone="targetsZone" zone="targetsZone">
<t:checkbox t:id="flag" t:value="flag" />
<t:submit value="Filter" />
</t:form>
<t:grid source="targets" row="target" model="myModel" inPlace="true" />
</t:zone>
On the java side: I change the grid model, depending on the checkbox value:
@Component
private Zone targetsZone;
@Property
@Persist
private boolean flag;
public BeanModel<CycleTargets> getMyModel() {
BeanModel<CycleTargets> myModel = beanModelSource.createDisplayModel(
CycleTargets.class, messages);
if (flag){
myModel.include(.....);
myModel.exclude(.....);
myModel.reorder(.....);
} else {
myModel.include(.....);
myModel.exclude(.....);
myModel.reorder(.....);
}
}
void onSubmitFromFilterTargetsForm() {
this.ajaxResponseRenderer.addRender("targetsZone", this.targetsZone);
}
Note that the method "onSubmit" only update the zone. So, depending if the
checkbox is clicked or not, i want to change the properties displayed by
the grid.
The problem is that after the form-submit the model seem not to change and
throws an "*Render queue error in
SetupRender[cycles/NewEditCyclePage:targetsgrid]: Bean editor model for
XXXXXXXX does not contain a property with id 'XXXXXX'*"
Do you know if the model of a grid can be changed on this way?
Thanks in advance!
------------------------------------------------------------------
David Germán Canteros
Re: changing grid-model using ajax
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 10 Jul 2012 17:13:32 -0300, David Canteros
<da...@gmail.com> wrote:
> org.apache.tapestry5.internal.beaneditor.BeanModelImpl.getById(BeanModelImpl.java:185)
> org.apache.tapestry5.corelib.components.Grid$DefaultGridSortModel.getSortConstraints(Grid.java:364)
Are you sure the model you're providing in AJAX requests have all the
properties cited in the sort constraints you're using?
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: changing grid-model using ajax
Posted by David Canteros <da...@gmail.com>.
I answer myself:
Yes, the sort model seems to be catched in the grid. I solved the problem
by adding the following line in onSubmit method:
void onSubmitFromFilterTargetsForm() {
> *this.targetsGrid.getSortModel().clear();*
this.ajaxResponseRenderer.addRender("targetsZone", this.targetsZone);
> }
------------------------------------------------------------------
David Germán Canteros
2012/7/10 David Canteros <da...@gmail.com>
> Addition information: the exception occurs only if I submit the form after
> a column sort process was done. Also the stack begins with the following
> lines:
>
> Stack trace
>
> - org.apache.tapestry5.internal.beaneditor.BeanModelImpl.getById(BeanModelImpl.java:185)
>
> - org.apache.tapestry5.corelib.components.Grid$DefaultGridSortModel.getSortConstraints(Grid.java:364)
>
> - org.apache.tapestry5.corelib.components.Grid.setupDataSource(Grid.java:483)
>
> - org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java:447)
>
> - org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java)
>
> And I found in the grid's documentation, about sort-model:
>
> "*The model used to handle sorting of the Grid. This is generally not
> specified, and the built-in model supports only single column sorting. The
> sort constraints (the column that is sorted, and ascending vs. descending)
> is stored as persistent fields of the Grid component*."
>
> Is the grid catching the old properties in the sort-model???
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------
> David Germán Canteros
>
>
>
> 2012/7/10 David Canteros <da...@gmail.com>
>
>> Hi guys!
>> I'm looking for help with a rare case. I have a zone, a form (with a
>> checkbox) and a grid. The form and the grid are enclosed by the zone.
>>
>> <t:zone t:id="targetsZone" t:update="show">
>>
>> <t:form t:id="filterTargetsForm" t:zone="targetsZone" zone="targetsZone">
>> <t:checkbox t:id="flag" t:value="flag" />
>> <t:submit value="Filter" />
>> </t:form>
>>
>> <t:grid source="targets" row="target" model="myModel" inPlace="true" />
>>
>> </t:zone>
>>
>> On the java side: I change the grid model, depending on the checkbox
>> value:
>>
>> @Component
>> private Zone targetsZone;
>>
>> @Property
>> @Persist
>> private boolean flag;
>>
>> public BeanModel<CycleTargets> getMyModel() {
>>
>> BeanModel<CycleTargets> myModel = beanModelSource.createDisplayModel(
>> CycleTargets.class, messages);
>>
>> if (flag){
>> myModel.include(.....);
>> myModel.exclude(.....);
>> myModel.reorder(.....);
>> } else {
>> myModel.include(.....);
>> myModel.exclude(.....);
>> myModel.reorder(.....);
>> }
>>
>> }
>>
>>
>> void onSubmitFromFilterTargetsForm() {
>> this.ajaxResponseRenderer.addRender("targetsZone", this.targetsZone);
>> }
>>
>> Note that the method "onSubmit" only update the zone. So, depending if
>> the checkbox is clicked or not, i want to change the properties displayed
>> by the grid.
>> The problem is that after the form-submit the model seem not to change
>> and throws an "*Render queue error in
>> SetupRender[cycles/NewEditCyclePage:targetsgrid]: Bean editor model for
>> XXXXXXXX does not contain a property with id 'XXXXXX'*"
>>
>> Do you know if the model of a grid can be changed on this way?
>>
>> Thanks in advance!
>>
>>
>> ------------------------------------------------------------------
>> David Germán Canteros
>>
>
>
Re: changing grid-model using ajax
Posted by David Canteros <da...@gmail.com>.
Addition information: the exception occurs only if I submit the form after
a column sort process was done. Also the stack begins with the following
lines:
Stack trace
- org.apache.tapestry5.internal.beaneditor.BeanModelImpl.getById(BeanModelImpl.java:185)
- org.apache.tapestry5.corelib.components.Grid$DefaultGridSortModel.getSortConstraints(Grid.java:364)
- org.apache.tapestry5.corelib.components.Grid.setupDataSource(Grid.java:483)
- org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java:447)
- org.apache.tapestry5.corelib.components.Grid.setupRender(Grid.java)
And I found in the grid's documentation, about sort-model:
"*The model used to handle sorting of the Grid. This is generally not
specified, and the built-in model supports only single column sorting. The
sort constraints (the column that is sorted, and ascending vs. descending)
is stored as persistent fields of the Grid component*."
Is the grid catching the old properties in the sort-model???
------------------------------------------------------------------
David Germán Canteros
2012/7/10 David Canteros <da...@gmail.com>
> Hi guys!
> I'm looking for help with a rare case. I have a zone, a form (with a
> checkbox) and a grid. The form and the grid are enclosed by the zone.
>
> <t:zone t:id="targetsZone" t:update="show">
>
> <t:form t:id="filterTargetsForm" t:zone="targetsZone" zone="targetsZone">
> <t:checkbox t:id="flag" t:value="flag" />
> <t:submit value="Filter" />
> </t:form>
>
> <t:grid source="targets" row="target" model="myModel" inPlace="true" />
>
> </t:zone>
>
> On the java side: I change the grid model, depending on the checkbox value:
>
> @Component
> private Zone targetsZone;
>
> @Property
> @Persist
> private boolean flag;
>
> public BeanModel<CycleTargets> getMyModel() {
>
> BeanModel<CycleTargets> myModel = beanModelSource.createDisplayModel(
> CycleTargets.class, messages);
>
> if (flag){
> myModel.include(.....);
> myModel.exclude(.....);
> myModel.reorder(.....);
> } else {
> myModel.include(.....);
> myModel.exclude(.....);
> myModel.reorder(.....);
> }
>
> }
>
>
> void onSubmitFromFilterTargetsForm() {
> this.ajaxResponseRenderer.addRender("targetsZone", this.targetsZone);
> }
>
> Note that the method "onSubmit" only update the zone. So, depending if
> the checkbox is clicked or not, i want to change the properties displayed
> by the grid.
> The problem is that after the form-submit the model seem not to change
> and throws an "*Render queue error in
> SetupRender[cycles/NewEditCyclePage:targetsgrid]: Bean editor model for
> XXXXXXXX does not contain a property with id 'XXXXXX'*"
>
> Do you know if the model of a grid can be changed on this way?
>
> Thanks in advance!
>
>
> ------------------------------------------------------------------
> David Germán Canteros
>