You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bhorvat <ho...@gmail.com> on 2013/02/22 00:39:38 UTC

Mixng cant find zone parameter

the zone parameter is always null for me.

call to mixing

<select t:id="selectType" t:type="select" t:mixins="SelectContextMixin" 
           t:zone="zone" t:context="currentFilterSection"
           t:model="typeModel" t:value="currentFilterSection.value.type" >
</select> 

Mixing class

    @InjectContainer
    private Select component;
    @Inject
    private ComponentResources resources;
    @Inject
    private JavaScriptSupport javascriptSupport;
    @Parameter
    private String zone;
    @Parameter
    private Object[] context;

    @AfterRender
    void linkZone() {
        Link link = resources.createEventLink("change", context);
        JSONObject spec = new JSONObject("selectId",
component.getClientId(), "zoneId", zone, "url", link.toURI());
        javascriptSupport.addInitializerCall("linkSelectToZone", spec);
    }

    Object onChange(@RequestParameter(value = "t:selectvalue", allowBlank =
true) final String selectValue) {
        CaptureResultCallback callback = new CaptureResultCallback();
        this.resources.triggerEvent(EventConstants.VALUE_CHANGED, new
Object[]{selectValue, context}, callback);
        return callback.getResult();
    }

Do I need to include zone in some differnet way?




--
View this message in context: http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Mixng cant find zone parameter

Posted by bhorvat <ho...@gmail.com>.
I see. Year your suggestion works like a charm.

thanks a million :)

cheers



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157p5720288.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Mixng cant find zone parameter

Posted by Ivan Khalopik <ik...@gmail.com>.
<t:zone t:id="zoneFilterType" id="prop:ZoneFilterTypeId">
  ...
  <t:zone t:id="zoneFilterProperty" id="prop:ZoneFilterPropertyId">
  ...
  </t:zone>
  ...
</t:zone>

   public String getZoneFilterTypeId() {
      return zoneFilterType.getClientId();//  return "zoneFilterType" +
currentFilterSection.getKey();
    }

    public String getZoneFilterPropertyId() {
        return zoneFilterProperty.getClientId();//return
"zoneFilterProperty" + currentFilterSection.getKey();
    }

In your code zone is declared to use "prop:ZoneFilterTypeId" property as
id. And this property gets id of zone => infinite recursion.
You should specify another property as zone id, e.g.:

<t:zone t:id="zoneFilterType" id="zoneFilterTypeId_${
currentFilterSection.key}">
  ...
  <t:zone t:id="zoneFilterProperty" id="zoneFilterPropertyId_${
currentFilterSection.key}">
  ...
  </t:zone>
  ...
</t:zone>


On Tue, Feb 26, 2013 at 12:03 AM, bhorvat <ho...@gmail.com> wrote:

> Nope removing normal id breaks the ajax. Here is how my code looks like
>
>  <select t:id="selectType" t:type="select" t:mixins="SelectContextMixin"
>                   zone="prop:ZoneFilterTypeId"
> t:context="currentFilterSection.key"
>                   contextEncoder="encoderFilterSection" t:model="typeModel"
>                   t:value="currentFilterSection.value.type" >
>   </select>
>
>  <t:zone t:id="zoneFilterType" id="prop:ZoneFilterTypeId">
>        <select t:id="selectProperty" t:type="select"
> t:mixins="SelectContextMixin"
>                   zone="prop:ZoneFilterPropertyId"
> t:context="currentFilterSection.key"
>                   contextEncoder="encoderFilterSection"
> t:model="propertyModel"
>                   t:value="currentFilterSection.value.properity">
>        </select>
>        <t:zone t:id="zoneFilterProperty" id="prop:ZoneFilterPropertyId">
>                    <select t:type="select" t:blankOption="never"
> class="dropDownMenu"
>                                t:model="comparatorModel"
> t:value="currentFilterSection.value.comparator">
>                   </select>
>
>        </t:zone>
>  </t:zone>
>
>     public String getZoneFilterTypeId() {
>       return zoneFilterType.getClientId();//  return "zoneFilterType" +
> currentFilterSection.getKey();
>     }
>
>     public String getZoneFilterPropertyId() {
>         return zoneFilterProperty.getClientId();//return
> "zoneFilterProperty" + currentFilterSection.getKey();
>     }
>
>
> Also is it possible to prevent using a mixin maybe the triggering of the
> original event?
>
> Thanks for the help and patience sody :)
>
> cheers
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157p5720219.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
BR
Ivan

Re: Mixng cant find zone parameter

