You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Wong, Emmanuel (Sam)" <Wo...@SEC.GOV> on 2007/01/18 22:06:48 UTC

[tobago] f:selectItem with tc:selectOneChoice

Hi:

            Could anyone tell me how to display a specified drop down
list value?  Let say will would like to display "3:Medium" instead of
other drop down value.  Please see below.  Thanks.

 

 

For example:

On the JSP:

<tc:selectOneChoice

                  value="#{ MyClassController.myBean.probability}"

                  required="false">

                  <f:selectItems value="#{
MyClassController.probability}" />

            </tc:selectOneChoice>

 

On the Backing Bean:

      

public class MyClassController{

 

      private MyBean myBean;

      public SelectItem[] _probability;

 

      public SelectItem[] getProbability() {

      

            SelectItem[] selectItemArry = new SelectItem[4];

selectItemArry[0] = new SelectItem("0", "");

            selectItemArry[1] = new SelectItem("5", "5:High");

            selectItemArry[2] = new SelectItem("3", "3:Medium");

      selectItemArry[3] = new SelectItem("1", "1:Low");

 

}

}

 

Public class MyBean{

 

      Private int probability;

 

      public int getProbility()

      {

            Return probability;

      }

 

      Public void setProbility(int probility)

      {

            This.Probility = probility;

      }

}


Re: [tobago] f:selectItem with tc:selectOneChoice

Posted by Jeff Bischoff <jb...@klkurz.com>.
Wong, Emmanuel (Sam) wrote:
> Hi:
> 
>             Could anyone tell me how to display a specified drop down
> list value?  Let say will would like to display "3:Medium" instead of
> other drop down value.  Please see below.  Thanks.

Unbelievable, considering the email that you are responding to. I think 
Dennis' advice applies equally to you, Sam. :)

Dennis Byrne wrote:
 > You will probably be better off directing these questions to
 > users@myfaces.apache.org .



Re: [tobago] f:selectItem with tc:selectOneChoice

Posted by Volker Weber <we...@googlemail.com>.
Hi,

not sure, but you have String values in selectItems and int value in
probability.

try

Private String probability;

public String getProbility()
{
    Return probability;
}

public void setProbility(String probility)
{
  this.Probility = probility;
}

or

SelectItem[] selectItemArry = new SelectItem[4];
selectItemArry[0] = new SelectItem(new Integer(0), "");
selectItemArry[1] = new SelectItem( new Integer(5), "5:High" );
selectItemArry[2] = new SelectItem(new Integer(3), "3:Medium" );
selectItemArry[3] = new SelectItem(new Integer(1), "1:Low" );

regards,
  Volker









2007/1/18, Wong, Emmanuel (Sam) <Wo...@sec.gov>:
> Yes, but the drop down box should display "3:Medium" if I set the
> probability = 3; I was not able to display "3:Medium" when I set
> probability = 3;   thannks
>
> -----Original Message-----
> From: Volker Weber [mailto:weber.volker@googlemail.com]
> Sent: Thursday, January 18, 2007 4:18 PM
> To: MyFaces Discussion
> Subject: Re: [tobago] f:selectItem with tc:selectOneChoice
>
> You want '3' as inital value?
>
> just set it:
>
> Public class MyBean{
>
>     private int probability = 3;
>
> ...
>
> }
>
>
> reagards,
>   Volker
>
> 2007/1/18, Wong, Emmanuel (Sam) <Wo...@sec.gov>:
> >
> >
> >
> >
> >
> >
> >
> > Hi:
> >
> >             Could anyone tell me how to display a specified drop down
> list
> > value?  Let say will would like to display "3:Medium" instead of other
> drop
> > down value.  Please see below.  Thanks.
> >
> >
> >
> >
> >
> > For example:
> >
> > On the JSP:
> >
> > < tc:selectOneChoice
> >
> >                   value= "#{
> > MyClassController.myBean.probability}"
> >
> >                   required= "false">
> >
> >                   <f:selectItems value="#{
> MyClassController.probability}"
> > />
> >
> >             </ tc:selectOneChoice >
> >
> >
> >
> > On the Backing Bean:
> >
> >
> >
> > public class MyClassController{
> >
> >
> >
> >       private MyBean myBean;
> >
> >       public SelectItem[] _probability;
> >
> >
> >
> >       public SelectItem[] getProbability() {
> >
> >
> >
> >             SelectItem[] selectItemArry = new SelectItem[4];
> >
> > selectItemArry[0] = new SelectItem("0" , "");
> >
> >             selectItemArry[1] = new SelectItem( "5", "5:High" );
> >
> >             selectItemArry[2] = new SelectItem( "3", "3:Medium" );
> >
> >       selectItemArry[3] = new SelectItem( "1", "1:Low" );
> >
> >
> >
> > }
> >
> > }
> >
> >
> >
> > Public class MyBean{
> >
> >
> >
> >       Private int probability;
> >
> >
> >
> >       public int getProbility()
> >
> >       {
> >
> >             Return probability;
> >
> >       }
> >
> >
> >
> >       Public void setProbility(int probility)
> >
> >       {
> >
> >             This.Probility = probility;
> >
> >       }
> >
> > }
> >
> >
> >
> >
> >  --
> >  Dennis Byrne
>

