Why h:dataTable can have hashmap as value

I have a question about the book of core java sever faces. It's in chapter 12 and the title is how do i generate a popup window. page 591.
The book uses <h:dataTable value="#{bb.states[param.country]}" var="state">
But bb.states is a hashmap in backing bean bb. How can it be used as array.
Actually value attribute of <h:dataTable> has to be one of 4 types (array, list, Result, ResultSet).
param.country is the url parameter, it could be USA or Canada.
The book says, "the sates property of the backing bean bb yields a map whose index is the country name"
But hashmap doesn't have index. Could you please help?
Thanks,
Jie
the BackingBean.java is listed below:
package com.corejsf;
import java.util.HashMap;
import java.util.Map;
public class BackingBean {
private String country = "USA";
private String state = "";
private static Map states;
// PROPERTY: country
public String getCountry() { return country; }
public void setCountry(String newValue) { country = newValue; }
// PROPERTY: state
public String getState() { return state; }
public void setState(String newValue) { state = newValue; }
public Map getStates() { return states; }
public String[] getStatesForCountry() { return (String[]) states.get(country); }
static {
states = new HashMap();
states.put("USA",
new String[] {
"Alabama", "Alaska", "Arizona", "Arkansas", "California",
"Colorado", "Connecticut", "Delaware", "Florida", "Georgia",
"Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas",
"Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts",
"Michigan", "Minnesota", "Mississippi", "Missouri", "Montana",
"Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico",
"New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma",
"Oregon", "Pennsylvania", "Rhode Island", "South Carolina",
"South Dakota", "Tennessee", "Texas", "Utah", "Vermont",
"Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"
states.put("Canada",
new String[] {
"Alberta", "British Columbia", "Manitoba", "New Brunswick",
"Newfoundland and Labrador", "Northwest Territories",
"Nova Scotia", "Nunavut", "Ontario", "Prince Edward Island",
"Quebec", "Saskatchewan", "Yukon"

The book uses <h:dataTable
value="#{bb.states[param.country]}" var="state">
But bb.states is a hashmap in backing bean bb. How can
it be used as array.
Actually value attribute of <h:dataTable> has to be
one of 4 types (array, list, Result, ResultSet).The value of that expression is the String[] of states.
Notice in your code, you are populating the states Hashmap with String keys and String[] values. The above expression translates to java as:
// grab bb's states property which is a map
Map statesMap = bb.getStates();
// our actual value from the expression is 'states'
String[] states = (String[]) statesMap.get("USA");The DataTable will iterate over the String[] of 'states', which again, is the value of the expression #{bb.states[param.country]} and one of the 4 types you mentioned above.

Similar Messages

  • Why a table can have only one PK ?

    Just wanted to know the reason why Oracle allows only one PK per table ?
    I came across a situation where my existing large PK which is on a single (ID) column needs an alteration to add a new column (No).
    ID column on which PK is based is now subjected to have duplication and that is the reason why i want to add a new column. The new column composition is not going to ensure uniqueness.
    So, i need to create (alter) PK on two columns now.
    It seems, in order to do that, i need to drop the existing PK and create a new one. Since this is a OLTP production database, business cannot afford to drop the existing pk.
    When i tried to create a separate PK on two columns, Oracle gave me below err:
    ORA-02260: table can have only one primary keySo, i wanted to understand why Oracle allows only one PK / table ? and considering above err, is there any way to make required changes to my PK without altering existing PK?
    (Table is a large 30 GB partition table and PK is a non partitioned global index)
    I think PROBABLY i need to drop existing PK and re-create the new one. But core intention for opening this thread is to know rational behind one pk/table concept.

    OraDBA02 wrote:
    Just wanted to know the reason why Oracle allows only one PK per table ?
    It's not exactly Oracle's fault. The ISO SQL standard requires that a "PRIMARY KEY" constraint can only be used once per table. However, a UNIQUE constraint on non-nullable columns achieves effectively the same thing as a PRIMARY KEY. You can have multiple UNIQUE constraints.
    Arguably the PRIMARY KEY constraint is unnecessary and could safely be dropped from the SQL language. In principle in the relational model a "primary" key is nothing more or less than a candidate key. All keys are equal in the relational model and there is no fundamental reason to designate a primary key at all. There is certainly no reason not to have multiple keys. In the SQL world though it is a very widely observed convention to use a PRIMARY KEY constraint for each table and to use it for all foreign key references.

  • How can i sort a hashmap so that it can have duplicates

    i need to sort a hashmap so that it can have duplicates.

    How would you obtain the correct value, though? Suppose I add the values "fido", "rover", "mandibles", "fluffy" against the key "dog": How would you retrieve "fido"?
    This goes against the grain of what a Map is for, what are you actually trying to do?

  • Want new tab to open to home page and why does firefox not have a simple check box in the options because I can't keep going through a long procedure each time

    I want new tab to open to home page and why does firefox not have a simple check box in the options because I can't keep going through the long tedious procedure each time I install firefox. It is something that should be in the options tab , and I want to know why it isn't. I am totally frustrated with firefox and getting ready to switch.

    You can use the SearchReset extension to reset some preferences to the default values.
    *https://addons.mozilla.org/firefox/addon/searchreset/
    Note that the SearchReset extension only runs once and then uninstalls automatically, so it won't show on the "Firefox > Add-ons" page (about:addons).
    If you do not keep changes after a restart or otherwise have problems with preferences, see:
    *http://kb.mozillazine.org/Preferences_not_saved

  • Why this Error comes "ORA-01461: can bind a LONG value only for insert into

    I'm using Oracle 9.2 with Weblogic 8 server. After Googling i got to resolve this issue "ORA-01461: can bind a LONG value only for insert into a LONG column" by adding : oracle.jdbc.RetainV9LongBindBehavior=true in server properties for the datasource.
    But why did this error come and after keeping the above property why did this error go away ?
    Can anyone help me on this.....

    You have an error in the code:
    1. you don't provide a value for 'what' - you have to tell Oracle what it should execute when it submits the job.
    And remember - with ISUBMIT the next_date parameter has datatype VARCHAR2 - SUBMIT uses datatype DATE. So make sure you provide a VARCHAR2 value and do not rely on implicit conversion.
    >
    PROCEDURE DBMS_JOB.ISUBMIT
    (job IN BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN VARCHAR2
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);
    PROCEDURE DBMS_JOB.SUBMIT
    (job OUT BINARY_INTEGER
    ,what IN VARCHAR2
    ,next_date IN DATE DEFAULT SYSDATE
    ,interval IN VARCHAR2 DEFAULT 'null'
    ,no_parse IN BOOLEAN DEFAULT FALSE);

  • How can i do with labview program,when i have 20 different values,and 1 want to add it with constant value.and how to get the results?

    how can i do with labview program,when i have   20 different values,and 1 want to add it with constant value.and how to get the results?

    Why do the 20 values have to be different? The same code should work even if some are equal.
    What do you mean by "get the result"? The result is available at the output terminal and all you need is a wire to get it where you need it. That could be an indicator, another operation, or even a hardware device.
    What is the data type of the 20 values? An array? A cluster? A bunch of scalars? A waveform? Dynamic data?
    LabVIEW Champion . Do more with less code and in less time .

  • TS1591 my ipod touch 2g is no longer being recognized by itunes why and what can i do i have reset it and everything

    my ipod touch 2g is no longer being recognized by itunes why and what can i do i have reset it and everything

    If the Reset doesn't work, try a Restore.  Note that it's nowhere near as quick as a Reset.  Connect via cable to the computer that you use for sync.  From iTunes, select the iPad/iPod and then select the Summary tab.  Follow directions for Restore and be sure to say "yes" to the backup.  You will be warned that all data (apps, music, movies, etc.) will be erased but, as the Restore finishes, you will be asked if you wish the contents of the backup to be copied to the iPad/iPod.  Again, say "yes."
    At the end of the basic Restore, you will be asked if you wish to sync the iPad/iPod.  As before, say "yes."  Note that that sync selection will disappear and the Restore will end if you do not respond within a reasonable time.  If that happens, only the apps that are part of the IOS will appear on your device.  Corrective action is simple -  choose manual "Sync" from the bottom right of iTunes.
    If you're unable to do the Restore, go into Recovery Mode per the instructions here.

  • I have a document that in Word required a password to open. I copied and pasted it to Pages. Put the password protection on. Now if I click on that filename in Finder it automatically opens.Why. Anyone can read it. How do I protect it again?

    I have a document that in Word required a password to open. I copied and pasted it to Pages. Put the password protection on. Now if I click on that filename in Finder it automatically opens.Why. Anyone can read it. How do i protect it again?

    You saved it after setting the Password? :
    Inspector > Document > Document > Require Password to Open
    I just tested it and it shows up ijn The Finder with a padlock on the file icon and does require a password to open.
    Peter

  • I have Firefox 6.0 running under Windows XL. When I forward an email with a URL in it, my recipients tell me the URL is not highlighted and they have to cut and paste it into their browser. Why? How can I get my forwarded URLs to be highlighted?

    I have Firefox 6.0 running under Windows XL. When I forward an email with a URL in it, my recipients tell me the URL is not highlighted and they have to cut and paste it into their browser. Why? How can I get my forwarded URLs to be highlighted?

    If you think getting your web pages to appear OK in all the major browsers is tricky then dealing with email clients is way worse. There are so many of them.
    If you want to bulk email yourself, there are apps for it and their templates will work in most cases...
    http://www.iwebformusicians.com/Website-Email-Marketing/EBlast.html
    This one will create the form, database and send out the emails...
    http://www.iwebformusicians.com/Website-Email-Marketing/MailShoot.html
    The alternative is to use a marketing service if your business can justify the cost. Their templates are tested in all the common email clients...
    http://www.iwebformusicians.com/Website-Email-Marketing/Email-Marketing-Service. html
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • I have ad Apple ID on my iPad , when I use the apple on my iPhone for the first time, I put in my Apple ID for the iPad, didn't work. Need to create a new one. Why? How can I just use my iPad ID on my iPhone?

    I have ad Apple ID on my iPad , when I use the apple on my iPhone for the first time, I put in my Apple ID for the iPad, didn't work. Need to create a new one. Why? How can I just use my iPad ID on my iPhone?

    Hi kamfong,
    Went to Settings where?
    If you want to use your exisiting Apple ID on your iPad, you need to:
    1.     Go to Settings>iTunes & App Store and sign out the new ID, and then sign on the old one
    2.     Go to Settings>iCloud, scroll to the bottom and delete the iCloud account, and the sign back onto iCloud using the old ID
    You still have not indindated why you are saying that using your old ID originally "didn't work". What do you mean by that? Did you get some sort of error when you tried to sign on with your exisiting Apple ID?
    Cheers,
    GB

  • How can you expect the customer to have a LOCAL/COUNTRY Based Credit Card every where we go??? Last week I was on holiday in HK,  and  from my Hotel I was able to use m VN Credit Card with my Apple ID and purchase online!  Why THIS WEEK, can't I use my HS

    Apple_ID_card_declined_for_this_country
    How can you expect the customer to have a LOCAL/COUNTRY Based Credit Card every where we go???
    Last week I was on holiday in HK,
    and
    from my Hotel I was able to use m VN Credit Card with my Apple ID and purchase online!
    Why THIS WEEK, can't I use my HSBC Platinum Credit Card from Vietnam,
    for my Singapore Apple ID account ,
    while working here in Vietnam???

    Unfortunately, this is a problem that is driven by the DRM Dictatorship.  Despite the proliferation of mobile devices and the fact that there are many of us who do a lot of international travel, content providers don't want you to have access to their products outside of your homeland.  The Balkanized mentality of the DRM Dictatorship is way out of touch with the modern world.
    At least Apple, to its credit, allows you to use your accounts outside of your homeland as long as you have the proper credentials for them.  Most other services use the more Draconian geolocation filtering which does require you to be physically present in your homeland.  For the most part, you are not allowed to leave home if you want access to your favorite entertainment!

  • DEBUG - how can I put a "break-point" when a variable have a certain value

    Hi
    I need help...
    Do you know some kind os instruction or tools to see and stop in debug a program when a variable have a specified value ?
    For example:
    At debug I want that a program "stop" when likp-vbeln = 70000123000.
    Now for do this, I change the code and insert a IF( ), and i put a breakpoint. But i need a way without need change code.
    Thanks

    Hi Ricardo,
    Use Watch point for this puppose.
    Watchpoints allow you the option of monitoring the content of individual variables.
    The Debugger stops as soon as the value of the monitored variable arrives.
    In addition, conditions can be specified. The Debugger also checks whether such a condition is fulfilled.
    Creating a Watchpoint
    In the toolbar of the New Debugger, you will find the pushbutton Create Watchpoint . It brings you to the dialog box Create Watchpoint.
    Using this function, you can enter the variable to be monitored.
    All possible ABAP data structures are allowed here.
    Hope this will help.
    Regards,
    Nitin.

  • When i plug my ipod into my computer it is not recharging.  The computer doesn't even acknowledge that it is plugged in. Any ideas why? It does have power left so i can use it but i want to recharge it of course.  Any input is appreicated.

    When i plug my ipod into my computer it is not recharging.  The computer doesn't even acknowledge that it is plugged in. Any ideas why? It does have power left so i can use it but i want to recharge it of course.  Any input is appreicated.

    Plug it into the wall using the supplied charger.
    Barry

  • Hi! I have an iPhone 4S with iOS 6.1.3 and I have iTunes 11.1.3.8. on my Windows 8. Now I can't sync my iPhone, because the device is not recognised by iTunes. Somebody have any idea why, or what can I do (except refresh the iPhone software) ?

    Hi! I have an iPhone 4S with iOS 6.1.3 and I have iTunes 11.1.3.8. on my Windows 8. Now I can't sync my iPhone, because the device is not recognised by iTunes. Somebody have any idea why, or what can I do (except refresh the iPhone software) ?

    Hi Drazse,
    Thanks for visiting Apple Support Communities.
    If your iPhone is not recognized by iTunes for Windows, the troubleshooting steps in this article may help:
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    Cheers,
    Jeremy

  • Hi, how can i break the value for a row and column once i have converted the image to the array?????​??

    Hi, I would like to know how can i break the value for a row and column once i have converted the image to the array. I wanted to make some modification on the element of the array at a certain position. how can i do that?
    At the moment (as per attachhment), the value of the new row and column will be inserted by the user. But now, I want to do some coding that will automatically insert the new value of the row and the column ( I will use the formula node for the programming). But the question now, I don't know how to split the row and the column. Is it the value of i in the 'for loop'? I've  tried to link the 'i' to the input of the 'replace subset array icon' , but i'm unable to do it as i got some error.
    Please help me!
    For your information, I'm using LABView 7.0.

    Hi,
    Thanks for your reply.Sorry for the confusion.
    I manage to change the array element by changing the row and column value. But, what i want is to allow the program to change the array element at a specified row and column value, where the new value is generated automatically by the program.
    Atatched is the diagram. I've detailed out the program . you may refer to the comments in the formula node. There are 2 arrays going into the loop. If a >3, then the program will switch to b, where if b =0, then the program will check on the value of the next element which is in the same row with b but in the next column. But if b =45, another set of checking will be done at a dufferent value of row and column.
    I hope that I have made the problem clear. Sorry if it is still confusing.
    Hope you can help me. Thank you!!!!
    Attachments:
    arrayrowncolumn2.JPG ‏64 KB

Maybe you are looking for

  • Fetching details from the URL Link

    Hi Experts, I need a help on the webdynpro, for capturing few details from the url used to call the webdynpro application. My client has designed the scenario such that, They have designed thier intranet in dotnet. For accessing the webpage designed,

  • Warehouse Mgmt :: Urgent

    Dear All, I am implementing WH. My query is that lets say i have a material Material : 1998 I have recieved the material in a Storage Bin (01-01-01). System saves the GR date. & If someone wants to use FIFO stock removal strategy then the system uses

  • LO Cockpit in SAP R/3 document

    HI Friends,     I am new to SAP R/3. Can any body please send me the complete document for LO cockpit, LIS Extraction in SAP R/3.   My mail : [email protected] Thanks in Advance DORA

  • Disabling always ontop for wifi pop-up window

    I'm not sure this is the correct forum in do this in, but I have a problem with using the Wifi at my university and the multi-desktop feature of OS X Yosemite. When I log onto my university wifi it comes up with a Safari pop-up window detailing my in

  • Why this message "Could not find layout Default Echo GB"

    Why am I getting the message "Could not find layout Default Echo GB"  i.e. no Reverb effects?