myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <sjarl...@stradefi.com>
Subject RE: multi-selection in selectOneListBox
Date Mon, 20 Mar 2006 06:42:35 GMT
This was effectively the problem. Thanks a lot for your great help!

Have a nice week

Sophie

 

  _____  

De : mkahlau@web.de [mailto:mkahlau@web.de] 
Envoyé : dimanche 19 mars 2006 22:09
À : MyFaces Discussion; sjarlier@stradefi.com
Objet : AW: multi-selection in selectOneListBox

 

 I think the problem is the configuration of your commandButton:

 

<h:commandButton value="#{msg.finish_button}" id="finish-button"
action="#{MyClass.finish}" styleClass="wizardButton" immediate="true”>

 

You set immediate=true, which causes the ActionEvent to be processed BEFORE
and WITHOUT any model update, which would cause your setSelectedTrades
method to be called. You have to use immediate=false. In this case, the
ActionEvent is processed in a later phase, after model update.

 

-Matthias

 

 -----Ursprüngliche Nachricht-----
Von: users-return-18789-mkahlau=web.de@myfaces.apache.org
[mailto:users-return-18789-mkahlau=web.de@myfaces.apache.org]Im Auftrag von
sjarlier@stradefi.com
Gesendet: Sonntag, 19. März 2006 20:47
An: 'MyFaces Discussion'; mkahlau@web.de
Betreff: RE: multi-selection in selectOneListBox

I have also this setSelectedTrades to get the selected trades in the jsp
page while doing finish :

 