RE: [tobago] f:selectItem with tc:selectOneChoice

Posted by "Wong, Emmanuel (Sam)" <Wo...@SEC.GOV>.
Yes, but the drop down box should display "3:Medium" if I set the
probability = 3; I was not able to display "3:Medium" when I set
probability = 3;   thannks

-----Original Message-----
From: Volker Weber [mailto:weber.volker@googlemail.com] 
Sent: Thursday, January 18, 2007 4:18 PM
To: MyFaces Discussion
Subject: Re: [tobago] f:selectItem with tc:selectOneChoice

You want '3' as inital value?

just set it:

Public class MyBean{

    private int probability = 3;

...

}


reagards,
  Volker

2007/1/18, Wong, Emmanuel (Sam) <Wo...@sec.gov>:
>
>
>
>
>
>
>
> Hi:
>
>             Could anyone tell me how to display a specified drop down
list
> value?  Let say will would like to display "3:Medium" instead of other
drop
> down value.  Please see below.  Thanks.
>
>
>
>
>
> For example:
>
> On the JSP:
>
> < tc:selectOneChoice
>
>                   value= "#{
> MyClassController.myBean.probability}"
>
>                   required= "false">
>
>                   <f:selectItems value="#{
MyClassController.probability}"
> />
>
>             </ tc:selectOneChoice >
>
>
>
> On the Backing Bean:
>
>
>
> public class MyClassController{
>
>
>
>       private MyBean myBean;
>
>       public SelectItem[] _probability;
>
>
>
>       public SelectItem[] getProbability() {
>
>
>
>             SelectItem[] selectItemArry = new SelectItem[4];
>
> selectItemArry[0] = new SelectItem("0" , "");
>
>             selectItemArry[1] = new SelectItem( "5", "5:High" );
>
>             selectItemArry[2] = new SelectItem( "3", "3:Medium" );
>
>       selectItemArry[3] = new SelectItem( "1", "1:Low" );
>
>
>
> }
>
> }
>
>
>
> Public class MyBean{
>
>
>
>       Private int probability;
>
>
>
>       public int getProbility()
>
>       {
>
>             Return probability;
>
>       }
>
>
>
>       Public void setProbility(int probility)
>
>       {
>
>             This.Probility = probility;
>
>       }
>
> }
>
>
>
>
>  --
>  Dennis Byrne

Re: [tobago] f:selectItem with tc:selectOneChoice

Posted by Volker Weber <we...@googlemail.com>.
You want '3' as inital value?

just set it:

Public class MyBean{

    private int probability = 3;

...

}


reagards,
  Volker