Posted by bhorvat <ho...@gmail.com>.
Nope removing normal id breaks the ajax. Here is how my code looks like
 
 <select t:id="selectType" t:type="select" t:mixins="SelectContextMixin" 
                  zone="prop:ZoneFilterTypeId"
t:context="currentFilterSection.key"  
                  contextEncoder="encoderFilterSection" t:model="typeModel" 
                  t:value="currentFilterSection.value.type" >
  </select>  
                        
 <t:zone t:id="zoneFilterType" id="prop:ZoneFilterTypeId">
       <select t:id="selectProperty" t:type="select"
t:mixins="SelectContextMixin" 
                  zone="prop:ZoneFilterPropertyId"
t:context="currentFilterSection.key" 
                  contextEncoder="encoderFilterSection"
t:model="propertyModel" 
                  t:value="currentFilterSection.value.properity">
       </select> 
       <t:zone t:id="zoneFilterProperty" id="prop:ZoneFilterPropertyId">
                   <select t:type="select" t:blankOption="never"
class="dropDownMenu" 
                               t:model="comparatorModel"
t:value="currentFilterSection.value.comparator">
                  </select> 
                 
       </t:zone>
 </t:zone>

    public String getZoneFilterTypeId() {
      return zoneFilterType.getClientId();//  return "zoneFilterType" +
currentFilterSection.getKey();
    }

    public String getZoneFilterPropertyId() {
        return zoneFilterProperty.getClientId();//return
"zoneFilterProperty" + currentFilterSection.getKey();
    }


Also is it possible to prevent using a mixin maybe the triggering of the
original event?

Thanks for the help and patience sody :)

cheers



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157p5720219.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Mixng cant find zone parameter

Posted by Ivan Khalopik <ik...@gmail.com>.
1) It seems that you use something like this

<t:zone t:id="zone" id="prop:zoneFilterPropertyId">
...
  <t:select zone="prop:zoneFilterPropertyId" .../>
...
</t:zone>

public String getZoneFilterPropertyId() {
  return zone.getClientId();
}

It makes a recursion in zoneId retrieval. You just need to remove id
parameter from zone.

<t:zone t:id="zone">
...
<t:zone>


On Mon, Feb 25, 2013 at 1:39 AM, bhorvat <ho...@gmail.com> wrote:

> Hi sody,
>
> Thanks for your info. I have managed to get to the same conclusion but you
> have explained a few problems that I was having :)
>
> 1) I found some old mail treads so I managed to figure this part on my own.
> However I prefer your solution but for some reason it isnt really working.
> For some reason I am getting StackOverFlowException
>
>
> com.bomahabo.flow.tapestry.components.layout.FilterData.getZoneFilterPropertyId(FilterData.java:138)
> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:59)
>
> org.apache.tapestry5.internal.transform.ParameterWorker$3$1.readFromBinding(ParameterWorker.java:263)
>
> org.apache.tapestry5.internal.transform.ParameterWorker$3$1.get(ParameterWorker.java:381)
>
> org.apache.tapestry5.corelib.components.Zone.conduit_get_idParameter(Zone.java)
> org.apache.tapestry5.corelib.components.Zone.getClientId(Zone.java:248)
>
> com.bomahabo.flow.tapestry.components.layout.FilterData.getZoneFilterPropertyId(FilterData.java:138)
> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:59)
>
> org.apache.tapestry5.internal.transform.ParameterWorker$3$1.readFromBinding(ParameterWorker.java:263)
>
> org.apache.tapestry5.internal.transform.ParameterWorker$3$1.get(ParameterWorker.java:381)
>
> org.apache.tapestry5.corelib.components.Zone.conduit_get_idParameter(Zone.java)
> org.apache.tapestry5.corelib.components.Zone.getClientId(Zone.java:248)
>
> com.bomahabo.flow.tapestry.components.layout.FilterData.getZoneFilterPropertyId(FilterData.java:138)
> org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:59)
>
> 2) Yea I have seen this behvariour. To be honest I dont mind it as it only
> calls my handler method so I dont have any problem still any way to prevent
> select component from adding its javascript that will trigger an event?
>
> 3) Thanks for this I have implemented as per your suggestion. Well I have
> used triggerEvent that receives a list of object or in my case one object
>
> 4) To be honest I was under the impression that I cant really use this but
> I
> will give a it a closer look that is for sure
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157p5720195.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
BR
Ivan

Re: Mixng cant find zone parameter

Posted by bhorvat <ho...@gmail.com>.
Hi sody,

Thanks for your info. I have managed to get to the same conclusion but you
have explained a few problems that I was having :)

