You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Igor Drobiazko <ig...@gmail.com> on 2009/07/15 07:36:30 UTC

Re: How do you display a HashMap> in a .tml table

Just convert your Map into a GridDataSource which you pass to the component.

Take a look at Tapestry's internal implementation of GridDataSource which is
constructed from a collection.

http://tapestry.formos.com/nightly/tapestry5/apidocs/src-html/org/apache/tapestry5/internal/grid/CollectionGridDataSource.html#line.29

You can also provide a type coercion from a Map to GridDataSource or to
Collection. Tapestry will do the coercion for you.


On Wed, Jul 15, 2009 at 4:35 AM, cajmrn <ca...@gmail.com> wrote:

>
> Hello all,
>
> I am once again stuck and unsure as to how to implement the following. I
> have a HashMap that contains a String id for the Key and an ArrayList as
> the
> value. What I need to do is to display in a table or grid each arrayList as
> it corresponds to a Key.
>
> How would you go about iterating first through the the id and implement it
> as a table header for example, then iterate through its corresponding
> ArrayList? Basically nesting the loops... Sort or like generating a table
> for each entry in the HashMap. Or if it could be implemented in one table
> that should be fine as well.
>
> Any help would be greatly appreciated.
> Thanks,
> Carlo
>
>
> --
> View this message in context:
> http://www.nabble.com/How-do-you-display-a-HashMap%3CString%2C-ArrayList%3Cobject%3E%3E-in-a-.tml-table-tp24490975p24490975.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
>
>


-- 
Best regards,

Igor Drobiazko

Re: How do you display a HashMap> in a .tml table

Posted by cajmrn <ca...@gmail.com>.
Hello Igor, 

Thank you for the reply, What I've implemented so far is I've converted the
hashmap keys and values to their respective collection types. but when I
pass either one of them to the grid component it displays the number of
objects passed but none of the information is passed. below is the code that
i have written for the display page.

So say for example i wanted to display just the keys i would pass the
issueKeys collection to the grid component correct? but it just displays as
aforementioned, an empty grid header with a false value in each row.
Side note:
this gird is being populated based on set of selections made on a grid that
was displayed on a previous page. I've debugged the information flow and i
can see the the HashMap is passed to this page and I see that the enclosed
ArrayList has information as well, its just Im not sure if perhaps the
information is getting lost at some point during the display of this grid?
Or maybe the accessor object that the component uses? Honestly I'm at a loss
as to what is going on...


public class Contact
{
	@ApplicationState
	private jiraDataSource jDO;
	private HashMap <String, ArrayList<Issue>> issuesList;
	private Collection<ArrayList<Issue>> issuesSet;
	private Collection<String> issueKeys;
	private String issueKey;
	
	private Issue issue;
	
	void onActivate()
	{
		issuesList =jDO.getAllIssuesLists(); 
	}
	
	public void setIssuesList(HashMap <String, ArrayList<Issue>> issuesList)
	{
		this.issuesList = issuesList;
	}
	
	public HashMap <String, ArrayList<Issue>> getIssuesList()
	{
		return issuesList;
	}

	public Collection <String> getIssueKeys()
	{
		issueKeys = issuesList.keySet();
		return issueKeys;
	}
	
	public Collection<ArrayList<Issue>> getIssuesSet()
	{
		issuesSet = issuesList.values();
		return issuesSet;
	}
	
	public String getIssueKey()
	{
		return issueKey;
	}
	
	public Issue getIssue()
	{
		return issue;
	}
	
	public void setIssue(Issue i)
	{
		this.issue = i;
	}
}

this is the page class its coming from:

public class About
{
	@ApplicationState
	private jiraDataSource jiraDO;
	private Filter filter;
	
	@InjectPage
	private Contact contact;
	
	public List <Filter> getAllFilters()
	{
		return jiraDO.getAllFilters();
	}
	
	public Filter getFilter()
	{
		return filter;
	}
	
	public void setFilter(Filter f)
	{
		this.filter = f;
	}

	@OnEvent(value="checkbox")
	void CheckboxClick()
	{
		System.out.println("a Checkbox was clicked");
	}
	
	@OnEvent(value="submit")
	Object tromSubmit()
	{
		System.out.println("submission made");
		HashMap <String, ArrayList<Issue>> issuesList =
jiraDO.getAllIssuesLists();
		contact.setIssuesList(issuesList);
		return contact;
	}

}


Igor Drobiazko wrote:
> 
> Just convert your Map into a GridDataSource which you pass to the
> component.
> 
> Take a look at Tapestry's internal implementation of GridDataSource which
> is
> constructed from a collection.
> 
> http://tapestry.formos.com/nightly/tapestry5/apidocs/src-html/org/apache/tapestry5/internal/grid/CollectionGridDataSource.html#line.29
> 
> You can also provide a type coercion from a Map to GridDataSource or to
> Collection. Tapestry will do the coercion for you.
> 
> 
> On Wed, Jul 15, 2009 at 4:35 AM, cajmrn <ca...@gmail.com> wrote:
> 
>>
>> Hello all,
>>
>> I am once again stuck and unsure as to how to implement the following. I
>> have a HashMap that contains a String id for the Key and an ArrayList as
>> the
>> value. What I need to do is to display in a table or grid each arrayList
>> as
>> it corresponds to a Key.
>>
>> How would you go about iterating first through the the id and implement
>> it
>> as a table header for example, then iterate through its corresponding
>> ArrayList? Basically nesting the loops... Sort or like generating a table
>> for each entry in the HashMap. Or if it could be implemented in one table
>> that should be fine as well.
>>
>> Any help would be greatly appreciated.
>> Thanks,
>> Carlo
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-do-you-display-a-HashMap%3CString%2C-ArrayList%3Cobject%3E%3E-in-a-.tml-table-tp24490975p24490975.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
>>
>>
> 
> 
> -- 
> Best regards,
> 
> Igor Drobiazko
> 
> 

-- 
View this message in context: http://www.nabble.com/How-do-you-display-a-HashMap%3CString%2C-ArrayList%3Cobject%3E%3E-in-a-.tml-table-tp24490975p24498894.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