2007/1/18, Wong, Emmanuel (Sam) <Wo...@sec.gov>:
>
>
>
>
>
>
>
> Hi:
>
>             Could anyone tell me how to display a specified drop down list
> value?  Let say will would like to display "3:Medium" instead of other drop
> down value.  Please see below.  Thanks.
>
>
>
>
>
> For example:
>
> On the JSP:
>
> < tc:selectOneChoice
>
>                   value= "#{
> MyClassController.myBean.probability}"
>
>                   required= "false">
>
>                   <f:selectItems value="#{ MyClassController.probability}"
> />
>
>             </ tc:selectOneChoice >
>
>
>
> On the Backing Bean:
>
>
>
> public class MyClassController{
>
>
>
>       private MyBean myBean;
>
>       public SelectItem[] _probability;
>
>
>
>       public SelectItem[] getProbability() {
>
>
>
>             SelectItem[] selectItemArry = new SelectItem[4];
>
> selectItemArry[0] = new SelectItem("0" , "");
>
>             selectItemArry[1] = new SelectItem( "5", "5:High" );
>
>             selectItemArry[2] = new SelectItem( "3", "3:Medium" );
>
>       selectItemArry[3] = new SelectItem( "1", "1:Low" );
>
>
>
> }
>
> }
>
>
>
> Public class MyBean{
>
>
>
>       Private int probability;
>
>
>
>       public int getProbility()
>
>       {
>
>             Return probability;
>
>       }
>
>
>
>       Public void setProbility(int probility)
>
>       {
>
>             This.Probility = probility;
>
>       }
>
> }
>
>
>
>
>  --
>  Dennis Byrne

[tobago] f:selectItem with tc:selectOneChoice

Posted by "Wong, Emmanuel (Sam)" <Wo...@SEC.GOV>.
Hi:

            Could anyone tell me how to display a specified drop down
list value?  Let say will would like to display "3:Medium" instead of
other drop down value.  Please see below.  Thanks.

 

 

For example:

On the JSP:

< tc:selectOneChoice

                  value= "#{ MyClassController.myBean.probability}"

                  required= "false">

                  <f:selectItems value="#{
MyClassController.probability}" />

            </ tc:selectOneChoice >

 

On the Backing Bean:

      

public class MyClassController{

 

      private MyBean myBean;

      public SelectItem[] _probability;

 

      public SelectItem[] getProbability() {

      

            SelectItem[] selectItemArry = new SelectItem[4];

selectItemArry[0] = new SelectItem("0" , "");

            selectItemArry[1] = new SelectItem( "5", "5:High" );

            selectItemArry[2] = new SelectItem( "3", "3:Medium" );

      selectItemArry[3] = new SelectItem( "1", "1:Low" );

 

}

}

 

Public class MyBean{

 

      Private int probability;

 

      public int getProbility()

      {

            Return probability;

      }

 

      Public void setProbility(int probility)

      {

            This.Probility = probility;

      }

}




-- 
Dennis Byrne 


Re: [tobago] f:selectItem with tc:selectOneChoice

Posted by Dennis Byrne <de...@dbyrne.net>.
Sam,

You will probably be better off directing these questions to
users@myfaces.apache.org .

Thanks,

Dennis Byrne

On 1/18/07, Wong, Emmanuel (Sam) <Wo...@sec.gov> wrote:
>
>  Hi:
>
>             Could anyone tell me how to display a specified drop down list
> value?  Let say will would like to display "3:Medium" instead of other drop
> down value.  Please see below.  Thanks.
>
>
>
>
>
> For example:
>
> On the JSP:
>
> <tc:selectOneChoice
>
>                   value="#{ MyClassController.myBean.probability}"
>
>                   required="false">
>
>                   <f:selectItems value="#{ MyClassController.probability}"
> />
>
>             </tc:selectOneChoice>
>
>
>
> On the Backing Bean:
>
>
>
> *public* *class* MyClassController{
>
>
>
>       private MyBean myBean;
>
>       *public* SelectItem[] _probability;
>
>
>
>       *public* SelectItem[] getProbability() {
>
>
>
>             SelectItem[] selectItemArry = new SelectItem[4];
>
> selectItemArry[0] = *new* SelectItem("0", "");
>
>             selectItemArry[1] = *new* SelectItem("5", "5:High");
>
>             selectItemArry[2] = *new* SelectItem("3", "3:Medium");
>
>       selectItemArry[3] = *new* SelectItem("1", "1:Low");
>
>
>
> }
>
> }
>
>
>
> Public class MyBean{
>
>
>
>       Private int probability;
>
>
>
>       public int getProbility()
>
>       {
>
>             Return probability;
>
>       }
>
>
>
>       Public void setProbility(int probility)
>
>       {
>
>             This.Probility = probility;
>
>       }
>
> }
>



-- 
Dennis Byrne