You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Semen Vishniakov <vi...@gmail.com> on 2014/04/26 14:17:10 UTC

Loop with component inside a zone: parameter is bound to null

Hi all!

I have a loop within zone:

<t:zone t:id="answersZone" id="answersZone">
        <t:loop source="csCustomerSurvey.csAnswers" value="csAnswerCurrent">
            <cs:csAnswerComponent t:csAnswer="csAnswerCurrent"/>
        </t:loop>
</t:zone>

Also I have a selector, that changes csCustomerSurvey.csAnswers and
rerenders this zone.

<t:select t:id="selectCategory" t:model="csCategoryModel"
t:value="csCustomerSurvey.questionsCategory"  t:zone="answersZone"/>

When selected value is changed, I set csAnswers of csCustomerSurvey
and return body of the zone:

@OnEvent(value = EventConstants.VALUE_CHANGED, component = "selectCategory")
public Block onValueChangedFromSelectCategory(CsCategory csCategory)
{
         csCustomerSurvey.setQuestionsCategory(csCategory);
         csCustomerSurvey.setCsAnswers(new HashSet<CsAnswer>());
         for (CsQuestion csQuestion : csCategory.getQuestions()){
              csCustomerSurvey.getCsAnswers().add(new
CsAnswer(csQuestion, csCustomerSurvey));
         }
   return answersZone.getBody();
}

inside a csAnswerComponent I have a parameter, fields of that are
changed in this component:

@Property
@Parameter(required = true, allowNull = false, defaultPrefix =
BindingConstants.PROP)
private CsAnswer csAnswer;

when I hit submit, i get

Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
Parameter 'csAnswer' of component
somePage:customersurveycomponent.csanswercomponent is bound to null.
This parameter is not allowed to be null. [at classpath:somePage.tml,
line 23]
at org.apache.tapestry5.internal.transform.ParameterWorker$3$1.readFromBinding(ParameterWorker.java:275)
at org.apache.tapestry5.internal.transform.ParameterWorker$3$1.get(ParameterWorker.java:381)

How can I fix it?
Thanks.

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


Re: Loop with component inside a zone: parameter is bound to null

Posted by Lance Java <la...@googlemail.com>.
You can attach the onevent mixin to any field, including select. The mixin
supports passing the clientside field value(s) and an optional context.

http://tapestry-stitch.uklance.cloudbees.net/oneventdemo

Re: Loop with component inside a zone: parameter is bound to null

Posted by Semen Vishniakov <vi...@gmail.com>.
> The solution for your specific case would be to pass the current loop
> variable value in the event context, but I don't think this was implemented
> yet. Until then, you'll need to write some JavaScript and not use the
> valueChanged event of Select.

Bad news. Thank you for reply!

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


Re: Loop with component inside a zone: parameter is bound to null

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Sat, 26 Apr 2014 09:17:10 -0300, Semen Vishniakov  
<vi...@gmail.com> wrote:

> Hi all!

Hi!

>
> I have a loop within zone:
>
> <t:zone t:id="answersZone" id="answersZone">
>         <t:loop source="csCustomerSurvey.csAnswers"  
> value="csAnswerCurrent">
>             <cs:csAnswerComponent t:csAnswer="csAnswerCurrent"/>
>         </t:loop>
> </t:zone>

Remember: the value property of the Loop component is only valid while  
rendering. Events are done in a different request, so the value is lost  
(and it should, otherwise you need some ugly stuff like Tapestry 4's  
rewind phase or JSF).

The solution for your specific case would be to pass the current loop  
variable value in the event context, but I don't think this was  
implemented yet. Until then, you'll need to write some JavaScript and not  
use the valueChanged event of Select.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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