1) I found some old mail treads so I managed to figure this part on my own.
However I prefer your solution but for some reason it isnt really working.
For some reason I am getting StackOverFlowException

com.bomahabo.flow.tapestry.components.layout.FilterData.getZoneFilterPropertyId(FilterData.java:138)
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:59)
org.apache.tapestry5.internal.transform.ParameterWorker$3$1.readFromBinding(ParameterWorker.java:263)
org.apache.tapestry5.internal.transform.ParameterWorker$3$1.get(ParameterWorker.java:381)
org.apache.tapestry5.corelib.components.Zone.conduit_get_idParameter(Zone.java)
org.apache.tapestry5.corelib.components.Zone.getClientId(Zone.java:248)
com.bomahabo.flow.tapestry.components.layout.FilterData.getZoneFilterPropertyId(FilterData.java:138)
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:59)
org.apache.tapestry5.internal.transform.ParameterWorker$3$1.readFromBinding(ParameterWorker.java:263)
org.apache.tapestry5.internal.transform.ParameterWorker$3$1.get(ParameterWorker.java:381)
org.apache.tapestry5.corelib.components.Zone.conduit_get_idParameter(Zone.java)
org.apache.tapestry5.corelib.components.Zone.getClientId(Zone.java:248)
com.bomahabo.flow.tapestry.components.layout.FilterData.getZoneFilterPropertyId(FilterData.java:138)
org.apache.tapestry5.internal.bindings.PropBinding.get(PropBinding.java:59)

2) Yea I have seen this behvariour. To be honest I dont mind it as it only
calls my handler method so I dont have any problem still any way to prevent
select component from adding its javascript that will trigger an event?

3) Thanks for this I have implemented as per your suggestion. Well I have
used triggerEvent that receives a list of object or in my case one object

4) To be honest I was under the impression that I cant really use this but I
will give a it a closer look that is for sure



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157p5720195.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Mixng cant find zone parameter

Posted by Ivan Khalopik <ik...@gmail.com>.
1. Each row will generate its own zone with unique id, so you can't use
static value for zone parameter. But you can use clientId of injected zone:

@InjectComponent
provate Zone zone;

public String getZoneId() {
  return zone.getClientId();
}

2. If you will use @BindParameter annotation - both select zone parameter
and mixin zone parameter will be bound. So you will have two behaviours:
from Select and from your mixin

3. As you don't use context parameter in onChange event handler in your
mixin you will have wrong value in VALUE_CHANGED event handler. It wil be
null. You need something like this:

    Object onChange(@RequestParameter(value = "t:selectvalue", allowBlank =
true) final String selectValue, EventContext eventContext) {
        CaptureResultCallback callback = new CaptureResultCallback();
        this.resources.triggerContextEvent(EventConstants.VALUE_CHANGED,
eventContext, callback);
        return callback.getResult();
    }

In VALUE_CHANGED event handler you will also need to get selected value
from request parameter instead of event context. As a variant you can also
create some kind of CompositeEventContext which will consist of original
EventContext and selectedValue object as a first argument.

4. And as you have already advised in another thread you can use popular
ZoneUpdater:


On Sat, Feb 23, 2013 at 6:26 PM, bhorvat <ho...@gmail.com> wrote:

> So I think that both of my problem are related to the fact that zone is not
> properly generated.
>
> It seems that regardless of the number of times I press + it always add the
> zone with the original name. The html code show that the id genreated is
> original_someRandomNumber while in the code I see that it is only original
> name. In other words each section always updates only the first row instead
> of its own row
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157p5720183.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
BR
Ivan

Re: Mixng cant find zone parameter

Posted by bhorvat <ho...@gmail.com>.
So I think that both of my problem are related to the fact that zone is not
properly generated. 

It seems that regardless of the number of times I press + it always add the
zone with the original name. The html code show that the id genreated is
original_someRandomNumber while in the code I see that it is only original
name. In other words each section always updates only the first row instead
of its own row



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157p5720183.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Mixng cant find zone parameter

Posted by bhorvat <ho...@gmail.com>.
It seems that this works but not properly. I will try to explain what I am
trying to do and then someone can tell me if this is even possible.

I want to be able to create using ajaxformloop an ability to add new row to
the 'table' each row should have few fields that are either select or
textfield. When a user select something form a first select field he will
see the refreshing of the rest of the them and the values will be changed. 

So we click the add row and then select few fields and a new row and so on.
The code so far looks like this

tml

<t:form t:id="form" >
     <div t:type="ajaxformloop" t:id="filters" t:show="update"
t:source="filterSections" t:value="currentFilterSection"
t:encoder="encoderFilterSection"> 
          <select t:id="selectType" t:type="select"
