Probs In JSF Binding Expr Using DataTable "var"

Hello,
I'm rendering a dataTable, shown below in pseudocode:
<h:dataTable ... var="chk">
<h:column>
<h:selectBooleanCheckbox binding="mymap[ chk.key ]"/>
</h:column>
</h:dataTable>
Here var corresponds to a custom bean, whose getKey() method returns a string. This string is used as a key into mymap (a HashMap), to retrieve instances of UISelectBoolean.
However, this gives me a runtime error, with the message "javax.servlet.ServletException: Error setting property 'null' in bean of type java.util.HashMap"
The odd thing is if I replace mymap[ chk.key ] with a hardcoded value, say, "100", which is the value of one of the keys, things work fine.
Likewise, if I give mymap a custom property that simply returns a string, say, "100", and write the expression above as mymap[ mymap.egKey ], things work as expected, again.
This makes me wonder whether the variable corresponding to the dataTable's "var" attribute may be used only directly in binding expressions, and not as an indexer as above.
Could somebody shed some light on this, please?
Thank you.
--A                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Change the binding expression to
binding="#{chk.key}"
this should work.

Similar Messages

  • Display images in rows & columns using dataTable in JSF 2.0, netbeans 6.9.1

    Hi,
    I have to display only images on a web page in JSF2.0 in Netbeans. I am using datatable and column to do so. But there is one problem.
    All images are display only in single column(i.e. vertically). I want to display in rows and columns not only column.
    e.g. One row will have atleast 3 images and more rows like this.
    Which attribute should i use of datatable? or should i use some other tag?
    My code is:
    <h:dataTable var="images"
    value="#{jsfMBean.allImages}"
    rules="none"
    cellpadding="20"
    border="0" >
    <h:column>
    <h:graphicImage value="faces/WEB-INF/upload/#{images.picid}" width="300px" height="100px" />
    </h:column>
    </h:dataTable>
    Thanks.
    NetBeans 6.9.1
    JSF 2.0 with facelets
    glassfish 3.0
    Enterprise java beans
    PrimeFaces 3.0

    I believe you are looking for the panelgrid, not the datatable.
    Note that there are a few useful websites online that list the available JSF tags plus their properties, such as these:
    http://www.horstmann.com/corejsf/jsf-tags.html
    http://www.exadel.com/web/portal/jsftags-guide

  • What is JSF and where use it

    hi!
    i dont know what is jsf and where use it
    what different from JSTL
    thanks...

    At this level a visit to JSF-Tutorials (http://www.jsftutorials.net/) might the best thing to do. Or dig into a book.
    Basically it has a different scope than JSTL.
    JSF is a presentation layer framework. Other names in that area are:
    Struts, Spring MVC, Tapestry, and many more
    JSTL is a collection of JSP-tags and therefor covers only a VERY small part of the presentation layer. And it is very far away from a framework
    hth
    Alexander

  • How to fill or bind data using Value Node in Tree Node

    Hi Gurus,
    Can anybody help me on how to fill data or bind data using Value Node in Tree Node View. I know how to create Tree Node but not able to show value on the UI in Tree View.
    Can u please let if anybody has done it?
    Thanks in advance.
    Madhusudan

    continued...
    TRY.
              lv_child = me->node_factory->get_proxy(
                        iv_bo = lv_value_node
                        iv_parent_proxy = me
                        iv_proxy_type = 'ZL_CLASS_CN02' ).
              lv_child->is_leaf = 'X'.
              APPEND lv_child TO rt_children.
            CATCH cx_sy_move_cast_error cx_sy_ref_is_initial.
          ENDTRY.
      In the above code iv_bo , lv_value_node will be the actual object of the second node or leaf node here, which will have the same structure of parent node along with data. After/before this, you would need to build table and refresh in do-prepare_output of IMPL class.In the above code iv_bo , lv_value_node will be the actual object of the second node or leaf node here, which will have the same structure of parent node along with data. After/before this, you would need to buid table and refresh in do-prepare_output of IMPL class.
    ztyped_context->resultlist->build_table( ).
      IF ztyped_context->resultlist->node_tab IS INITIAL.
        ztyped_context->resultlist->refresh( ).
      ENDIF.
    Also the EH_ONEXPAND has to be implemented and event handled in DO_HANDLE_EVENT. But this expand event has to be delegated to context node directly as CL_BSP_WD_CONTEXT_NODE_TREE will already have the implementation.
    ztyped_context->resultlist->expand_node( lv_event->row_key ).
    Where in result list is the node ZL_CLASS_CN00.
    After typing the whole content , i found this blog :). There are few things i have written more that in the blog.  /people/poonam.assudani/blog/2009/06/24/create-a-tree-view-display-in-crm-web-ui
    Regards,
    Karthik

  • One Bind Variable used in multiple VOs jdev 11.1.2.3 redhat 5.8

    Hello:
    I have multiple View Objects and each view object needs to use a bind variable. I would like each VO to reference the same bind variable.
    Example: I have 3 VO and in each VO where clause I need something like emp_key = :p_emp_key, but I want only one bind variable used in each VO. Is this possible?
    So I would like to create one drop down list of values for all the employee names and have all the view objects reference the selected value key of the drop down for employees.
    Each VO should reference the same employee selected.
    What is the best way to accomplish this?
    Thanks much.

    Also, you can try the programatic way if it suits your requirement:
    1. for all 3 VO, make them extend a base class
    2. have a common property with relevant getter and setters in the base class - eg. private String myjob
    3. set this varaible from the view(page/screen - button click/dropdown selection etc) using EL
    4. in each VO using groovy to access the set variables like this -> adf.object.viewObject.myjob
    5. call execute query on requried vo

  • Do some processing before loading jsf fragment created using adf task flow

    Hi,
    I am working on JDev11g.
    I want to create SelectItems of SelectOneChoice dynamically before loading jsf fragment created using adf task flow
    I tried by implementing RegionController class's method RefreshRegion in my backing bean of jsf page fragement to do some processing before loading region
    But it seems to be not feasible approach because it is getting called every time any component on fragement gets partially submitted.
    Is there any method which is called only first time when region is loaded ?
    Or any other solution to achieve this.
    Regards,
    Devang

    Hi,
    don't think so. You would need a phase listener, but I don't see how you get it in. Wha about using a dynamic region and then use the method that is called from the dynamic region first time it is rendered?
    Frank

  • Error : A READ-ONLY bind variable used in OUT or IN-OUT context

    Hi,
    I got error from my report as A READ-ONLY bind variable used in OUT or IN-OUT context in formula column. I already face this problem but at that time i cleared , but now i cont able to do, please give suggestion to this
    regards
    venki

    I find my ERROR in that report, that A READ-ONLY bind variable used in OUT or IN-OUT context is
    when we assign a database column in a placeholder are summary column.
    From that placeholder or summary column will call by formula column
    you might be face that error, But how means
    when that database column , we are assign that decode, case or NVL funtion using else condition as Null you may be face that error.
    Without my knowledge it may seem some other problem also
    without any idea we con't able to clear this error.
    venki

  • How to use call a binding action using Javascript ?

    Hi adf people,
    JDev : 11.1.1.4.0
    How to submit the binding action using the Javascript ?

    what do u mean by submitting the binding action..???
    for javascript you can either use
    af:clientlistener to call javascript
    af:serverlistener to call from javascript to managed bean
    http://download.oracle.com/docs/cd/E12839_01/apirefs.1111/e12419/tagdoc/af_clientListener.html
    http://download.oracle.com/docs/cd/E15523_01/apirefs.1111/e12419/tagdoc/af_serverListener.html
    please tell us if you need any more information.. or explain your question properly..

  • AS3 script to detect spacebar press and score using incremented var

    Hi,
    Continuing work on eLearning project exercise see: http://forums.adobe.com/message/4682999#4682999
    Based on kglad's script there, I am trying to add scoring by detecting a spacebar press when a specific text item is displayed. If the user presses the spacebar while the text is in the text box, then it would increment a variable by +1 (++).
    The script I've written to test this (using 1 var for one type of correct "hit" and a second var for a second type of "hit"), when added to the other script, doesn't work. The Flash debugging player freezes. A trace does not show anything, including incrementing of the variable.
    Here's the script:
    stage.addEventListener(KeyboardEvent.KEY_DOWN,checker);
    var targetHit:int;
    function checker(e:KeyboardEvent){
    while (wordT.text = "3")
       if(e.keyCode==Keyboard.SPACE){
           targetHit++;
           trace(targetHit);
    stage.addEventListener(KeyboardEvent.KEY_DOWN,checker2);
    var distractorHit:int;
    function checker2(e:KeyboardEvent){
       while (wordT.text = "5")
       if(e.keyCode==Keyboard.SPACE){
           distractorHit++;
           trace(distractorHit);
    Any suggestions on fixing this script would be appreciated.

    Thank you for this helpful suggestion.
    By way of explanation:
    If the user sees a specific correct "target" word displayed during the 1000ms that it is displayed in the text box, and they press the spacebar, they would receive a +1 added to a score var (targetHit).
    The exercise also needs to score/keep track of incorrect hits: when the user presses the spacebar when a specific distractor word is displayed during the 1000ms that it is displayed in the text box. This spacebar press would add +1 to the var distractorHit.
    Substituting "if" seems to work.
    Now, with the practice blocks of 16 each working sufficient (can tweak them later), need to move on to a slightly more challenging part of the exercise: the 70-word trial blocks.
    Will close out this posting as "correct" and post a new question related to the more challenging 70-word versions.

  • Setting VO bind variable using session variable

    Hi,
    I need to get/set VO bind variable using ApplicationModuleImple or ViewObjectImple class. Does Any one know how to do it?
    I have one VO based on query like "select name from users where password = :password ". I had a bind variable to it too. now i want to set it from a session scoped variable. can i do it using ADFContext.getCurrent().getSession().get('username'); ? but somehow I am not able to get the knowledge i.e where to set bind variable. please help.

    Timo thanks for the reply, actually I don't want to do it using data control i.e drag and drop method to a page. Instead i just want to set bind variable to a session varable already got from login page.
    I got the following sollotion but don't know where to put them,
    1.
    FacesContext context = FacesContext.getCurrentInstance();
    ValueBinding vb = context.getApplication().createValueBinding("#{data}");
    BindingContext bci = (BindingContext)vb.getValue(context);
    DCDataControl dc = bci.findDataControl("AppModuleDataControl");
    ApplicationModule am = (ApplicationModule)dc.getDataProvider();
    AppModuleImpl service = (AppModuleImpl)am;
    ViewObject vo = service.findViewObject("YourViewObject").setNamedWhereClauseParam("nameBindVariable", objectValue);
    vo.executeQuery();
    what is the #{data} in second line ? if you know please let me know.
    Second Solution :
    2- In backing bean code:
    FacesContext context = FacesContext.getCurrentInstance();
    Application fapp = context.getApplication();
    JUFormBinding adfbc = (JUFormBinding)fapp.createValueBinding("#{bindings}").getValue(context);
    DCIteratorBinding iter = adfbc.findIteratorBinding("YourIterator");
    iter.getViewObject().setNamedWhereClauseParam("nameBindVariable", objectValue);
    iter.executeQuery();
    where would I get "YourIterator" ... ? I am still a new at jdev ... ;)

  • How to use a var as a string

    hello, sorry for my question,
    but I want to use a var as a string:
    I know it is a completely beginners-question, but I didn´t need it until now:
    var zahl = Math.floor((Math.random()*99)+1);
    sym.$("frame")
              .css(
                                  {'background-image':'url("images/zahl.jpg")'
    I tried it with {zahl} and [zahl] but it does not work.
    Help would be great
    Oliver

    Thanks a lot,
    but sorry, I have no sucsess:
    var zahl = Math.floor((Math.random()*99)+1);
    sym.$("frame")
    .css(
                                                                {'background-image':'url("images/" + zahl + ".jpg")'
    here is the whole code again so that you can see if I made a fault.
    THX

  • Problem with binding in h:dataTable

    Hi
    I have a problem with h:dataTable, where the table rows are bound to objects (Bean$Line) nested within a backing bean (Bean).
    JSP:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <html>
      <f:view>
        <head>
          <link href="styles.css" rel="stylesheet" type="text/css"/>
          <title>Sandbox</title>
        </head>
        <body>
          <h:form>
            <h:dataTable value="#{bean.lines}" var="line">
              <h:column>
                <h:outputText value="#{line.id}"/>
              </h:column>
              <h:column>
                <!-- using value = line.lineSelected here works (assuming boolean property Line.lineSelected) --/>
                <h:selectBooleanCheckbox binding="#{line.lineSelected}"/>
              </h:column>
            </h:dataTable>
          </h:form>
        </body>
      </f:view>
    </html>Bean:
    package com.test;
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.component.UISelectBoolean;
    public final class Bean {
      private final List<Line> lines;
      public Bean() {
        lines = new ArrayList<Line>();
        lines.add(new Line("one"));
        lines.add(new Line("two"));
        lines.add(new Line("three"));
      public List<Line> getLines() {
        return lines;
       * Nested class in order to access containing class
       * properties etc.
      public static class Line {
        //private boolean lineSelected = false;
        private UISelectBoolean lineSelected;
        private String id;
        public Line(String id) {
          this.id = id;
        /*public boolean isLineSelected() {
          return lineSelected;
        public void setLineSelected(boolean lineSelected) {
          this.lineSelected = lineSelected;
        public UISelectBoolean getLineSelected() {
          return lineSelected;
        public void setLineSelected(UISelectBoolean lineSelected) {
          this.lineSelected = lineSelected;
        public String getId() {
          return id;
        public void setId(String id) {
          this.id = id;
      } // Line
    }The setup works when I use value="#{line.lineSelected}" (assuming the property is defined as boolean in Bean$Line) but as soon as I use a binding, I get the following exception:
    com.sun.rave.web.ui.appbase.ApplicationException: javax.servlet.ServletException: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'line' resolved to null
    at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.cleanup(ViewHandlerImpl.java:594)
    at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:325)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
    at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
    faces_config:
    <faces-config version="1.2"
                  xmlns="http://java.sun.com/xml/ns/javaee"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd">
      <application>
        <locale-config>
          <default-locale>en_GB</default-locale>
          <supported-locale>en_GB</supported-locale>     
        </locale-config>
      </application>
      <managed-bean>
        <managed-bean-name>bean</managed-bean-name>
        <managed-bean-class>com.test.Bean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    </faces-config>What am I missing here?
    Help much appreciated
    Lance

    Guys
    Thanks a lot, both of your replies are immensely instructive. Maybe a little background on what I'm trying to do. In the table, I have header rows with dependent line rows. When a check box is ticked in the header, I want the corresponding check boxes in the dependent lines to be checked automatically (in slave fashion and ideally without using JavaScript). My idea was to update the bound components (for the lines) from within the Bean (in response to change on the header). However, given there's only a single component for each column in the table, this of course doesn't make sense.
    I'm trying to get to the typical MVC workflow of a) user updates a View component, b) Controller detects the change and updates the Model, c) The Model fires a property change event, which the View detects and updates appropriately. What's the way to achieve this in JSF (by design)?
    Here's a simple fragment (which does not work):
            <h:dataTable value="#{bean.lines}" var="line">
              <h:column>
                <h:outputText value="#{line.id}"/>
              </h:column>
              <h:column>
                <!-- (1) This is the master and (2) should refresh on update here --/>
                <h:selectBooleanCheckbox onchange="submit()" value="#{line.lineSelected}"/>
              </h:column>
              <h:column>
                <!-- (2) This is the slave and I want this to update in response to a change of (1) above --/>
                <h:selectBooleanCheckbox value="#{line.slaveSelected}"/>
              </h:column>
            </h:dataTable>In the setter method for lineSelected, I'm setting slaveSelected to the new value but the View is not refreshing based on this. How do I get the View to update (each dependent line) based on the new values for slaveSelected?
    Thanks again
    Lance

  • How to insert additional column header using dataTable

    Hi everyone, I am using MyFaces 1.1.3, tomahawk 1.1.3, tomahawk-sandbox 1.1.5
    I have to add one column header "Proficiency" as in image [http://www.nabble.com/file/p17206601/screenshot.jpg]
    This is JSF code without "Proficiency":
    <t:dataTable id="data" value="#{commonBean.tableList}" styleClass="standardTable" headerClass="table_header" rowClasses="table_row1, table_row2" columnClasses="standardTable_Checkbox_Column,standard_text,standardTable_Checkbox_Column,standardTable_Checkbox_Column" var="value" preserveSort="true" rows="10" width="100%" border="0" sortColumn="#{commonBean.sortColumn}" sortAscending="#{commonBean.ascending}" cellpadding="2" cellspacing="1" rowIndexVar="tableRowIndex">
         <h:column>
              <f:facet name="header">
                        <h:panelGrid styleClass="table_header2">
                                  <h:outputText value="#{msg['select']}" />
                        </h:panelGrid>
              </f:facet>
              <h:selectBooleanCheckbox id="select" value="#{value.select}" />
         </h:column>
         <h:column>
              <f:facet name="header">
                        <t:commandSortHeader columnName="languageSkill" arrow="true" styleClass="table_header">
                                  <h:outputText value="#{msg['language.skill']}" />
                        </t:commandSortHeader>
              </f:facet>
              <h:commandLink action="#{commonBean.editAction}" actionListener="#{commonBean.editActionListener}">
                        <h:outputText value="#{value.languageSkill}" />
              </h:commandLink>
              <f:param id="object" value="#{value}" />
         </h:column>
         <h:column>
              <f:facet name="header">
                        <h:outputText value="#{msg['spoken']}" />
              </f:facet>
              <h:outputText value="#{value.spokenDescription}" styleClass="standardText"/>
         </h:column>
         <h:column>
              <f:facet name="header">
                        <h:outputText value="#{msg['written']}" />
              </f:facet>
              <h:outputText value="#{value.writtenDescription}" styleClass="standardText"/>
         </h:column>
    </t:dataTable>How to do ?
    Thanks for your help
    Edited by: nvduc82 on May 13, 2008 12:09 PM
    Edited by: nvduc82 on May 13, 2008 8:46 PM

    I see 2 possibilities:
    1. Merge two last columns. And then use panelGrid inside the cells.
    2. Use JSTL and tag forEach. I found it much easy-to-use.

  • DataTable var in request scope?

    Hi all,
    The description for the 'var' attribute of a h:dataTable tag reads:
    "Name of a request-scope attribute under which the model data for the row ... will be exposed."
    So I thought I would be able to access the object set as 'var' in normal JSP expressions and actions:
    <h:dataTable value="#{currentItem.children}" var="item">
      <h:column>
        <h:outputText value="#{item.uri}"/>
        <f:verbatim>${item.uri}</f:verbatim>
      </h:column>
    </h:dataTable>But the ${item.uri} does not evaluate to the same as #{item.uri}. Instead, it is empty, or if 'item' pre-exists in the request scope, it shows that item (and not the one assigned by the dataTable).
    What have I misunderstood?
    Cheers,
    Roger

    Basically:
    JSF<h:dataTable binding="#{myBean.table}" value="#{myBean.list}" var="item">
        <h:column><h:outputText value="#{myBean.value}" /></h:column>
    </h:dataTable>MyBeanprivate HtmlDataTable table;
    private List<Dto> list;
    // + getters + setters
    public String getValue() {
        Dto dto = (Dto) table.getRowData();
        // Do your thing with the current row object.
    }Although I recommend to just add a new property or getter to the DTO. It saves one mapping layer.

  • One more try: inserting 5 rows of data at once in DB, using dataTable

    Defining the datatable columns in the JSF page itself, and not "binding" to any UIData element in a backing bean allows for an update to the list that the datatable points to, which is stored in a request scope bean.
    Defining the datatable columns through the request bean itself, ie, generating it by code, does NOT allow for this update. I have updated it so that each column/input text object will have a unique id that will be the same every time.
    Any reason why?
    Edited by: ayanafridi on Jan 14, 2008 7:09 AM

    Defining the datatable columns in the JSF page itself, and not "binding" to any UIData element in a backing bean allows for an update to the list that the datatable points to, which is stored in a request scope bean.
    Defining the datatable columns through the request bean itself, ie, generating it by code, does NOT allow for this update. I have updated it so that each column/input text object will have a unique id that will be the same every time.
    Any reason why?
    Edited by: ayanafridi on Jan 14, 2008 7:09 AM

Maybe you are looking for