public void setSelectedTrades(String[] selTrades)

 {

             logger.info("[MyWizard]start setSelectedTrade");

             for(int i=0; i<selTrades.length; i++)

             {

                        if(selTrades[i]!=null)

                        {

                                   logger.info("[MyWizard]selectedTrade" +
selTrades[i]);

                                   this.selectedTrades[i] = selTrades[i];

                                   logger.info("[MyWizard]selectedTrade
stored" + this.selectedTrades[i]);

                        }

             }

             logger.info("[MyWizard]end setSelectedTrade");

 }

 

But it seems that this method is never called ([MyWizard]start
setSelectedTrade is never written in my log file).

This method should be automatically called while the selectManyListBox
changes right?

When:

<h:selectManyListbox id="trades1" value="#{MyClass.selectedTrades}"
style="width:150px" >     <f:selectItems value="#{MyClass.allTradesArray}"
/>

 

#{MyClass.selectedTrades} calls setSelectedTrades no?

 

Thanks.

Sophie

 


  _____  


De : sjarlier@stradefi.com [mailto:sjarlier@stradefi.com] 
Envoyé : dimanche 19 mars 2006 18:54
À : mkahlau@web.de; 'MyFaces Discussion'
Objet : RE: multi-selection in selectOneListBox

 

I am not really familiar with JSF lifecyle…

Here is my code in the JSF code to select the trades and to submit it
(finish)

 

<td style="width:150px">

    <h:outputText value="#{Fmsg.authorizedTrades}" />:<BR>

     <h:selectManyListbox id="trades1" value="#{MyClass.selectedTrades}"
style="width:150px" >                  <f:selectItems
value="#{MyClass.allTradesArray}" />

   </h:selectManyListbox>

</td>

[…]

<td align="center">

      <h:commandButton value="#{msg.finish_button}" id="finish-button"
action="#{MyClass.finish}" styleClass="wizardButton" immediate="true”>

</td>

 

And here is my function finish() from my backing bean:

public String finish()

   {

      String outcome = FINISH_OUTCOME;

            

      try {

                        BufferedWriter out = new BufferedWriter(new
FileWriter("selectedTrades.txt"));

 
out.write(String.valueOf(this.selectedTrades.length));

                        for(int i=0; i<this.selectedTrades.length; i++)

                        {

                                   if(selectedTrades[i]!=null)

 
out.write(this.selectedTrades[i]);

                        }

                        out.close();

         } catch (IOException ioe) {

                 System.out.println(ioe.toString());

         }

               

      return outcome;

   }

 

And I think I already described my selectedTrades and allTradesArray:

  protected SelectItem[] allTradesArray = null; 

  protected String[] selectedTrades;

 

While opening the page there is the initialization called:

MyXMLParse xmlParse = new MyXMLParse();

                    

this.allTrades = xmlParse.getAllActiveDimensions("Trade"); //I get all
trades allTrades is a List<SelectItem>

this.allTradesArray = new SelectItem[this.allTrades.size()];

      int i=0;

      for(SelectItem sel: this.allTrades)

      {

              this.allTradesArray[i] = sel;

              i++;

      }

 

Do you need other code?

Thanks again!

Sophie

      


  _____  


De : mkahlau@web.de [mailto:mkahlau@web.de] 
Envoyé : dimanche 19 mars 2006 11:39
À : MyFaces Discussion; sjarlier@stradefi.com
Objet : AW: multi-selection in selectOneListBox

 

I need more info... In which phase of the JSF request lifecycle do you
evaluate or write out the selection? How do you submit the form, could you
please post the code for the action or sth. else which does perform the
submit.

 

-Matthias

-----Ursprüngliche Nachricht-----
Von: users-return-18782-mkahlau=web.de@myfaces.apache.org
[mailto:users-return-18782-mkahlau=web.de@myfaces.apache.org]Im Auftrag von
sjarlier@stradefi.com
Gesendet: Sonntag, 19. März 2006 08:27
An: 'MyFaces Discussion'
Betreff: RE: multi-selection in selectOneListBox

I am using String datatype…

 


  _____  


De : mkahlau@web.de [mailto:mkahlau@web.de] 
Envoyé : samedi 18 mars 2006 20:24
À : MyFaces Discussion; sjarlier@stradefi.com
Objet : AW: multi-selection in selectOneListBox

 

Which datatype do you use for the SelectItem's values?

 

-Matthias

-----Ursprüngliche Nachricht-----
Von: users-return-18769-mkahlau=web.de@myfaces.apache.org
[mailto:users-return-18769-mkahlau=web.de@myfaces.apache.org]Im Auftrag von
sjarlier@stradefi.com
Gesendet: Samstag, 18. März 2006 18:48
An: 'MyFaces Discussion'
Betreff: RE: multi-selection in selectOneListBox

I tried to use an array for the selectedTrades (String[nbTrades]) and an
array for all my trades (SelectItem[nbTrades])

But that does not work, I have nbTrades selectedTrades that are all null.

 

Sophie

 


  _____  


De : mkahlau@web.de [mailto:mkahlau@web.de] 
Envoyé : samedi 18 mars 2006 16:44
À : MyFaces Discussion; sjarlier@stradefi.com
Objet : AW: multi-selection in selectOneListBox

 

I've never used the selectManyListbox action myself. But I remember a
problem when using a List for the selected values of a selectManyCheckbox,
which also didn't work. I used an Array with the type of the SelectItem
values instead, and this did the trick. Maybe you want to try this.

 

-Matthias

 

-----Ursprüngliche Nachricht-----
Von: users-return-18764-mkahlau=web.de@myfaces.apache.org
[mailto:users-return-18764-mkahlau=web.de@myfaces.apache.org]Im Auftrag von
sjarlier@stradefi.com
Gesendet: Samstag, 18. März 2006 16:19
An: mkahlau@web.de; 'MyFaces Discussion'
Betreff: RE: multi-selection in selectOneListBox

 

Thanks for the answer. I was trying to use this selectManyListBox but I got
into troubles to get the selected items.

Please would you mind telling me what I am doing wrong:

 

-          I initialized my list of trades:

protected List<SelectItem> allTrades = null;

allTrades = xmlParse.getAllActiveDimensions("Trade");     //all trades are
correctly displayed in my jsp page

 

-          I initialized my list of selected trades:

protected List<String> selectedTrades = null; 

this.selectedTrades =  new ArrayList<String>();

 

-          I have getters setters on them

public  List<SelectItem> getAllTrades(){

    return this.allTrades;

 }

public void setAllTrades(List<SelectItem> allTrades){

    this.allTrades = allTrades;

 }public  List<String> getSelectedTrades(){

    return this.selectedTrades;

 }

public void setSelectedTrades(List<String> selectedTrades) {

    this.selectedTrades = selectedTrades;

 }

-          I add the code to display the trades in my jsp page:

<td style="width:150px">

        <h:outputText value="#{Fmsg.authorizedTrades}" />:<BR>

<h:selectManyListbox id="trades1" value="#{MyClass.selectedTrades}"
style="width:150px" > 

            <f:selectItems value="#{MyClass.allTrades}" />

        </h:selectManyListbox>

   </td>

-          I write all the selected trades in a file but none are written:

try {

                  BufferedWriter out = new BufferedWriter(new
FileWriter("selectedTrades.txt"));

                  for ( String sel : this.selectedTrades)

                             out.write( sel );

                  out.close();

         } catch (IOException ioe) {

           System.out.println(ioe.toString());

         }

But here the file is created but nothing is written inside! What do I do
wrong?

Thanks again for help.

Sophie

 


  _____  


De : mkahlau@web.de [mailto:mkahlau@web.de] 
Envoyé : samedi 18 mars 2006 15:19
À : MyFaces Discussion; sjarlier@stradefi.com
Objet : AW: multi-selection in selectOneListBox

 

Hi,

 

you may use the selectManyListbox of the Standard HTML RenderKit Taglib. It
displays all options at the same time and allows the user to mouse select
many options while holding the CTRL-Key.

 

-Matthias

 

-----Ursprüngliche Nachricht-----
Von: users-return-18756-mkahlau=web.de@myfaces.apache.org
[mailto:users-return-18756-mkahlau=web.de@myfaces.apache.org]Im Auftrag von
sjarlier@stradefi.com
Gesendet: Samstag, 18. März 2006 11:41
An: 'MyFaces Discussion'
Betreff: multi-selection in selectOneListBox

Hi !

 

Is there a JSF tool to have a selectOneListBox that allows us to select
several elements in this list at the same time ?

 

Thanks

 

 


  _____  


De : Dave [mailto:javaone9@yahoo.com] 
Envoyé : samedi 18 mars 2006 09:24
À : users@myfaces.apache.org
Objet : myfaces source including sandbox

 

http://svn.apache.org/repos/asf/myfaces/

http://cvs.apache.org/builds/myfaces/nightly/

 

I try to use subForm.

I could not find sandbox in repos. In the nightly build area, there is no
sandbox either.

I like to download all myfaces source including sandbox. thanks for info.


  _____  


Yahoo! Mail
Bring photos to life! New
<http://pa.yahoo.com/*http:/us.rd.yahoo.com/evt=39174/*http:/photomail.mail.
yahoo.com>  PhotoMail makes sharing a breeze. 



__________ NOD32 1.1449 (20060317) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



__________ NOD32 1.1449 (20060317) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



__________ NOD32 1.1450 (20060318) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



__________ NOD32 1.1450 (20060318) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com



__________ NOD32 1.1450 (20060318) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com


Mime
View raw message