Jsf 2 nested datatable rerender issue

Hi All,
I'm struggling with a nested datatable rerender issue, which I can't seem to solve.
Here's the situation: I have this datatable which iterates over serverinstances. For each serverinstance, I then iterate over it's urls. This all works fine.
Now I want to add a new url for that serverinstance, so under the datatable, there's an input form.
When submitted, the url is added to the serverinstance and updated (via backing bean).
The only problem is, that the (nested) datatable is not rerendered. I can see the update working fine, because the url is added in the database.
If I do the same thing in a one-level, unnested datatable, it works fine. I suppose the nesting is the problem here.
Here's the (simplified) code:
          <h:form id="appurlform">
<h:dataTable var="serverinstance" value="#{_AddUrls.app.sortedServerInstance}" >
<h:column>
<h:dataTable var="_appurl" value="#{serverinstance.appUrl}">
<h:column><h:outputText value="#{_appurl.appurl}"/></h:column>
</h:dataTable>
</h:column>
</h:dataTable>
</h:form>
<h:form id="newappurlform" prependId="false">
<h3><h:outputText value="New Monitored Url"/></h3>
<table>
<tr>
<td>Url: </td>
<td>
<h:inputText id="newappurl_url" value="#{_AddUrls.newAppUrl.appurl}"/>
</td>
</tr>
</table>
<h:commandButton id="submitappurl" value="Add Url"
onclick="jsf.ajax.request(this, event,
{execute:'newappurl_url',
render:'appurlform'}); return false;"
actionListener="#{_AddUrls.addAppUrl}">
</h:commandButton>
</h:form>

Hi All,
I'm struggling with a nested datatable rerender issue, which I can't seem to solve.
Here's the situation: I have this datatable which iterates over serverinstances. For each serverinstance, I then iterate over it's urls. This all works fine.
Now I want to add a new url for that serverinstance, so under the datatable, there's an input form.
When submitted, the url is added to the serverinstance and updated (via backing bean).
The only problem is, that the (nested) datatable is not rerendered. I can see the update working fine, because the url is added in the database.
If I do the same thing in a one-level, unnested datatable, it works fine. I suppose the nesting is the problem here.
Here's the (simplified) code:
          <h:form id="appurlform">
<h:dataTable var="serverinstance" value="#{_AddUrls.app.sortedServerInstance}" >
<h:column>
<h:dataTable var="_appurl" value="#{serverinstance.appUrl}">
<h:column><h:outputText value="#{_appurl.appurl}"/></h:column>
</h:dataTable>
</h:column>
</h:dataTable>
</h:form>
<h:form id="newappurlform" prependId="false">
<h3><h:outputText value="New Monitored Url"/></h3>
<table>
<tr>
<td>Url: </td>
<td>
<h:inputText id="newappurl_url" value="#{_AddUrls.newAppUrl.appurl}"/>
</td>
</tr>
</table>
<h:commandButton id="submitappurl" value="Add Url"
onclick="jsf.ajax.request(this, event,
{execute:'newappurl_url',
render:'appurlform'}); return false;"
actionListener="#{_AddUrls.addAppUrl}">
</h:commandButton>
</h:form>

