Loop parameter becoming null

Tyler Wilcock <[email protected]>
Newsgroups gmane.comp.java.tapestry.user
Message-ID <CAOZwnFbY5fj0Xk+hK9KRGH-xpF9p6eZ5qj9AWh+-7E11XN0D4w@mail.gmail.com>
Hi all.  I have some components being rendered in a loop.  On initial
render, everything comes out fine.  However, when I try to click on an
eventlink within one of the rendered components, I get an application
exception.  What is going wrong here?

---
SearchFilterContainer.java
---

public class SearchFilterContainer
{
   @Inject
   private SearchFilterService searchFilterService;

   @Property
   private SearchFilter currentFilter;

   public List<SearchFilter> getChronologicalSearchFilters()
   {
      return searchFilterService.getChronologicalFilters();
   }

   public String getPreFiltersText()
   {
      return messages.get("pre-search-filters-text");
   }

   public boolean isAssetStatusFilter()
   {
      return currentFilter.getFilterType() == SearchFilterType.ASSET_STATUS;
   }


---
SearchFilterContainer.tml
---

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
             xmlns:p="tapestry:parameter"
             xmlns:sf="tapestry-library:dam/search/filters">

<t:loop source="chronologicalSearchFilters" value="currentFilter"
formState="ITERATION">
    <t:if test="assetStatusFilter">
        <sf:refineassetstatusfilter
assetStatusRefineOption="currentFilter.getFilterValue()" />
    </t:if>
</t:loop>

</t:container>

---
RefineAssetStatusFilter.java
---

public class RefineAssetStatusFilter extends SearchComponent
{
   @Parameter(required=true)
   private AssetStatusRefineOptions assetStatusRefineOption;

   public String getFilterText()
   {
      return assetStatusRefineOption.getDisplayName();
   }

   public void onRemove()
   {
      // do stuff
   }
}

---
RefineAssetStatusFilter.tml
---

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd">

<div class="search-filter rectangular-pill">
    ${getFilterText()}
    <t:eventlink event="remove" class="remove-filter-icon">&times;</t:eventlink>
</div>

</t:container>

---
Exception information
---
An unexpected application exception has occurred.

   - org.apache.tapestry5.ioc.internal.OperationException
   Failure reading parameter 'assetStatusRefineOption' of component
   dam/SearchResults:instantsearch.searchfiltercontainer.refineassetstatusfilter:
   Property 'currentFilter' (within property expression
   'currentFilter.getFilterValue()', of
   collective.app.dam.components.search.filters.SearchFilterContainer@48e53372)
   is null.
   locationclasspath:collective/app/dam/components/search/filters/SearchFilterContainer.tml,
   line 8
   3 xmlns:p="tapestry:parameter"
   4 xmlns:sf="tapestry-library:dam/search/filters">
   5
   6 <t:loop source="chronologicalSearchFilters" value="currentFilter"
   formState="ITERATION">
   7 <t:if test="assetStatusFilter">
   8 <sf:refineassetstatusfilter
   assetStatusRefineOption="currentFilter.getFilterValue()" />
   9 </t:if>
   10

   trace
      - Triggering event 'remove' on
      dam/SearchResults:instantsearch.searchfiltercontainer.refineassetstatusfilter
   - org.apache.tapestry5.runtime.ComponentEventException
   Failure reading parameter 'assetStatusRefineOption' of component
   dam/SearchResults:instantsearch.searchfiltercontainer.refineassetstatusfilter:
   Property 'currentFilter' (within property expression
   'currentFilter.getFilterValue()', of
   collective.app.dam.components.search.filters.SearchFilterContainer@48e53372)
   is null.
   contexteventTyperemovelocationclasspath:collective/app/dam/components/search/filters/SearchFilterContainer.tml,
   line 8
   - org.apache.tapestry5.ioc.internal.util.TapestryException
   Failure reading parameter 'assetStatusRefineOption' of component
   dam/SearchResults:instantsearch.searchfiltercontainer.refineassetstatusfilter:
   Property 'currentFilter' (within property expression
   'currentFilter.getFilterValue()', of
   collective.app.dam.components.search.filters.SearchFilterContainer@48e53372)
   is null.
   locationclasspath:collective/app/dam/components/search/filters/SearchFilterContainer.tml,
   line 8
   - java.lang.NullPointerException
   Property 'currentFilter' (within property expression
   'currentFilter.getFilterValue()', of
   collective.app.dam.components.search.filters.SearchFilterContainer@48e53372)
   is null.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.