SelectOneListbox with Integer value?

Hello
Maybe I'm stupid... I'm trying to do the following, where #{searchBean.filter.role.code} is of type Integer:
<m:selectOneListbox id="role" size="1"
     value="#{searchBean.filter.role.code}">
     <f:selectItem itemLabel="VN" itemValue="417" />
     <f:selectItem itemLabel="PI" itemValue="415" />
</m:selectOneListbox>
I'm getting the following exception:
java.lang.ClassCastException: java.lang.String
I tried with some converters but could not find a solution. It seems that the value of the selectedItems are String and jsf cannot convert the code to String. But why?
I hope someone can help. Thanks!
Oliver

What is it, the 'm' taglib? Is it the Sun JSF implementation? Why aren't you using the 'h' prefix?
Anyway, the given code should just work, assuming that #{searchBean.filter.role.code} is actually mapped to java.lang.Integer and not null. But I recall some related bugs in one of the ancient JSF RI versions. Which implementation/version are you using? It might be worth upgrading to the latest. If you're using Sun RI 1.0 or 1.1, get the 1.1_02 here: [http://javaserverfaces.dev.java.net]. If your're using Sun RI 1.2 (Mojarra), or if your environment supports Servlet 2.5 / JSP 2.1, then get the latest 1.2 build (currently 1.2_09) from the same site.
Said that, did you know that you can also just use a <h:selectOneMenu /> instead of a <h:selectOneListbox size="1" />? They are both effectively the same.