t:mixins="SelectContextMixin" t:zone="zone"    
t:context="currentFilterSection" t:model="typeModel"
t:value="currentFilterSection.value.type" >
          </select>  
          <t:zone t:id="zone"> 
              <select t:id="selectProperty" t:type="select"
t:model="propertyModel" t:value="currentFilterSection.value.properity">
              </select> 
              <t:textfield t:value="currentFilterSection.value.value"
class="field"/>  
          </t:zone> 
    </div>
   <t:submit class="profileButton" value="Run" />
  </div>
 </t:form>

Mixing

@InjectContainer
    private Select component;
    @Inject
    private ComponentResources resources;
    @Inject
    private JavaScriptSupport javascriptSupport;
    @BindParameter
    private String zone;
    @Parameter
    private Object[] context;

    @AfterRender
    void linkZone() {
        Link link = resources.createEventLink("change", context);
        JSONObject spec = new JSONObject("selectId",
component.getClientId(), "zoneId", zone, "url", link.toURI());
        javascriptSupport.addInitializerCall("linkSelectToZone", spec);
    }

    Object onChange(@RequestParameter(value = "t:selectvalue", allowBlank =
true) final String selectValue) {
        CaptureResultCallback callback = new CaptureResultCallback();
        this.resources.triggerEvent(EventConstants.VALUE_CHANGED, new
Object[]{selectValue, context}, callback);
        return callback.getResult();
    }

Problem at the moment. 

If I insert some row in advance then by adding a new row it will create a
link and add it. Selecting something will trigger a zone refresh. However
the zone that will is refreshed appears to be one above all of this and not
the one called zone in my code (ie this zone is part of the page while this
component is just added to that page)

If I dont insert any row in advance click the + button will create a link
however I cant see the code to be added and selecting anything wont trigger
a zone refresh.

Any ideas what could be the problem?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157p5720181.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Mixng cant find zone parameter

Posted by bhorvat <ho...@gmail.com>.
But why cant I use

    @BindParameter
    private String zone;

to bind the name of the zone?

<select t:id="selectType" t:type="select" t:mixins="SelectContextMixin"
t:zone="zone" t:context="currentFilterSection" t:model="typeModel"
t:value="currentFilterSection.value.type" ></select> 

I mean am I reading it wrong or should this bind the zone for me?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157p5720180.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Mixng cant find zone parameter

Posted by Taha Siddiqi <ta...@gmail.com>.
tapestry.apache.org/component-mixins.html


If the component and a mixin both define a parameter with the same name, then the component wins: the component's parameter will be bound, and the mixin's parameter will be unbound.

Alternately, you may prefix the name of the parameter with the unqualified name of the Mixin class; this eliminates the ambiguity. Example:

  @Component(parameters={"Autocomplete.id=auto", . . . }) @Mixins("Autocomplete", "DefaultFromCookie"})
  private TextField userId;
If the component and a mixin both supports informal parameters, the mixin will receive the all the unqualified informal parameters. If more than one Mixin supports informal parameters the results are undefined.

Sent from my iPhone

On 22-Feb-2013, at 5:09 AM, bhorvat <ho...@gmail.com> wrote:

> the zone parameter is always null for me.
> 
> call to mixing
> 
> <select t:id="selectType" t:type="select" t:mixins="SelectContextMixin" 
>           t:zone="zone" t:context="currentFilterSection"
>           t:model="typeModel" t:value="currentFilterSection.value.type" >
> </select> 
> 
> Mixing class
> 
>    @InjectContainer
>    private Select component;
>    @Inject
>    private ComponentResources resources;
>    @Inject
>    private JavaScriptSupport javascriptSupport;
>    @Parameter
>    private String zone;
>    @Parameter
>    private Object[] context;
> 
>    @AfterRender
>    void linkZone() {
>        Link link = resources.createEventLink("change", context);
>        JSONObject spec = new JSONObject("selectId",
> component.getClientId(), "zoneId", zone, "url", link.toURI());
>        javascriptSupport.addInitializerCall("linkSelectToZone", spec);
>    }
> 
>    Object onChange(@RequestParameter(value = "t:selectvalue", allowBlank =
> true) final String selectValue) {
>        CaptureResultCallback callback = new CaptureResultCallback();
>        this.resources.triggerEvent(EventConstants.VALUE_CHANGED, new
> Object[]{selectValue, context}, callback);
>        return callback.getResult();
>    }
> 
> Do I need to include zone in some differnet way?
> 
> 
> 
> 
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Mixng-cant-find-zone-parameter-tp5720157.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>