You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by mathias °ö° <Ma...@statistik.sachsen.de> on 2007/01/18 13:04:24 UTC
HashMap and dataTable
hi all
how can i access my HashMap (backing bean) in the jsf-page:
<t:dataTable value="#{myHashMap.myhm}" var="table">
<t:column value=""></t:column> <!-- Frage column -->
<t:column value=""></t:column> <!-- Antwort column -->
</t:dataTable>
backing bean:
public class MyHashMap {
public HashMap <String, String> myhm = new HashMap<String, String>();
public HashMap<String, String> getMyhm() {
myhm.put("Frage1", "Antwort1");
myhm.put("Frage2", "Antwort2");
myhm.put("Frage3", "Antwort3");
myhm.put("Frage4", "Antwort4");
return myhm;
}
public void setMyhm(HashMap<String, String> myhm) {
this.myhm = myhm;
}
}
--
View this message in context: http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8429583
Sent from the MyFaces - Users mailing list archive at Nabble.com.
How to set the column with in dataTable?
Posted by "Chen, Wei" <W....@verband.creditreform.de>.
Hi,
My codes looks as follow. But it doesn't work. Any Tipps?
<t:dataTable id="dataError" value="#{fileuploadBean.dataFormatErrorEntrySet}" var="dataError" border="1">
<t:column width="150">
<f:facet name="header">
<h:outputText value="#{bundle.table_header_linenNumber}" />
</f:facet>
<h:outputText value="#{dataError.key}"/>
</t:column>
...
...
</t:dataTable>
Regards
Wei
-----Ursprüngliche Nachricht-----
Von: Volker Weber [mailto:weber.volker@googlemail.com]
Gesendet: Freitag, 19. Januar 2007 12:11
An: MyFaces Discussion
Betreff: Re: HashMap and dataTable
Hi,
try:
<t:dataTable value="#{myHashMap.myhmEntrySet}" var="entry">
<t:column>
<t:outputText value="#{entry.key}" />
</t:column>
<t:column>
<t:outputText value="#{entry.value}" />
</t:column>
</t:dataTable>
Regards,
Volker
2007/1/19, mathias °ö° <Ma...@statistik.sachsen.de>:
>
> hi maik
> thanks for your answer
>
> it works, but the jsf-page display this:
>
> table:
> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
>
> my jsf-page:
> <t:outputText value="table:" />
> <t:dataTable value="#{myHashMap.myhmEntrySet}" var="entry">
> <t:column>
> <t:outputText value="#{myHashMap.myhmEntrySet}" />
> </t:column>
> </t:dataTable>
>
> what is wrong?
>
>
> Mike Kienenberger wrote:
> >
> > UIData components operate on ordered lists.
> >
> > So the easiest thing to do would be to use something like this:
> >
> > <t:dataTable value="#{myHashMap.myhmEntrySetList}" var="entry">
> >
> > public List getMyhmEntrySetList() {
> > return new java.util.ArrayList(myhm.entrySet());
> > }
> >
> >
> > On 1/18/07, mathias °ö° <Ma...@...> wrote:
> >>
> >> hi all
> >>
> >> how can i access my HashMap (backing bean) in the jsf-page:
> >>
> >> <t:dataTable value="#{myHashMap.myhm}" var="table">
> >> <t:column value=""></t:column> <!-- Frage column -->
> >> <t:column value=""></t:column> <!-- Antwort column -->
> >> </t:dataTable>
> >>
> >> backing bean:
> >>
> >> public class MyHashMap {
> >>
> >> public HashMap <String, String> myhm = new HashMap<String, String>();
> >>
> >> public HashMap<String, String> getMyhm() {
> >>
> >> myhm.put("Frage1", "Antwort1");
> >> myhm.put("Frage2", "Antwort2");
> >> myhm.put("Frage3", "Antwort3");
> >> myhm.put("Frage4", "Antwort4");
> >>
> >> return myhm;
> >>
> >> }
> >>
> >> public void setMyhm(HashMap<String, String> myhm) {
> >> this.myhm = myhm;
> >>
> >> }
> >>
> >> }
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8429583
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8446082
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>
Re: HashMap and dataTable
Posted by mathias °ö° <Ma...@statistik.sachsen.de>.
hi volker
great! it works
thanks
Volker Weber-4 wrote:
>
> Hi,
>
> try:
>
> <t:dataTable value="#{myHashMap.myhmEntrySet}" var="entry">
> <t:column>
> <t:outputText value="#{entry.key}" />
> </t:column>
> <t:column>
> <t:outputText value="#{entry.value}" />
> </t:column>
> </t:dataTable>
>
> Regards,
> Volker
>
> 2007/1/19, mathias °ö° <Ma...@...>:
>>
>> hi maik
>> thanks for your answer
>>
>> it works, but the jsf-page display this:
>>
>> table:
>> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
>> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
>> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
>> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
>>
>> my jsf-page:
>> <t:outputText value="table:" />
>> <t:dataTable value="#{myHashMap.myhmEntrySet}" var="entry">
>> <t:column>
>> <t:outputText value="#{myHashMap.myhmEntrySet}" />
>> </t:column>
>> </t:dataTable>
>>
>> what is wrong?
>>
>>
>> Mike Kienenberger wrote:
>> >
>> > UIData components operate on ordered lists.
>> >
>> > So the easiest thing to do would be to use something like this:
>> >
>> > <t:dataTable value="#{myHashMap.myhmEntrySetList}" var="entry">
>> >
>> > public List getMyhmEntrySetList() {
>> > return new java.util.ArrayList(myhm.entrySet());
>> > }
>> >
>> >
>> > On 1/18/07, mathias °ö° <Ma...@...> wrote:
>> >>
>> >> hi all
>> >>
>> >> how can i access my HashMap (backing bean) in the jsf-page:
>> >>
>> >> <t:dataTable value="#{myHashMap.myhm}" var="table">
>> >> <t:column value=""></t:column> <!-- Frage column -->
>> >> <t:column value=""></t:column> <!-- Antwort column -->
>> >> </t:dataTable>
>> >>
>> >> backing bean:
>> >>
>> >> public class MyHashMap {
>> >>
>> >> public HashMap <String, String> myhm = new HashMap<String, String>();
>> >>
>> >> public HashMap<String, String> getMyhm() {
>> >>
>> >> myhm.put("Frage1", "Antwort1");
>> >> myhm.put("Frage2", "Antwort2");
>> >> myhm.put("Frage3", "Antwort3");
>> >> myhm.put("Frage4", "Antwort4");
>> >>
>> >> return myhm;
>> >>
>> >> }
>> >>
>> >> public void setMyhm(HashMap<String, String> myhm) {
>> >> this.myhm = myhm;
>> >>
>> >> }
>> >>
>> >> }
>> >>
>> >> --
>> >> View this message in context:
>> >> http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8429583
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8446082
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8447609
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: HashMap and dataTable
Posted by Volker Weber <we...@googlemail.com>.
Hi,
try:
<t:dataTable value="#{myHashMap.myhmEntrySet}" var="entry">
<t:column>
<t:outputText value="#{entry.key}" />
</t:column>
<t:column>
<t:outputText value="#{entry.value}" />
</t:column>
</t:dataTable>
Regards,
Volker
2007/1/19, mathias °ö° <Ma...@statistik.sachsen.de>:
>
> hi maik
> thanks for your answer
>
> it works, but the jsf-page display this:
>
> table:
> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
> [Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
>
> my jsf-page:
> <t:outputText value="table:" />
> <t:dataTable value="#{myHashMap.myhmEntrySet}" var="entry">
> <t:column>
> <t:outputText value="#{myHashMap.myhmEntrySet}" />
> </t:column>
> </t:dataTable>
>
> what is wrong?
>
>
> Mike Kienenberger wrote:
> >
> > UIData components operate on ordered lists.
> >
> > So the easiest thing to do would be to use something like this:
> >
> > <t:dataTable value="#{myHashMap.myhmEntrySetList}" var="entry">
> >
> > public List getMyhmEntrySetList() {
> > return new java.util.ArrayList(myhm.entrySet());
> > }
> >
> >
> > On 1/18/07, mathias °ö° <Ma...@...> wrote:
> >>
> >> hi all
> >>
> >> how can i access my HashMap (backing bean) in the jsf-page:
> >>
> >> <t:dataTable value="#{myHashMap.myhm}" var="table">
> >> <t:column value=""></t:column> <!-- Frage column -->
> >> <t:column value=""></t:column> <!-- Antwort column -->
> >> </t:dataTable>
> >>
> >> backing bean:
> >>
> >> public class MyHashMap {
> >>
> >> public HashMap <String, String> myhm = new HashMap<String, String>();
> >>
> >> public HashMap<String, String> getMyhm() {
> >>
> >> myhm.put("Frage1", "Antwort1");
> >> myhm.put("Frage2", "Antwort2");
> >> myhm.put("Frage3", "Antwort3");
> >> myhm.put("Frage4", "Antwort4");
> >>
> >> return myhm;
> >>
> >> }
> >>
> >> public void setMyhm(HashMap<String, String> myhm) {
> >> this.myhm = myhm;
> >>
> >> }
> >>
> >> }
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8429583
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8446082
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>
Re: HashMap and dataTable
Posted by mathias °ö° <Ma...@statistik.sachsen.de>.
hi mike
thanks for your answer
it works, but the jsf-page display this:
table:
[Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
[Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
[Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
[Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
my jsf-page:
<t:outputText value="table:" />
<t:dataTable value="#{myHashMap.myhmEntrySet}" var="entry">
<t:column>
<t:outputText value="#{myHashMap.myhmEntrySet}" />
</t:column>
</t:dataTable>
what is wrong?
Mike Kienenberger wrote:
>
> UIData components operate on ordered lists.
>
> So the easiest thing to do would be to use something like this:
>
> <t:dataTable value="#{myHashMap.myhmEntrySetList}" var="entry">
>
> public List getMyhmEntrySetList() {
> return new java.util.ArrayList(myhm.entrySet());
> }
>
>
> On 1/18/07, mathias °ö° <Ma...@...> wrote:
>>
>> hi all
>>
>> how can i access my HashMap (backing bean) in the jsf-page:
>>
>> <t:dataTable value="#{myHashMap.myhm}" var="table">
>> <t:column value=""></t:column> <!-- Frage column -->
>> <t:column value=""></t:column> <!-- Antwort column -->
>> </t:dataTable>
>>
>> backing bean:
>>
>> public class MyHashMap {
>>
>> public HashMap <String, String> myhm = new HashMap<String, String>();
>>
>> public HashMap<String, String> getMyhm() {
>>
>> myhm.put("Frage1", "Antwort1");
>> myhm.put("Frage2", "Antwort2");
>> myhm.put("Frage3", "Antwort3");
>> myhm.put("Frage4", "Antwort4");
>>
>> return myhm;
>>
>> }
>>
>> public void setMyhm(HashMap<String, String> myhm) {
>> this.myhm = myhm;
>>
>> }
>>
>> }
>>
>> --
>> View this message in context:
>> http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8429583
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8446082
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: HashMap and dataTable
Posted by mathias °ö° <Ma...@statistik.sachsen.de>.
hi maik
thanks for your answer
it works, but the jsf-page display this:
table:
[Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
[Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
[Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
[Frage1=Antwort1, Frage3=Antwort3, Frage2=Antwort2, Frage4=Antwort4]
my jsf-page:
<t:outputText value="table:" />
<t:dataTable value="#{myHashMap.myhmEntrySet}" var="entry">
<t:column>
<t:outputText value="#{myHashMap.myhmEntrySet}" />
</t:column>
</t:dataTable>
what is wrong?
Mike Kienenberger wrote:
>
> UIData components operate on ordered lists.
>
> So the easiest thing to do would be to use something like this:
>
> <t:dataTable value="#{myHashMap.myhmEntrySetList}" var="entry">
>
> public List getMyhmEntrySetList() {
> return new java.util.ArrayList(myhm.entrySet());
> }
>
>
> On 1/18/07, mathias °ö° <Ma...@...> wrote:
>>
>> hi all
>>
>> how can i access my HashMap (backing bean) in the jsf-page:
>>
>> <t:dataTable value="#{myHashMap.myhm}" var="table">
>> <t:column value=""></t:column> <!-- Frage column -->
>> <t:column value=""></t:column> <!-- Antwort column -->
>> </t:dataTable>
>>
>> backing bean:
>>
>> public class MyHashMap {
>>
>> public HashMap <String, String> myhm = new HashMap<String, String>();
>>
>> public HashMap<String, String> getMyhm() {
>>
>> myhm.put("Frage1", "Antwort1");
>> myhm.put("Frage2", "Antwort2");
>> myhm.put("Frage3", "Antwort3");
>> myhm.put("Frage4", "Antwort4");
>>
>> return myhm;
>>
>> }
>>
>> public void setMyhm(HashMap<String, String> myhm) {
>> this.myhm = myhm;
>>
>> }
>>
>> }
>>
>> --
>> View this message in context:
>> http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8429583
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8446082
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: HashMap and dataTable
Posted by Mike Kienenberger <mk...@gmail.com>.
UIData components operate on ordered lists.
So the easiest thing to do would be to use something like this:
<t:dataTable value="#{myHashMap.myhmEntrySetList}" var="entry">
public List getMyhmEntrySetList() {
return new java.util.ArrayList(myhm.entrySet());
}
On 1/18/07, mathias °ö° <Ma...@statistik.sachsen.de> wrote:
>
> hi all
>
> how can i access my HashMap (backing bean) in the jsf-page:
>
> <t:dataTable value="#{myHashMap.myhm}" var="table">
> <t:column value=""></t:column> <!-- Frage column -->
> <t:column value=""></t:column> <!-- Antwort column -->
> </t:dataTable>
>
> backing bean:
>
> public class MyHashMap {
>
> public HashMap <String, String> myhm = new HashMap<String, String>();
>
> public HashMap<String, String> getMyhm() {
>
> myhm.put("Frage1", "Antwort1");
> myhm.put("Frage2", "Antwort2");
> myhm.put("Frage3", "Antwort3");
> myhm.put("Frage4", "Antwort4");
>
> return myhm;
>
> }
>
> public void setMyhm(HashMap<String, String> myhm) {
> this.myhm = myhm;
>
> }
>
> }
>
> --
> View this message in context: http://www.nabble.com/HashMap-and-dataTable-tf3033822.html#a8429583
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>