Similar Messages

  • Formating and operating with integer values

    I am new to XML Publisher.
    I have a task to make a layout using rtf. The problem is that I must do an arithmetical operation using data generated from a system report. I must not modify the report!!!
    The value retrieved from report is of X.Y format which means a time period (X - years, Y - months). So I want to split this value in two - one for years and other for months with a posibility of making arithmetical operations over them. Is it possible?? And if so, cand anybody give me a solution for this...?

    ok, back to the problem. As I red in the XML Publihser Users Guide there is a posibility to transform strings in numbers, but I can't figure out how it works! As speaking of my problem I can not do arithmetical operations with that value (YEARS.MONTHS). I tried the to_number function described in XML Publisher User's Guide (page 7-3) over the vlaue x.y, I tried to change the point (x.y) to a comma (x,y) and again aply to_number function over resulted value, but it doesn't work. What do I do wrong?
    I tried the solution of spliting the x from y, but I run into a problem again. The years part x has a variable length so I can't get the y part. (the substr function didn't worked with negative start position - substr(DATE, -3, 3))
    Generaly I'm a very confused about XML Publisher. There are examples in User's Guide which didn't work for me...
    If anybody has some links with documentation about XML Publisher, other than those from ORACLE, please share them with me.
    10x!

  • Vision DevMod: How to create large Gaussian filter kernels with integer values like Vision Assistant uses

    Hello,
    in Vision Assistant it is possible to create filter kernel of arbitrary size, like e.g. a 75x75 Gaussian kernel. These kernels feature integer-only elements. I tried to find a function in the Vision Development Module, but have been unable to find something so far. So I still create a Vision Assistant script with such a kernel and export it to a LabVIEW VI in order to abtain such a kernel. Any ideas on how to create such kernels programmatically?

    -You can generate custom kernels in LabVIEW also, but you need to have either string or numerical of that kernels. Without these two, i am not sure of how to do this.
    -Please check this for building kernels.
    http://zone.ni.com/reference/en-XX/help/370281M-01​/imaqvision/imaq_buildkernel/
    -Let's say you are able to programmatically generate kernel string, it will convert to kernel in double format automatically and connect this to convolute vi.
    Thanks
    uday,
    Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
    Certified LabVIEW Associate Developer (CLAD) Using LV13

  • Help with passing integer value in A.S.S

    I get an NSinternal script error while trying to pass this value can anyone help?
    Also I wonder if it is possible to pass the value to a matrix
    on clicked theObject
    tell button "checkbox" of window 1
    if integer value = 1 then
    set button "checkbox2" of window 1 to integer value = 1
    else
    set integer value to 0
    end if
    end tell
    end clicked
    I also tried:
    if state of button "checkbox" of window1 is 1 then
    set the state of button "checkbox2" of window1 to 1
    end if
    Message was edited by: Doug Bassett

    I've been following this thread and trying to figure out how to make this work. I was getting inconsistent results or errors with most of the code that has been posted. But I finally got it working... at least on a Leopard machine (not sure if this could have changed between Tiger and Leopard so your mileage may vary).
    What I found was that a checkbox button that's located directly in a window seems to have a state that's equal to 0 when it's unchecked and 1 when it's checked. But a checkbox cell that's contained within a matrix seems to have a state that's set to either _off state_ or _on state_. Trying to set a cell's state to 0 or 1 simply wasn't working right for me. So I get the state of the "selectall" checkbox button (which is a 0/1) and transform it to either "off state" or "on state" before setting the states of the checkbox cells in the matrix.
    Here's my code:
    on clicked theObject
    set n to name of theObject
    if n = "selectall" then
    set s to state of theObject
    log "state: " & s
    if s = 0 then
    set newState to off state
    else
    set newState to on state
    end if
    repeat with i from 1 to count of cells of matrix "directories" of window "main"
    tell cell i of matrix "directories" of window "main"
    set state to newState
    end tell
    end repeat
    return
    end if
    if n = "logStatesBtn" then
    logStates()
    return
    end if
    end clicked
    on logStates()
    log "Logging states:"
    set s to state of button "selectall" of window "main"
    log "selectall checkbox: " & s
    repeat with i from 1 to count of cells of matrix "directories" of window "main"
    tell cell i of matrix "directories" of window "main"
    set s to state
    end tell
    log "Cell " & i & ": " & s
    end repeat
    end logStates
    Note the "logStates" handler is just something I connected up to a "logStatesBtn" button in my window that lets me spit out the states of all the checkboxes into the console log. This is how I actually discovered that the cells were set to "off state" or "on state".
    Steve

  • Convert an integer value that was created with the Excel DATEVALUE formula to a valid date?

    Hello everyone,
    How can I convert an integer value that was created with the Excel DATEVALUE formula to a valid date in SSIS?
    Is this even possible?
    For example:
    =DATEVALUE("8/22/2008") will format the cell to display 39682.
    Reading the column as a string to get the int value (39682) - how can I turn this into a valid date using SSIS and then importing the real date to sql server?
    Thank you!

    You can use Script component for this and convert your integer values to Date. An example here is following:
    CultureInfo provider = CultureInfo.InvariantCulture;
    string dateString = "08082010";
    string format = "MMddyyyy";
    DateTime result = DateTime.ParseExact(dateString, format, provider);
    Source: http://stackoverflow.com/questions/2441405/converting-8-digit-number-to-datetime-type
    Vikash Kumar Singh || www.singhvikash.in

  • Initialize class level constant integer with negative values

    Hi,
    While initializing constant integer with -1, the actual value while calling the setter with this value is set to 1-
    Even in the debugger when i view the value its 1-
    Has anybody come across similar proglem? Any help?
    Thanks,
    Piyush

    Hi,
    Thanks for the reply.
    The problem is i'm creating a XML out of this constant and when this value is assigned to a string, the string value is represented as "1-" and further with this value the XML is created.
    Can i try something else here?
    Thanks,
    Piyush

  • 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]

  • Passing multiple integer values as parameter in SSRS

    Hello,
    I am trying to pass a comma separated multiple integer value parameter in SSRS report and it errors out complaining that it is not able to convert the nvarchar value to datatype int. But it works fine when I pass a single value. Here is the code I am using
    for the report and I am stuck at passing multiple values.
    SELECT
    id,count(*) as cnt
    from table
    and ID in (@id) group by id
    eg: if I pass 10,20,30 then I would get error however if I pass 10 then it works fine
    Is there a different method to pass multiple integer values?
    Thanks for your help.

    A comma is, of course, a textual character and not an integer, thus the error you are getting. Multi-value parameters can be used for this.
    Select "Allow multiple values"and set data type to Integer. Multi-value parameters deliver the values as an array. The query interface is smart enough to convert them to the proper syntax (comma-delimited) automatically so a statement like:
    WHERE Field IN (@id)
    where the parameter has an array of values {1, 2, and 3} is interpreted as:
    WHERE Field IN (1,2,3)
    You do not need to manually convert it in a transact SQL query. That is not the case for displaying the value array in your report. If you wish to display the array (described above) in your report as "1, 2, 3", you will need to use a join expression:
    =Join(@id, ", ")
    As DJ described, the other part to a multivalue parameter is the Available values. These can be set explicitly but given your example, I think it would be best to create a new dataset that retrieves a distinct list of the IDs that can be retrieved, perhaps
    something like:
    SELECT DISTINCT GroupName, GroupID
    FROM table
    WHERE [criteria]
    Set the available values to use this query with GroupName (or whatever user-friendly field you choose for your dataset) as the label and the id as the value. The label field should be something the the target report user can easily identify the correct group
    using.
    If you don't want to or can't use a multivalue parameter for some reason then you will need to manipulate your parameter value prior to consuming it in your query. When you add the parameter to the TSql query and save the dataset, SSRS adds it to the Parameters
    property of the dataset. Open the dataset properties and select the parameters tab. You should see your parameter in the list. click the expression builder (fx) button next to the value and enter this expression:
    =Split(@id,",")
    Note that the second element of the expression is the delimiter. If your text input has comma-space as a delimiter (1, 2, 3 vs 1,2,3) then that element must include ", ". My example just has comma so if you use that with a string "1, 2, 3"then
    the resulting array will still have 3 elements but the 2nd and 3rd elements of the array will have a preceding space which will cause your dataset to error with the same error. As long as there are no non-numeric characters in any of the elements, the split6
    will create the text array, SSRS will dynamically generate the correct "IN"syntax (comma separated) and SQL will convert the elements from VARCHAR to INT on the fly.
    "You will find a fortune, though it will not be the one you seek." -
    Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

  • How to set a default integer value in a form

    I have a form defined as follows:
    =================================================
    public static class ProjectForm extends FormData
    private int idx;
    private String name;
    private String projectNumber;
    private String description;
    public void setIdx(int index)
    this.idx = idx;
    public int getIdx(){
    return this.idx;
    public void setName(String name)
    this.name = name;
    public String getName()
    return this.name;
    public void setDescription(String description)
    this.description = description;
    public String getDescription()
    return this.description;
    public void setProjectNumber(String projectNumber)
    this.projectNumber = projectNumber;
    public String getProjectNumber()
    return this.projectNumber;
    ======================================================
    When I add a new entry into the database, I have no issues. However, when I want to modify an entry I run into some issues with the idx entry. For some reason, I cannot set a default value into the netui:label tag. My jsp code is as follows:
    ===================================================
    <tr valign="top">
    <td>
    Index:
    </td>
    <td>
    <netui:label value="{actionForm.idx}"
    defaultValue="{pageFlow.project.idx}"/>
    </td>
    </tr>
    <tr valign="top">
    <td>
    Name:
    </td>
    <td>
    <netui:textBox dataSource="{actionForm.name}"
    defaultValue="{pageFlow.project.name}"/>
    </td>
    </tr>
    <tr valign="top">
    <td>
    ProjectNumber:
    </td>
    <td>
    <netui:textBox dataSource="{actionForm.projectNumber}"
    defaultValue="{pageFlow.project.projNum}"/>
    </td>
    <tr valign="top">
    <td>
    Description:
    </td>
    <td>
    <netui:textBox dataSource="{actionForm.description}"
    defaultValue="{pageFlow.project.description}"/>
    </td>
    </tr>
    ======================================================
    The the project class is passes into the page and has the appropriate values. The name, project number and description fields work as I would expect. However, the idx value is alway '0'. If I print out pageFlow.project.idx it has the correct value.
    How do I fix this? My feeling is that it is related to the form field being an int and not a string. The default parameter indicates that is only works with null values, and ints default to zero. Do I need to use an Integer value instead in the form, or just stay away from non-string form fields.
    Thank for the help!!
    --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    In the action which displays the edit page just set the form idx value before displaying the jsp.

  • Populating select list in a JSP with enumeration values

    I'm working on a JSP in which I need to populate a select list with enumeration values.
    Everytime I'm trying to insert these values (using enum.nextElement()) in a select box only the first enumerated value gets inserted correctly, the rest of the values shows up outside the select list. I would appreciated any help...thanks!!!

    I'm not exactly sure how your generating your list to begin with, however the following code will work:
    <form>
    <select>
    <%
         java.util.Vector v = new java.util.Vector();
         for(int i=0;i<12;i++){
              v.addElement(new Integer(i));
         java.util.Enumeration enum = v.elements();
         while(enum.hasMoreElements()){
         Object obj = enum.nextElement();
         out.println("<option name='"+obj+"'>"+obj+"</option>");
    %>
    </select>
    </form>Anthony
    BTW does anyone know why the greater than symbol never renders properly in these forums when text is encapsulated in the code tag?
    pre:
    >code:
    >

  • Wanna send integer value by reference in function

    I wanna send integer value by reference thro' function. Here's the code going.
    class test
    basic b = new basic();
    test()
    test2.Fuction(b.value);
    class basic
    int value;
    basic(){}
    //////here i want value to be affected by Function.I don't want it affected by value, but by reference.
    class test2
    public static void Function(int value)
    value++;

    If you want to update the value in your b object, then you have to pass the reference of that object to test2.Function(..). Here is one way to do it:
    class test {
      basic b = new basic();
      test() {
        test2.Function(b);
    class test2 {
      public static void Function(basic b) {
        b.value++;
    }It's a good idea to follow the java naming convention. Classes should begin with an upper case letter. Methods and variable names with a lover case letter (but final static variables with all upper case letters).

  • Large integer values

     

    You could use DecimalData with scale 0.
    Alexis Hassler
    OOsphere France
    (33) 4 37 49 01 28
    -----Message d'origine-----
    De: Kasrul Islam [SMTP:kasrul.islamchordiant.com]
    Date: vendredi 3 mars 2000 21:04
    A: kamranaminyahoo.com
    Objet: (forte-users) Large integer values
    Hi,
    Can anyone out there help with a little problem, I have string of numbers
    that I have extracted out of a file, the numbers are all over 10 digits
    when I try to convert this string into a Integer the number gets changed to
    something weird for example.
    Txt : TextData = new(Value = '12345');
    mInt : IntegerData = new(Value = Txt.IntegerValue);
    this works fine but when I try a number like this :
    Txt : TextData = new(Value = '951475978067');
    mInt : IntegerData = new(Value = Txt.IntegerValue);
    then I get the following value in my integerdata object : 2147483647 any
    help will be appreciated, I really need to get the above value as an
    integer because I need to do some calculations with it.
    Thanks in advance.
    Kasrul Islam.
    << Fichier: ATT00000.html>>

  • ReportQuery on Integer Values

    Toplink seems to be inconsistent with SQL aggregate functions when running a report query on an integer field.
    My code is similar to this:
    // Toplink version 9.0.4.2
    ReportQuery report = new ReportQuery(Person.class);
    ExpressionBuilder builder =
    report.getExpressionBuilder();
    report.addAverage("id-ave",builder.get("id"));
    report.addMinimum("id-min",builder.get("id"));
    report.addMaximum("id-max",builder.get("id"));
    report.addStandardDeviation("id-std",builder.get("id"));
    report.addSum("id-sum",builder.get("id"));
    report.addVariance("id-var",builder.get("id"));
    results = session.executeQuery(toplinkQuery);
    After running a report, Toplink returns all of the requested values as java.lang.Integer types.
    This is not a problem for sum, min, and max, because these values should always be integers. But for average, variance, and standard deviation, floating point values are a likely result. The Toplink returned integer values are rounded down to the nearest whole number.
    Running the equivalent SQL on Oracle 9i returns floating point results. The SQL is something like
    SELECT AVG(ID), MIN(ID), MAX(ID), STDDEV(ID), SUM(ID), VARIANCE(ID) FROM PERSON
    Is this the defined behavoir of Toplink, or is it a bug? I haven't tried the SQL on different database vendors. Maybe the SQL executes differently for other vendors and Toplink chose integer values so that results would be consistent. But I have not seen any documentation indicating so.
    -J

    Yes this is an issue with ReportQuery, currently it tries to convert the values to their attribute type, but should not be doing so for these functions.
    I have logged this problem internally, but if you need a solution to the problem, please contact Oracle support.
    Workarounds would be:
    - In you DatabaseLogin turn off data-optimization, i.e. login.dontUseDataOptimization();
    - Use custom SQL with the report query, or a DataReadQuery.

  • Integer values and decimal values in weblient UI - Display mode

    Hello,
    i have developed an custom assignmentblock with some custom fields.
    Some of this fields are integer values and text values.
    Some other fields are decimal values.
    I face the issue that this decimal values are in display mode  right-aligned all other fields are left-aligned.
    In edit mode all values are right-alligned.
    How can i change this behaviour? All values left-alligned in display mode!
    Otherwise this looks strange.
    Thank you
    Kind regards
    Manfred

    Hi,
    Decimal values will be displayed right-aligned. To change that you need to modify the GET_M method.
    In get_m method, you have to change the attr datatype to string.
    Data: attr type string.
    Data: dref type ref to data.
    Get reference of attr into dref.
    Regards,
    Arun
    Edited by: Arun Kumar on May 14, 2010 3:03 PM

  • Adding a listener to an integer value?

    Hello All
    Is there a way of adding a listener to an integer value that produce an event (run a method with the object) when an integer value is changed? (Through a object.setValue(int) for example)
    Thanks for any help,
    Harold Clements

    Can any of the kilo-posters (that's with two o's) say if it's considered
    bad form to reuse a class that already exists - albeit for a slighty
    different purpose? What I'm thinking is that the SpinnerNumberModel
    is rather close to what's being looked for - the differences being that
    it'll handle any Numbers and has a "next" functionality that we ignore.
    Something like:import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Random;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.SpinnerNumberModel;
    import javax.swing.event.ChangeEvent;
    import javax.swing.event.ChangeListener;
    public class NumberEg extends JFrame {
         private SpinnerNumberModel intModel;
         private Random rand = new Random();
         private JLabel aLabel;
         public NumberEg() {
                   // a thing that responds to changes - there could be
                   // many of these
              aLabel = new JLabel("I respond to changes...");
              add(aLabel, BorderLayout.CENTER);
                   // the thing which changes
              intModel = new SpinnerNumberModel(0, null, null, 0);
                   // a change listener which glues the two previous
                   // together - again there could be a number of these
              intModel.addChangeListener(new ChangeListener(){
                   public void stateChanged(ChangeEvent evt) {
                        aLabel.setText(intModel.getValue().toString());
                   // Meanwhile events like button clicks *cause* the
                   // changes
              JButton but = new JButton("Click me!");
              but.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt) {
                        intModel.setValue(rand.nextInt());
              add(but, BorderLayout.NORTH);
              but = new JButton("Reset");
              but.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt) {
                        intModel.setValue(0);
              add(but, BorderLayout.SOUTH);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              pack();
         public static void main(String args[]) {
              NumberEg test = new NumberEg();
              test.setVisible(true);
    }

Maybe you are looking for