Similar Messages

  • JSF Nested Datatable , ValueExpression

    Hi, I'm working on an application which is going to use a nested datatable.
    basically I generate 1 datatable which consist of 7 columns , 5 rowsItems and for each column I generate a datatable to handle the data.
    I make a List from RowItems and bind it to my datatable by wrapping it in a datamodel
    the rowItem class consist of 7 List for each column which will be binded to each nested datatable using ValueExpression
    So now the problem is:
    I couldnt get the name for each display, I'm getting error message could not find property "name" for class String.
    output_name.setValueExpression("value", createValueExpression("#{displaycolVar.name}", String.class));but I can get the working unit displayed correctly
    output_workingunit.setValueExpression("value", createValueExpression("#{RowItemsVar.workingtime}", String.class));can someone help me on this problem?
    Thanks in advance
    my code
    calendar.java
    package demo;
    import java.util.ArrayList;
    import javax.el.ValueExpression;
    import javax.faces.component.UIOutput;
    import javax.faces.component.html.HtmlOutputText;
    import javax.faces.context.FacesContext;
    import javax.faces.model.ListDataModel;
    import org.ajax4jsf.org.w3c.tidy.TagTable;
    import org.richfaces.component.*;
    import org.richfaces.component.html.HtmlDataTable;
    import org.richfaces.component.html.HtmlColumn;
    public class Calendar
         // Table Properties
         private String[] days = {"Working Time","Monday","Tuesday","Wednesday","Thursday","Freiday","Saturday","Sunday"};
         private String[] workingunit = {"8:00-8:45","8:45-9:30","9:30-10:15","10:15-11:00","11:00-11:45"};
         private int column; // number of columns
         private int row; // number of rows
         // Main List to store the values
         private ArrayList<RowItems> RowItemList;
         // Datatable backing bean Component
         private UIDataTable calendarDatatable;
         // Constructor
         public Calendar()
              // Initializing row and column
              column = 7;
              row = 5;
              // Initializing Datatable
              calendarDatatable = new HtmlDataTable();
              calendarDatatable.setVar("RowItemsVar");
              calendarDatatable.setRendered(true);
              // Creating List of RowItems
              RowItemList = new ArrayList<RowItems>();
              // Adding rows to the List
              for(int i = 0;i<row;i++)
                   RowItemList.add(new RowItems(workingunit,column,i));
              // Creating creating 7 columns for each day + name column
              for(int i = 0; i <column+1; i++)
                   UIColumn column = new HtmlColumn();
                   UIOutput header = new HtmlOutputText();
                   // Initializing column and header
                   header.setValue(days[i]);
                   column.setHeader(header);
                   // the first column doesn't need a datatable
                   if(i == 0)
                        // Display data
                        HtmlOutputText output_workingunit = new HtmlOutputText();
                        output_workingunit.setValueExpression("value", createValueExpression("#{RowItemsVar.workingtime}", String.class));
                        column.getChildren().add(output_workingunit);
                        System.out.println("\n"+output_workingunit.getValueExpression("value"));
                   else      
                        // Create datatable for each column
                        UIDataTable datatable_nested = new HtmlDataTable();
                        datatable_nested.setVar("displaycolVar");               
                        datatable_nested.setRendered(true);
                        UIColumn column_for_nestedDT = new HtmlColumn();
                        // Display data
                        HtmlOutputText output_name = new HtmlOutputText();
                        output_name.setValueExpression("value", createValueExpression("#{displaycolVar.name}", String.class)); // <- it wont just find the property
                        // add outputtext for each column in nested datatable
                        column_for_nestedDT.getChildren().add(output_name);
                        // Add a column for each nested datatable
                        datatable_nested.getChildren().add(column_for_nestedDT);
                        * the expression value is correct I checked through println
                        switch(i)
                             case 1: datatable_nested.setValueExpression("value", createValueExpression("#{RowItemsVar.displaylist_col1}", String.class));
                                       break;
                             case 2:     datatable_nested.setValueExpression("value", createValueExpression("#{RowItemsVar.displaylist_col2}", String.class));
                                       break;
                             case 3:     datatable_nested.setValueExpression("value", createValueExpression("#{RowItemsVar.displaylist_col3}", String.class));
                                       break;               
                             case 4:     datatable_nested.setValueExpression("value", createValueExpression("#{RowItemsVar.displaylist_col4}", String.class));
                                       break;
                             case 5:     datatable_nested.setValueExpression("value", createValueExpression("#{RowItemsVar.displaylist_col5}", String.class));
                                       break;
                             case 6: datatable_nested.setValueExpression("value", createValueExpression("#{RowItemsVar.displaylist_col6}", String.class));
                                       break;
                             case 7:     datatable_nested.setValueExpression("value", createValueExpression("#{RowItemsVar.displaylist_col7}", String.class));
                                       break;                    
                        // Add the nested datatable to each column
                        column.getChildren().add(datatable_nested);
                   // Adding each column to highest entity of datatable
                   // 7 column will be added because there is 7 datatable
                   calendarDatatable.getChildren().add(column);
              // Test data
              RowItemList.get(0).getDisplaylist_col1().add(new Display("danny",1,1));
              // Datamodel for the highest entity of datatable
              ListDataModel<RowItems>RowItemsDM = new ListDataModel<RowItems>();
              // Wrapp the data from ArrayList into DataModel object
              RowItemsDM.setWrappedData(RowItemList);
              // Adding datamodel to highest entity of datatable
              calendarDatatable.setValue(RowItemsDM);
         public UIDataTable getCalendarDatatable() {
              return calendarDatatable;
         public void setCalendarDatatable(UIDataTable calendarDatatable) {
              this.calendarDatatable = calendarDatatable;
    // Methode to create a ValueExpression
    private ValueExpression createValueExpression(String valueExpression, Class<?> valueType)
    FacesContext facesContext = FacesContext.getCurrentInstance();
    return facesContext.getApplication().getExpressionFactory().createValueExpression(
    facesContext.getELContext(), valueExpression, valueType);

    RowItems.java
    package demo;
    import java.util.ArrayList;
    * Class to represent each column
    public class RowItems
         private String workingtime;
         private int col;
         private int index;
         // List of list for each column     
         private ArrayList<Display> displaylist_col1 = new ArrayList<Display>();
         private ArrayList<Display> displaylist_col2 = new ArrayList<Display>();
         private ArrayList<Display> displaylist_col3 = new ArrayList<Display>();
         private ArrayList<Display> displaylist_col4 = new ArrayList<Display>();
         private ArrayList<Display> displaylist_col5 = new ArrayList<Display>();
         private ArrayList<Display> displaylist_col6 = new ArrayList<Display>();
         private ArrayList<Display> displaylist_col7 = new ArrayList<Display>();
         // Constructor
         public RowItems (String workingtime, int col, int index)
              this.workingtime = workingtime;
              this.col = col;
              this.index = index;
         // Getter & Setter
         public String getWorkingtime() {
              return workingtime;
         public void setWorkingtime(String workingtime) {
              this.workingtime = workingtime;
         public int getCol() {
              return col;
         public void setCol(int col) {
              this.col = col;
         public void setIndex(int index) {
              this.index = index;
         public int getIndex() {
              return index;
         public ArrayList<Display> getDisplaylist_col1() {
              return displaylist_col1;
         public void setDisplaylist_col1(ArrayList<Display> displaylist_col1) {
              this.displaylist_col1 = displaylist_col1;
         public ArrayList<Display> getDisplaylist_col2() {
              return displaylist_col2;
         public void setDisplaylist_col2(ArrayList<Display> displaylist_col2) {
              this.displaylist_col2 = displaylist_col2;
         public ArrayList<Display> getDisplaylist_col3() {
              return displaylist_col3;
         public void setDisplaylist_col3(ArrayList<Display> displaylist_col3) {
              this.displaylist_col3 = displaylist_col3;
         public ArrayList<Display> getDisplaylist_col4() {
              return displaylist_col4;
         public void setDisplaylist_col4(ArrayList<Display> displaylist_col4) {
              this.displaylist_col4 = displaylist_col4;
         public ArrayList<Display> getDisplaylist_col5() {
              return displaylist_col5;
         public void setDisplaylist_col5(ArrayList<Display> displaylist_col5) {
              this.displaylist_col5 = displaylist_col5;
         public ArrayList<Display> getDisplaylist_col6() {
              return displaylist_col6;
         public void setDisplaylist_col6(ArrayList<Display> displaylist_col6) {
              this.displaylist_col6 = displaylist_col6;
         public ArrayList<Display> getDisplaylist_col7() {
              return displaylist_col7;
         public void setDisplaylist_col7(ArrayList<Display> displaylist_col7) {
              this.displaylist_col7 = displaylist_col7;
    }display.java
    package demo;
    public class Display
         private Person person;
         private String name;
         private int x;
         private int y;
         public Display(String name, int x, int y)
              this.person = new Person(name);
              this.name = name;
              this.x = x;
              this.y = y;
         public String getName() {
              return name;
         public void setName(String name) {
              this.name = name;
         public Person getPerson() {
              return person;
         public void setPerson(Person person) {
              this.person = person;
         public int getX() {
              return x;
         public void setX(int x) {
              this.x = x;
         public int getY() {
              return y;
         public void setY(int y) {
              this.y = y;
    }

  • Command link from nested datatables

    I have nested datatables that work, but I need to be able execute an actionListener from a h:commandLink and reference the item that is being clicked. The example below works except that it always returns the items in the last category. So that if the 2nd item in the first category is clicked, the 2nd item of the last category is returned. I tried binding my dataTables to UIData objects on my managed bean so that I could call getRowData() but I cannot find a way to bind the embedded h:dataTable when I don't know how many to expect.
    Here is the code (stripped down for simplicity):
    <h:dataTable value="#{bean.categories}" var="category">
        <h:column>
            <h:outputText value="#{category.name}" styleClass="txtTitle"/>
            <h:dataTable value="#{category.items}" var="item">
                <h:column>
                    <h:commandLink actionListener="#{bean.activate}">
                        <h:outputText value="#{item.name}"/>
                        <f:param name="activate" value="#{item}"/>
                    </h:commandLink>
                </h:column>
            </h:dataTable>
        </h:column>
    </h:dataTable>
    =====================================================
    public class ManagedBean {
        private List categories;
        private Item activeItem;
        public void activate(ActionEvent e) {
            UICommand command = (UICommand)e.getComponent();
            List children = command.getChildren();
            for (Iterator i = children.iterator(); i.hasNext(); ) {
                UIComponent child = (UIComponent) i.next();
                if (child instanceof UIParameter) {
                    UIParameter param = (UIParameter)child;
                    if (param.getName().equals("activate")) {
                        this.activeItem = (Item)param.getValue();
                        break;
        public List getCategories() {
            return categories;
        public void setCategories(List categories) {
                this.categories = categories;
        public Item getActiveItem() {
            return activeItem;
        public void setActiveItem(item activeItem) {
                this.activeItem = activeItem;
    }

    bump

  • Nested dataTable bug?

    I�m having a problem with nested dataTables. The complete source code is attached.
    My backing bean has properties keys and map. Keys is an array of strings. Map is a map keyed off keys with string array values.
    The faces jsp creates a table with one row per key. The key is displayed in the first column and the second column holds another table displaying the elements of the corresponding map entry.
    Various command links with nested <f:param> elements are in the cells and footers of the nested table. The parameter values reference the var property of either the inner or outer tables. All command links reference the same action listener which prints the value of the parameter to stdout.
    Clicking on outer var always works.
    Clicking on inner var yields the correct result only if you are in the last row of the outer table.
    Clicking once on any of the footer link command links causes the action listener to be invoked once for each row of the outer table.
    Have I found a bug, am I doing something wrong, or is this functionality not supported?
    Any help appreciated.
    Nick
    Backing Bean Source:
    package test;
    import java.util.*;
    import javax.faces.component.UIParameter;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ActionEvent;
    public class NestedTableBean {
         private Map map;
         private String[] keys;
         public NestedTableBean() {
              keys = new String[]{"1", "2", "3"};
              map = new HashMap();
              map.put(keys[0], new String[]{"1a", "1b", "1c"});
              map.put(keys[1], new String[]{"2a", "2b", "2c"});
              map.put(keys[2], new String[]{"3a", "3b", "3c"});
         public Map getMap() {
              return map;
         public String[] getKeys() {
              return keys;
         public void doIt(ActionEvent actionEvent) {
              String param = null;
             List children = actionEvent.getComponent().getChildren();
             for (int i = 0; i < children.size(); i++) {
               if (children.get(i) instanceof UIParameter) {
                 UIParameter currentParam = (UIParameter) children.get(i);
                 if (currentParam.getName().equals("param") &&
                     currentParam.getValue() != null) {
                   param = currentParam.getValue().toString();
                   break;
             FacesContext context = FacesContext.getCurrentInstance();
             String id = actionEvent.getComponent().getClientId(context);
             System.out.println("In doIt(), component id: "+id+", param: "+param);
    }Faces JSP Source:
    <h:dataTable border="2" value="#{nestedTable.keys}" var="outerVar">
    <h:column>
      <h:outputText value="#{outerVar}"/>
    </h:column>
    <h:column>
      <h:dataTable  border="1" value="#{nestedTable.map[outerVar]}" var="innerVar">
       <h:column>
        <h:panelGrid columns="3">
         <h:outputText value="#{innerVar}"/>
         <h:commandLink actionListener="#{nestedTable.doIt}">
          <h:outputText value="outerVar"/>
          <f:param name="param" value="#{outerVar}"/>
         </h:commandLink>
         <h:commandLink actionListener="#{nestedTable.doIt}">
          <h:outputText value="innerVar"/>
          <f:param name="param" value="#{innerVar}"/>
         </h:commandLink>
        </h:panelGrid>
       </h:column>
       <f:facet name="footer">
        <h:panelGrid columns="2">
         <h:commandLink actionListener="#{nestedTable.doIt}">
          <h:outputText value="footer link"/>
          <f:param name="param" value="#{outerVar}"/>
         </h:commandLink>
        </h:panelGrid>
       </f:facet>
      </h:dataTable>
    </h:column>
    </h:dataTable>

    Hello,
    I have the same problem, when I use an nested dataTable the ActionEvent of the Second dataTable get always the Last Row of the First dataTable.
    The complete code :
    -=-=-=-=-=-=-=-=-=-=-=-=- PAGE.JSP -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    <h:dataTable id="categorias" var="categoria" value="#{UserBean.allCategorias}">
        <h:column>
            <h:dataTable id="items" var="item" value="#{categoria.items}">
               <f:facet name="header">
                   <h:outputText value="#{categoria.nome}" />
               </f:facet>
               <h:column>
                   <f:facet name="header">
                       <h:outputText value="Item" />
                   </f:facet>
                   <h:outputText value="#{item.nome}" />
               </h:column>
               <h:column>
                   <f:facet name="header">
                       <h:outputText value="Qtd Solicitada" />
                   </f:facet>
                    <h:outputText value="#{item.qtdSolicitada}" />
                </h:column>
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Qtd Recebida" />
                </f:facet>
                <h:outputText value="#{item.qtdEfetivada}" />
             </h:column>
              <h:column>
                  <h:panelGrid columns="2">
                      <h:inputText id="selected" size="5" />
                      <h:commandButton id="confirmar" immediate="true" image="images/confirmar_1.gif" actionListener="#{UserBean.processAction}">
                          <f:param id="itemId" name="id" value="#{item.nome}" />
                      </h:commandButton>
                  </h:panelGrid>
             </h:column>
         </h:dataTable>
    </h:column>
    </h:dataTable>-=-=-=-=-=-=-=-=-=-=-=-=- UserBean.java -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    public void processAction(ActionEvent event) throws AbortProcessingException {
        /* Find the UIParameter component by expression */
       UIParameter component = (UIParameter) event.getComponent().findComponent("itemId");
       /* param itemId - Wrong (use Debug to see) */
    }

  • Nesting DataTable

    hello everyone
    i have problem in printing table in the following format
    student has taken many courses
    1.id name
    course1
    course2
    course2
    2.id name
    course1
    course2
    i am using nested datatable but it displays all the courses for every record
    any one could help me
    thanks in advance

    hi ramu use this code that will help u
    <t:dataTable id="Table" rowIndexVar="row"
                   value="#{Bean.list}" var="p" border="1"
                   cellpadding="1" cellspacing="1" first="0" rows="5">
                   <f:facet name="header">
                        <h:outputText value="View Details" />
                   </f:facet>
                   <t:column>
                        <f:facet name="header">
                             <t:outputText value="description" />
                        </f:facet>
                        <t:outputText value="#{p.description}" />
                   </t:column>
                   <t:column>
                        <f:facet name="header">
                             <t:outputText value="location" />
                        </f:facet>
                        <t:outputText value="#{p.location}" />
                   </t:column>
                   <t:column>
                        <tr>
                             <td colspan="2">
                                  <t:dataTable id="subTable" value="#{p.subList}" var="sub"
                                       border="2" cellpadding="2" cellspacing="2" first="0" rows="5">
                                       <t:column>
                                            <t:outputText value="Title" />
                                       </t:column>                                   
                                  </td>
                        </tr>
                   </t:column>
              </t:dataTable>
              <t:dataScroller id="scroller2" for="Table" paginator="true"
                   fastStep="2" paginatorMaxPages="5"
                   paginatorActiveColumnStyle="fontsize:10px;font-weight:bold;"
                   immediate="true">
                   <f:facet name="first">
                        <t:outputLabel value="first" />
                   </f:facet>
                   <f:facet name="last">
                        <t:outputLabel value="last" />
                   </f:facet>
                   <f:facet name="previous">
                        <t:outputLabel value="previous" />
                   </f:facet>
                   <f:facet name="next">
                        <t:outputLabel value="next" />
                   </f:facet>
              </t:dataScroller>

  • JSF 1.2 DataTable management during view creation

    Hi all, I have a question on how JSF 1.2 manages DataTable exactly. Consider this table (suppose that tableList.persone has 3 items):
    <h:dataTable id="tablePersone" value="#{tableList.persone}" var="item">
    <h:column>
              <f:facet name="header">
              <h:outputText value="STATO" />
              </f:facet>
              <h:inputText value="#{item.stato}" />
         </h:column>
         <h:column>
              <f:facet name="header">
              <h:outputText value="CODICE" />
              </f:facet>
              <h:inputText value="#{item.codice}" />
         </h:column>
    </h:dataTable>
    I read that jsf iterates over the items of the list during the render response phase, in fact, "item" is not available when the view is built.
    Does it means that jsf does not duplicate the content of the table for each item in the list when creating the tree component?
    In the table above, each row has 2 inputText. If jsf does not create a couple of inputText objects for each row, how jsf handles all the 6 request parameters when the form is submitted (in particular during the apply request values phase).
    Thanks a lot,
    Nico

    I could be really mean right now in my answer.
    I did not even have to post anything, i choose to use MyFaces 1.2.1 and scraped JSF 1.2_06 SUN RI out of my projects lib folder.
    Sorry dude that's the reality, the exceptions the SUN RI threw does not help me in trying to work on real life applications.
    You know i have read that Sun RI implementation is probably best out there since work began on the 1.2 spec way before Apache MyFaces started, hence potentially less buggy.
    I picked up the latest code from SUN RI and encountered at least 3 exceptions that are very low level and hard to mitigate.
    While without any JSF pages modifications i plugged in MyFaces 1.2.1-Snapshot and not a single NullPointerException or a failure.
    I just want to reflect here on this situation because i have been always defending SUN and it's work against other packages
    but my situation with upgrading from 1.1 to JSF 1.2 really puts a dent in my conviction
    specially where UI is such a risky business for us developers in the Web industry.
    this Forum probably is taking me longer then if i just logged the issue against RI.
    But my point is that when such frameworks are being developed they should be tested against real large applications under many industry problems.
    I am after getting this point across, because right now i don't care if you these exceptions are being fixed i dumped your packages anyway.
    Now i know MyFaces have their own problems, but at this moment they are not my issues, my project works using their implementation and that's the story .

  • Jsf 2.0 datatable grid

    Hi
    I would like to display a list in a grid format instead of rows of data. With jsf 1.2, the tag <t:datatable> provided this feature, but that is not compatible with 2.0
    Is there any other option?
    thanks

    Hi,
    thank you for answer. Problem is not related with displaying value. If I do it :
    <h:dataTable value="#{userBean.list}" var="item">
              <h:column>
                   <h:outputText value="#{item}" />
              </h:column>
         </h:dataTable>I get this output :
    string: String
    list:
    Tom
    Andy
    So everythink seems to be OK ! but .. If I look at tomcat console, I see output:
    [INFO] UserBean:26 - getString
    [INFO] UserBean:21 - getList
    [INFO] UserBean:21 - getList
    [INFO] UserBean:21 - getList
    And this is my problem...
    Any advice ?
    Regards,
    Slawek

  • JSF 1.2 Session Timeout Issue

    I am using using:
    JSF- Sun RI (1.2)
    Websphere (6.1)
    Facelets (1.?)
    RichFaces (3.3.2)
    I am having an issue with session timeouts that shows up in two different ways:
    Scenario 1) the client makes an ajax call after the session has timed out
    Scenario 2) the client makes a standard request after the session has timed out - navigating to a new page
    I seem to be able to address one or the other, but I can't seem to find a solution that fixes both scenarios.
    For Scenario 1, I have the client-side A4J.AJAX.onExpired function defined and that is currently working for session timeouts that are discovered via an ajax request.
    However, if I start making changes to try and address the other scenario, it seems to break the A4J javascript function.
    For Scenario 2, I have tried a number of suggestions that I've found online:
    1) I've tried to configure the error page in web.xml:
    <error-page>
         <exception-type>javax.faces.application.ViewExpiredException</exception-type>
         <location>/timeout.jsf</location>
    </error-page>
    However, anything I seem to try around this solution still winds up with a ViewExpiredException. I've tried to have timeout.jsf redirect to the login page and I get a ViewExpiredException on the login page when the redirect happens. I've tried to just render a timeout page with a link the user can click on to go to the login page and that fails as well.
    2) I've tried the phase listener and had little success too.
    3) I tried a NavigationHandler
    One thing I did have working, I believe, was with the phase listener approach, but I had a difficult time displaying a session timed out message upon redirect, but not the first time the user visited the page.
    I'm relatively new to JSF and probably don't understand the app life cycle well enough, I guess, but is there a solution that addresses all of these issues:
    1) works for AJAX calls
    2) works for actual navigation
    3) sends the user back to the login page with some indication as to "why", but gracefully handles the first visit to the login page (or a logout)
    Thanks for any suggestions you can offer.

    Sorry, but I have to disagree. Loading JavaScript at the beginning of your page would only make the page load slower (and "ruin" the user's experience when they see the page being loaded steadily) and also cause unforeseen issues than to leave it at the bottom of your page.
    Big companies like Google (1999), Yahoo (2000), Oracle (2001) and many others are doing the opposite to what you have said. Look at the way they load their JavaScripts and you'll see.
    It's also good practice to zip your content from the server before sending it to the client's web browser to increase performance. Of course, this will depend on whether your web browser supports methods such as gzip, deflate, etc... and whether you use HTTP or HTTPS.
    Lastly, another bad practice I often see Java programmers do is write the following all over the places:
    setString, setInt, setDouble, etcInstead of using an existing feature of Java to do the same in one procedure, as in:
    public static void setParameters(PreparedStatement preparedStatement, Object... values)
       throws SQLException
       for (int i = 0; i < values.length; i++) {
          preparedStatement.setObject(i + 1, values);
    Then just call *setParameters* whenever you need it instead of writing multiple setString, setInt, etc statements everywhere...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Nested datatable

    Hello!
    I want to display data table with nested loops using EL.
    My backing bean is a controller for the parent hibernate entity, lets call it UserGroup (and it has User childs), then I want to display UserGroups with User list for each UserGroup.
    I like that I can access directly to domain classes using EL, like this - #{userGroupController.userGroup.user.login}.
    And I like using entites nested collections as nested loops in my datatable.
    But the problem is that collection of Users is a Set and I can't use Set in datatable.
    As I know datatable works only with Lists.
    What will be the best solution? Use <list> instead of <set> in hibernate mapping file, or leave <set> and use some converter or something else? Do you have any ideas?
    Your help and suggestions are hightly appreciated.

    Generally I would advise against changing the structure of your data model beans because of a limitation in the view technology. I.e., I would keep it as a set.
    In which case what you need is an implementation of javax.faces.model.DataModel which can handle a Set. Note that the dataTable is really looking for a DataModel; when you give it a List it uses ListDataModel automatically.
    Edited by: RaymondDeCampo on Oct 10, 2007 8:56 AM

  • JMeter +JSF 1.2 +Multiple threads issue

    I have an issue when running JMeter with an JSF 1.2 application.
    I have the regex and xpath fix working. It is extracting the correct ViewState value, but only as long as I am running one thread. If I start a thread group with multiple threads the regex/xpath will eventually return the default value and the test will fail.
    Scenario 1 (SUCCESS):
    I run one thread and one thread group, regex/xpath return the
    "ViewState" value correctly and the test runs perfectly until I stop it.
    Scenario 2 (FAILURE):
    I run multiple threads and one thread group, regex/xpath
    eventually return the DEFAULT value instead the "ViewState" value to
    all but one thread. The more threads the faster they fail. It really
    seems like there is a threading issue.
    Has anyone experienced similar issues when running regex/xpath and multiple threads?

    Thank you, I tried what you suggested and revealed something interesting. The application in some cases prints the following on the screen:
    *~com.sun.faces.saveStateFieldMarker~*, and it is in those cases JMETER Xpath extraction fails.
    Well I have to look more into it. Thank again for the help.

  • DataTable Refresh issue

    I have two datatables on a single JSF page.
    A Master /slave model
    page
    DATA TABLE A
    DATA TABLE B
    DataTable A
    Row 1
    Row 2
    Row n
    When I click on Row1 DataTable B is populated with rows corresponding to Row 1
    But the problem is when I sort DataTable A using some column; DataTable B's content is vanished..
    How can i avoid wholoe page being reloaded/refreshed?
    thanks
    Satish
    Boston

    probably datatable b is populated by a request scoped bean?
    some code fragments would be useful...

  • Rerendering issue for download operation

    I have the following requirement
    1. User clicks on a commandButton(Implemented using h:commandButton)
    2. User is presented with Save Dialog box to save an xml in the desired location.
    This works fine as expected in IE and Firefox.
    But I'm facing following issues:
    1. After this operation when i click any button to open a modal panel, it is not opening(Problem only in IE7 not Firefox)
    2. Also I want to display a success message after download operation. Due to page rendering it is not displayed.(Problem both in IE7 and Firefox)
    3. I have attached a status processing image with the h:commandButton but I think the h:commandButton does not have oncomplete
    event so even after Save Dialog Box is closed the status processing image is not closing (Problem both in IE7 and Firefox)
    Note:
    1) I tried using a4j:commandButton instead of h:commandButton, but the Save Dialog box was not displayed.
    2)I'm using tomcat 6.0.14 and richfaces 3.2.1
    3)The xhtml is actually embedded within frames. If i try accessing the xhtml directly without frames then the modal opening issue is not reproduced.
    Code:
    ManagedBean:
    FacesContext ctx = FacesContext.getCurrentInstance();
    if (!ctx.getResponseComplete()) {
        try{       
         String strMIME = "application/xml";
         HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
         response.setContentType( strMIME );
         response.setHeader( "Content-Disposition", "attachment;filename=\"" + "TestDAta.xml" + "\"" );
         ServletOutputStream out = response.getOutputStream();
         out.write("<xmlfile></xmlfile>".getBytes());
         out.flush();
         out.close();
         ctx.responseComplete();
        }catch(Exception e){  
         System.err.println("Finish read end of file...");  
    }xhtml:
    <h:form id="details">
         <h:panelGrid columns="1" >
              <h:commandButton  value="Open Save Dialog" action="#{saveDialog.openSaveDialog}" onclick="javascript: Richfaces.showModalPanel('downloadModalPanel',{left:'auto', top:'auto',height:'50px',width:'130px'});" oncomplete="javascript: Richfaces.hideModalPanel('downloadModalPanel');" />
         </h:panelGrid>
         <h:panelGrid columns="1">
              <a4j:commandButton  value="Open Modal" reRender="moviesModal" limitToList="true" onclick="Richfaces.showModalPanel('moviesPanel',{left:'auto', top:'auto',height:'100px',width:'100px'});" />
         </h:panelGrid>
    </h:form>Edited by: Leela.C on Apr 20, 2009 5:04 AM

    I think ctx.responseComplete() causes HTTP response for a request to complete
    without rendering the component tree.
    Note: Without ctx.responseComplete() I'm getting following exception on the page
    SEVERE: Error Rendering View[index.xhtml]
    java.lang.IllegalStateException: Servlet response already use stream, Writer not possible
         at org.ajax4jsf.webapp.FilterServletResponseWrapper.getWriter(FilterServletResponseWrapper.java:226)
         at com.sun.facelets.FaceletViewHandler.createResponseWriter(FaceletViewHandler.java:399)
         at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:556)
         at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
         at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
         at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
         at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
         at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
         at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
         at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
         at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         at java.lang.Thread.run(Thread.java:595)

  • Jsf newbie :: converter and navigation issues

    Hi,
    Iam facing a problem in my first jsf application.
    Iam using jsf 1.1 and tomcat 5.5.7
    I have a UserBean with a single attribute userName (which has public getter and setter methods).
    * I have an index.jsp that redirects to login.faces.
    * I have the appropriate servlet url-mapping in my web.xml that maps *.faces to the FacesServlet
    Here's the code for login.jsp
    <f:view>
       <h:form>
             <h3>Please enter your name </h3>
         <table>
          <tr>
              <td>Name:</td>
            <td><h:inputText id = "name" value="#{user.userName}"/></td>
         </tr>               
         </table>
         <p><h:commandButton value="Login" action="welcome"/>
         </p>
         </h:form>
       </body>
    </f:view>Next I have a welcome.jsp which simply outputs Hello <userName>
    <f:view>
      <h:form>
         <h:outputText value="#{user.userName}"></h:outputText>
      </h:form>
    </f:view>And this is my faces-config.xml
    <?xml version="1.0"?>
    <!DOCTYPE faces-config PUBLIC
      "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
      "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <faces-config>
         <managed-bean>
              <managed-bean-name>user</managed-bean-name>
              <managed-bean-class>com.myjsf.UserBean</managed-bean-class>
              <managed-bean-scope>session</managed-bean-scope>
         </managed-bean>
         <navigation-rule>
              <from-view-id>/index.jsp</from-view-id>
              <navigation-case>
                   <from-outcome>welcome</from-outcome>
                   <to-view-id>/welcome.jsp</to-view-id>
              </navigation-case>
         </navigation-rule>
    </faces-config>Now when I start my application , the index page redirects me to login.faces. I believe the FacesServlet intercepts this call, strips of .faces and forwards to login.jsp. Login.jsp is displayed correctly, so far so good. However from here on, I have all kinds of problems
    1. Should the <from-view-id> be /index.jsp (my actual url) or /login.jsp (the url to which index.jsp forwards me to). Actually both seem to work (or not work depending on how you look at it :( )
    2. Anyways whatever I set it to, the login.jsp is displayed correctly. The action attribute of the commandButton tag is set to 'welcome' which matches with the <from-outcome> value in navigation rule in faces-config.xml and I would have expected the welcome.jsp to load on form submit.
    But the form just reloads itself on clicking submit.
    I googled around and discovered that this may be due to validation errors or conversion errors and adding <h:messages/> would indicate the error source. AQccordingly I added it and got this o/p
    " "name": " Conversion Error setting value 'Duke' for 'null Converter'. To cut a long agony story short, I found that I have to define a converter for some data types for validation and/or display. But all I have is a String property. Doesnt jsf provide a default Converter ?
    3. I couldnt get my app to work when I put my jsps in a folder and access them as /<foldername>/jsp in my faces-config.xml. Isnt this possible ? Should all jsps be under the root folder ?
    Will be thankful for any help.
    cheers,
    ram.
    2. Whenever I click on

    Thanks for the reference , I shall definitely go through it.
    My immediate concern is to get the first program working.
    Here is my source code for the bean.
    package com.myjsf;
    import java.io.Serializable;
    public class UserBean implements Serializable {
        private String userName;  
        public String getUserName() {
            return userName;
        public void setName(String userName) {
            this.userName = userName;
    }Here's my login.jsp which comes up fine
    <f:view>
       <h:form>
         <h:messages/>
             <h3>Please enter your name.</h3>               
                 Name: <h:inputText id = "userName" value="#{user.userName}"/><br>
                  <h:commandButton value="Login" action="welcome"/>
         </h:form>
      </f:view>Here's my faces-config.xml
    <faces-config>
         <managed-bean>
              <managed-bean-name>user</managed-bean-name>
              <managed-bean-class>com.myjsf.UserBean</managed-bean-class>
              <managed-bean-scope>session</managed-bean-scope>
         </managed-bean>
         <navigation-rule>
              <from-view-id>/login.jsp</from-view-id>
              <navigation-case>
                   <from-outcome>welcome</from-outcome>
                   <to-view-id>/welcome.jsp</to-view-id>
              </navigation-case>
         </navigation-rule>
    </faces-config>     And this is the error that I get
    "userName": Conversion error occurred. The page gets displayed again. One thing I noticed was that in the html - view source the action attribute of the form tag is set to /myjsf/faces/login.jsp. Shouldnt it be welcome.jsp rather ?
    Iam at my wits end. I have decided to write a Converter which may solve my problem, but is it required ?
    Please help.
    Thanks,
    Ram.

  • Nested for-each issue [Solved]

    Hi.
    First of all, just started looking into xsl, so please explain things carefully.
    I need to make a master-detail form, but the xml is a bit tricky.
    I've made a demo here:
    <DATASET>
    <ROWSET1>
    <ROW>
    <ID>1</ID>
    <NAME>Harry Potter</NAME>
    </ROW>
    <ROW>
    <ID>2</ID>
    <NAME>Draco Malfoy</NAME>
    </ROW>
    </ROWSET1>
    <ROWSET2>
    <ROW_R2>
    <OWNER_ID>1</OWNER_ID>
    <PC>HP</PC>
    </ROW_R2>
    <ROW_R2>
    <OWNER_ID>1</OWNER_ID>
    <PC>Dell</PC>
    </ROW_R2>
    <ROW_R2>
    <OWNER_ID>2</OWNER_ID>
    <PC>Compaq</PC>
    </ROW_R2>
    </ROWSET2>
    </DATASET>
    Here's what I want printed:
    Harry Potter
    -HP
    -Dell
    Draco Malfoy
    -Compaq
    Here's how I've tried making my xsl and if's for joining.
    <xsl:for-each select="DATASET/ROWSET1/ROW">
    <xsl:value-of select="NAME"/>
    <xsl:for-each select="../../ROWSET2/ROW_R2">
    <xsl:if test=" ../../ROWSET1/ROW/ID = OWNER_ID">
    <xsl:text>ID: </xsl:text><xsl:value-of select="../../ROWSET1/ROW/ID"/>
    <xsl:text>OWNER_ID: </xsl:text><xsl:value-of select="OWNER_ID"/>
    <xsl:text>PC: </xsl:text><xsl:value-of select="PC"/>
    </xsl:if>
    </xsl:for-each>
    </xsl:for-each>
    This only outputs
    Harry Potter
    Draco Malfoy
    If I remove the if/end if, it outputs
    Harry Potter
    ID:1 Owner_ID:1 PC:HP
    ID:1 Owner_ID:1 PC:Dell
    ID:1 Owner_ID:2 PC:Compaq
    Draco Malfoy
    ID:1 Owner_ID:1 PC:HP
    ID:1 Owner_ID:1 PC:Dell
    ID:1 Owner_ID:2 PC:Compaq
    Obviously there's a couple of things wrong, so if anyone could help out I'd be greatful.
    I know it's a bit tacky looping through twice to find matching id vs owner_id, but with this kind of xml I don't know any other way, and I can't change the xml. Fortunately it's not that much data so it shouldn't be too slow.
    Cheers,
    Vidar
    Message was edited by:
    Vidar
    :added solved to subject

    A solution that works is to great a for-each loop table using ROWSET1 and setting a variable to the ID value. Then put a nested for-each loop inside the first using ROWSET2 and using a filter on the for-each to filter for OWNER_ID like this:
    <?for-each:/DATASET/ROWSET2/ROW_R2[xdoxslt:get_variable($_XDOCTX, 'x')=OWNER_ID]?>
    for template then looks like the following:
    inialize variable 'x'
    for-each ROWSET1
    NAME
    ID set 'x'
    for-each ROWSET2[filter]
    OWNER ID PC
    end for-each
    end for-each

  • Datatable radiobutton issue

    Hi I have a page with multiple datatables that are shown based on some condition. At any given point only on edatatable is visisble and the rest are hidden. I have radiobuttons in one of the columns. The problem is that radio button selection is not working properly. The problem is selecting one radio button does not unselect the previously selected button: Here is the javascript I have:
    <script>
                        function dataTableSelectOneRadio(radio) {
                             var id = radio.name.substring(radio.name.lastIndexOf(':'));
                             var el = radio.form.elements;
                             for (var i = 0; i < el.length; i++) {
                                  if (el.name.substring(el[i].name.lastIndexOf(':')) == id) {
                                       el[i].checked = false;
                             radio.checked = true;
                   </script>
    Here is the partial jsp code:
    <h:dataTable value="#{reqbean.listOne}"
                                         var="varlistOne" border="0"
                                         id="table1" width="777"
                                         headerClass="header"
                                         rowClasses="evenRow, oddRow"
                                         columnClasses="firstColumn,secondColumn,thirdColumn"
                                         binding="#{reqbean.dataTable1}"
                                         rendered="#{reqbean.flagBtn}">
                              <h:column>                           
                                <h:selectOneRadio valueChangeListener="#{reqbean.setSelectedItem}" onchange="dataTableSelectOneRadio(this);"><f:selectItem itemValue="null" /></h:selectOneRadio>
                              </h:column>
                                    Some more columns
                            </h:dataTable>
                            <h:dataTable value="#{reqbean.listTwo}"
                                         var="varlistTwo" border="0" id="table2"
                                         headerClass="header" width="777"
                                         rowClasses="evenRow, oddRow"
                                         columnClasses="firstColumn,secondColumn,thirdColumn"
                                         binding="#{reqbean.dataTable2}"
                                         rendered="#{reqbean.flagBtn2}">
                              <h:column>
                                <h:selectOneRadio valueChangeListener="#{reqbean.setSelectedItem}" onchange="dataTableSelectOneRadio(this);"><f:selectItem itemValue="null" /></h:selectOneRadio>
                              </h:column>
                                    Some more columns
                            </h:dataTable>Thanks

    Do you understand what the Javascript is doing? Check the client ID's of your form and radio button elements in the HTML source.

Maybe you are looking for