How do I populate h:selectOneMenu with a sequence of numbers?

Hi,
I would think this would be simple, but I cannot figure out how to get it to work for the life of me. I want to have a drop down list box populated with sequential numbers. I tried this, but it fills it with blanks (I think that's what it did, I tried so many things I am forgetting what did what):
<h:selectOneMenu value="#{query.response}">
<c:forEach var="i" begin="1" end="31">
<f:selectItem itemLabel="#{i}" itemValue="#{i}"/>
</c:forEach>
</h:selectOneMenu>
I got it to fill with zeros if I say "#{0 + i}".
I am new to JavaServer Faces, but I think it's because the loop happens early, and the # expression is deferred and happens after "i" no longer exists.
How do I accomplish this? Any help is appreciated. I searched the net far and wide and could not find a solution (which seems weird, I would think this would be a common thing to want to do).
Thanks.

Use f:selectItems and let the backing bean return a List<SelectItem> with the desired values.
<h:selectOneMenu value="#{myBean.selectedItem}">
    <f:selectItems value="#{myBean.selectItems}" />
</h:selectOneMenu>
private Integer selectedItem; // + getter + setter.
private List<SelectItem> selectItems; // + getter.
public MyBean() {
    fillSelectItems();
private void fillSelectItems() {
    selectItems = new ArrayList<SelectItem>();
    for (int i = 1; i <= 31; i++) {
        selectItems.add(new SelectItem(new Integer(i)));
}PS: if you want to create kind of a calendar selection, rather look for existing components such as Tomahawk Calendar: [http://myfaces.apache.org/tomahawk/calendar.html].
Edited by: BalusC on 19-jun-2008 11:41

Similar Messages

  • How do I cerate an array with a set of numbers lets say 1 through 12 random order but no repeating.

    How do I cerate  an
    array with a set of numbers lets say 1 through 12 random order but no
    repeating.
    I know this should be easy but my brain wont work
    right now
    Solved!
    Go to Solution.

    OK, here's the handmade version.
    It is useful to know that arrays of clusters are sorted by the cluster order of the elements. Simply bundle random numbers with numbers 1-12 in a loop, create an array at the output tunnel, sort the array by the random number, and extract the number array. It will be shuffled.
    Message Edited by altenbach on 06-04-2007 09:20 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    shuffleArray.png ‏5 KB

  • How can I populate a pdf with database data?

    How can I populate a pdf that we have on our server with database data on our server?

    Actually, if you export it in the right format then you won't need a script
    at all.
    You can import data directly into fields from a plain-text file via Tools -
    Forms - More Form Options - Import Data...
    I believe the format is tab-delimited with the field names in the first row
    and their values in the second.

  • How can i populate the Jcombobox with the data from my jpa list? Desperate

    I need to populate my jcombobox with data from my jpa. This is my first time trying this and i just need some sample or a quick solution to this. Thanks in advance
    <code>
    public static MyNames myNames() {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("JavaTrialsPU");
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    Query q = em.createNamedQuery("MyNames.findAll");
    MyNames n = (MyNames) q.getResultList();
    return n;
    public static void myCombo() {       
    comboBox = new JComboBox(????--how can i make the jcombobox display my myNames() list--?????);
    frame.add(comboBox, BorderLayout.PAGE_START);
    </code>

    Implement toString() on your entity to return whatever you want to use as a label for the combobox.
    Your need for quick solutions is very destructive to your learning process. In stead take the time and read around a little. Swing happens to have an excellent tutorial with many example programs readily available for you to pick through:
    http://docs.oracle.com/javase/tutorial/uiswing/
    And PS: you need to use \ tags in this forum.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to dynamically populate a listbox with the values in the database

    Hi,
    How do dynamically populate the list box with the values in the oracle database. I want to load the list box at run time.Plz anybody help me out to find a solution for this problem.
    Thanks in advance...
    Regards,
    Shiva.

    u can wite code like this..on jsp page
    <%
    ResultSet rs = stmt.executeQuery("select vender_name from vendors");
    %>
    <select name = "vendorlist">
    <%
    while(rs.next()){
    String vname = rs.getString(1);
    %>
    <option value="<%=vname%>"><%=vname%></option%>
    <%
    rs.close();
    %>

  • How do you highlight several cells with the mouse in numbers

    how do you highlight several cells with the mouse in numbers

    Hi David,
    Using only the mouse, you can select a contiguous range of cells using the method described by dwb.
    For larger (but still contiguous) ranges you might prefer this method:
    Click the first (top left) cell of the desired selection.
    Scroll to the last (botom right) cell of the desired selection.
    Shift-click the bottom right cell to select it, and all of the cells in the rectangular array defined by this and the top left cell selected in step 1.
    To select two or more non-contiguous cells:
    Click on the first to select it.
    Command-click on another to add it to the selection.
    Repeat as necessary.
    Regards,
    Barry

  • How do I populate a ScrollView with multiple TextView and ImageView?

    Hi there,
    I'm new to development and I'm trying to create an app which includes many views, each with a scrollview containing a combination of blocks of texts and images.
    I can do this awkwardly with Storyboard, but what's the simplest way to setup and populate these through code?
    Thanks,
    Darryl

    Thanks for your response.
    Since writing my first post, I have learned that I cannot
    simply return the 2 dimensional array I create in my CFC. I think I
    need to return an array of structures.
    So now the question is, how do a receive an array of
    structures and stick it into an arrayCollection?
    I get this error:
    TypeError: Error #1034: Type Coercion failed: cannot convert
    mx.collections::ArrayCollection@3ce1251 to Array.
    in this function:
    [Bindable]
    public var acPeriod:ArrayCollection;
    private function wsListResult(event:ResultEvent):void{
    acPeriod= new ArrayCollection(wsList.onePeriod.lastResult);
    }

  • Tabular form - how to auto populate a column with the user name

    Hi,
    I have a tabular form with 3 columns - (customer name, notes, user). my users are allowed to enter customer details in the notes section... as soon as the user completes notes section and save the form, I want "USER" field to be auto populate with the user name so that I may track activity by the user...
    Please advice how to accomplish it...
    thanks in advance

    Hi,
    After user saves the forms that means commit to the database, so you can simply write a trigger like:
    CREATE OR REPLACE TRIGGER "AUDIT"
    before insert or update on TABLE1
    for each row
    begin
    :new.user_field := nvl(v('APP_USER'),user);
    end;
    Regards,
    Aljaz
    Edited by: Aljaz on 4.3.2012 22:03

  • How do I populate an array with a directory listing.

    I have a web site that has its photos updated by another person using a content management system that I have written. As Dreamweaver does not know about these extra photos, if I try to
    syncronise the site on my machine for backup purposes, Dreamweaver downloads all 5000+ photos, and this can take upwards of 12 hours if there are no breaks in the connection.
    So I am trying to write a page that creates an array of the existing files on the remote site. It will then do the same on my local site, and by comparing the arrays, will make a list of the new files, and then download these, which will save a lot of time and bandwith charges.
    First I have to read the directory list, using the code below which reads and echos it on screen.
    However, I cannot work out how to populate the required array.
    <?php
        try
        {          /***photo directory ***/
            $it = new directoryIterator('../web/thumbs');
            while( $it->valid())
                  /*** echo if not a dot directory ***/
                if( !$it->isDot() )
    /**** Array creation code needs to go here I think.***/
    echo $it->current()."<br />";
         /*** move to the next element ***/
                      $it->next();
        catch(Exception $e)
            /*** echo the error message ***/
            echo $e->getMessage();
    ?>
    This creates a list of files and displays it on the page.
    How do I store it in an array?
    Howard Walker

    Although not the solution you were looking for, consider the following:
    Click the icon in DW for "Expand to show local and remote sites."  Arrange the remote image directory by "Modified date," Then select all the recent images and GET them.
    I find the above method good enough for occassional synchronization. I also simply ignore broken image links on the testing system.
    If the above is not a solid enough solution, perhaps someone else will write your array function for you. I don't have the time.

  • How to pre-populate ADF form with data?

    Hi Guys,
    Just wondering how you go about generating a pre-populated ADF form. Is it something that is done though the ADF designer and Business Objects? or do you have to create the Database tables seperatley and bind them into ADF and the workflow. Specifically I want this so a user is presented with a several drop-down lists when the initiator human task is run.
    Thanks,
    Ross

    Hi Ross
    1. Yes, in the very first place in the Database, we added all the data manually for all the Lookups. Its our own custom Schema. We are planning to provide some simple admin screens in a different WebApps to maintain these lookup values. Note that this is a different simple ADF App, with one EJB Layer and EJB Layer calling this database and getting/updating the values.
    2. ALSO, we have some lookup values that we get from totally another System/application like Oracle EBS Suite. For this, we already have a custom schema created. In this custom schema, we have some stored procedures created by the EBS database developers (they are more familiar with EBS). Now within our EJB layer, we use JPA architecture, call these stored procedures, and get all the lookup values and show in the TaskDetails page. These lookup values are maintained in EBS itself, so we do not have any custom admin screens within our SOA/BPM project.
    In conclusion, for our SOA/BPM applications, we have like 2 Databases. First database is for SOA Components where we run RCU comand and it has all SOA_INFRA, MDS, ORABAM schemas etc. The second database is for our custom schema specific to our application. Here we have our own lookup tables, custom tables and any cutom stored procedures that coonect to external EBS etc. From Weblogic console, we just create a Datasource for this second database and use that in JPA layer (persistence.xml file). For the first database, you already know that at domain creation itself, it will create all datasources also.
    Thanks
    Ravi Jegga

  • How can i populate pdf form with access report data

    i am trying to make a report electronicly signable. my report is compiled weekly from an access database and i need a way to make it signable. if i can export records from access to an existing pdf would be great. or maybe there is a way to get a signature block put in on the fly? got any ideas?

    i am trying to make a report electronicly signable. my report is compiled weekly from an access database and i need a way to make it signable. if i can export records from access to an existing pdf would be great. or maybe there is a way to get a signature block put in on the fly? got any ideas?

  • How can I populate a UILabel with an Integer value?

    I have a UILabel field and I want to display an integer value in this field.
    I used lblTemp.text = @"number of apples"; this worked for string only. But now I have an TempInt integer whose value I want to put into the lblTemp.text.
    my final label field should be "number of apples is <TempInt>"
    Any suggestions on the syntax to do this?
    thanks for the help,
    Max

    [NSString stringWithFormat:@"%d", tempInt]

  • How do I export multichannel audio with match sequence settings?

    I have a prores file that has 10 channels of audio. I made a sequence with the same audio and video settings (I also tried dragging the video on the new sequence button with the audio import set to adaptive) and then I tried to render a clip out of it by using the match sequence settings. The audio export defaults to stereo and can't be changed. I'm using Premiere CC 7.2.2 on a Mac at the moment.

    It's difficult to be helpful when you have an attitude. I read your post, and was offering suggestions for how to achieve what you seem to want to achieve. If you really need to use the Match Sequence Settings - rather than changing the settings to match manually - then clearly you're not going to be able to get multichannel audio. Since this does not seem like a bug, I would suggest submitting a feature request and asking for the Match Sequence Settings to support multichannel audio export.
    Adobe - Feature Request/Bug Report Form

  • How to get message ID's with reference to PO numbers.

    Hi experts,
    There is requirement that we need to resend the messages manually from sproxy for a particular interface, they gave only the PO numbers.
    How can I check the Message IDs corresponding to the PO numbers?
    I created a UDMS but we require the time ranges also, that which we doesn't have.
    Can you please help me in this...
    Thanks in advance.
    Regards,
    Sunita

    Hi Sunitha
    Unfortunately there is no standard transaction by which you can get the message id from the PO number.
    You can try to configure to user defined message search in ECC system using PO number as search field. After you do that you will be able to see the messages in MONI using PO number.
    Check this document for more details
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/803b22cf-ad75-2f10-0790-da055f2e8c0e?overridelayout=t…

  • How to remove project using sql with right sequence

    Hi,
    Tried to remove failed project using queries as per sequence specified as below.But getting below error while running final sql script(delete from epub_process where project = '?')
    SQL Error: ORA-02292: integrity constraint (PUB.PROC_HIST_ID_FK) violated - child record found
    02292. 00000 - "integrity constraint (%s.%s) violated - child record found"
    *Cause:    attempted to delete a parent key value that had a foreign
               dependency.
    *Action:   delete dependencies first then parent or disable constraint.
    delete from avm_asset_lock where workspace_id in
    (select id from avm_devline where name in
    (select workspace from epub_project where project_id = 'prj49024'));
    delete from EPUB_PR_HISTORY where project_id in
    (select project_id from epub_project where project_id = 'prj49024');
    delete from epub_project where project_id = 'prj49024';
    delete from EPUB_PROC_HISTORY where process_id in
    (select process_id from epub_process where project = 'prj49024');
    delete from EPUB_PROC_TASKINFO where id in
    (select process_id from epub_process where project = 'prj49024');
    delete from epub_taskinfo where process_id in
    (select process_id from epub_process where project = 'prj49024');
    delete from EPUB_WORKFLOW_STRS where id in
    (select ID from EPUB_IND_WORKFLOW where process_id in
    (select process_id from epub_process where project = 'prj49024'));
    delete  from EPUB_IND_WORKFLOW where process_id in
    (select process_id from epub_process where project = 'prj49024');
    Getting error while executing this script
    delete from epub_process where project = 'prj49024';
    Please let me know right sequence or how to avoid this error
    Thanks
    Sri

    Thanks Shaik.Slight modification to your query working.
    delete from EPUB_PR_HISTORY where project_id in ('prj213002','prj200001');
    delete from EPUB_PROC_HISTORY where process_id in
    (select process_id from epub_process where project in ('prj213002','prj200001'));
    delete from EPUB_PROC_TASKINFO where id in
    (select process_id from epub_process where project in ('prj213002','prj200001'));
    delete from EPUB_IND_WORKFLOW where process_id in
    (select process_id from epub_process where project in ('prj213002','prj200001'));
    delete from epub_process where project in ('prj202001','prj213002');
    delete from avm_asset_lock where workspace_id in
    (select id from avm_devline where name in
    (select workspace from epub_project where project_id in ('prj213002','prj213002')));
    delete from epub_project where project_id in ('prj202001','prj213002');
    commit;

Maybe you are looking for

  • BI Report error in Web-UI

    Dear CRM Gurus,   I am calling a report from CRM 2007 Web-UI and I get an error message " Error loading template 0TPLB_0CSALMC02_Q010_1 ". The logical connection to the BI System has been created. This is a standard report. How can I debug where is i

  • How do I stop needing to scroll both horizontal and vertical in my folders to see all of the content.

    How do I stop needing to scroll both horizontal and vertical in my folders to see all of the content.

  • Cannon HF100

    I'm looking to buy a Cannon HF100 camera. I use imovie 09. Would anyone recommend this model, or is there a better camera for a decent price?

  • Mrp run without sales order

    Hi Experts,      I am running the MRP for a particular material ,and the material contains some sales order. I dont want the mrp to consider the sales order. I have made the changes in Strategy group from 40 to 10 in MRP3 tab. Schedule line from cp t

  • Objects not highlighting in the navigator

    when I click on an object in the layout model it doesn't highlight in the object navigator. This is a fairly involved report and this is very annoying. has anyone ever seen this before. Do I have some parameter set incorrectly. Thanks.