Af:table sorting when immediate='true' bug

Where can I find the patch to fix the problem of sorting an af:table when immediate='true'?

No I don't have a bug number, I've found that this is a bug based on this thread <a href src='BUG:  ADF FACES 10.1.3_04: Table sort broken if immediate="true" but I have no idea what the number is or where to find the patch for it.
This is a really irritating bug. I want to have sorting on my tables but if I can't put immediate='true' on the table then other components on the page will fire their validation.

Similar Messages

  • Sorting an af:table produces a javascrpt error when immediate="true"

    Does anyone know why a javascript error would pop up on the load of the page when I have immediate="true" on an af:table with sortable columns. When I take the immediate="true" off it sorts just fine. The only problem is I need the immediate equals true so that it does not perform validation. Any ideas?

    A resolution to this is critical to our application.

  • ADF table sorting not working - Possible Bug

    Hi all,
    I'm getting this error when I tried to sort a table.
    <06/11/2012 09h14min53s BRST> <Warning> <EclipseLink> <BEA-2005000> <2012-11-06 09:14:53.839--UnitOfWork(28365105)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Column "clientes.nome" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
    Error Code: 8127
    Call: SELECT COUNT(id) FROM "clientes" ORDER BY nome DESC
    Query: ReportQuery(referenceClass=Clientes sql="SELECT COUNT(id) FROM "clientes" ORDER BY nome DESC")>
    <06/11/2012 09h14min53s BRST> <Warning> <EclipseLink> <BEA-2005000> <2012-11-06 09:14:53.917--UnitOfWork(25154371)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: Column "clientes.nome" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
    Error Code: 8127
    Call: SELECT COUNT(id) FROM "clientes" ORDER BY nome DESC
    Query: ReportQuery(referenceClass=Clientes sql="SELECT COUNT(id) FROM "clientes" ORDER BY nome DESC")> I'm using MSSQL server and I tried the same code with MySQL and everything worked.
    I really don't know waht to do, anyone have faced this problem?

    Yes,
    Column "clientes.nome" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.I've create an Aplication using EJB 3.0 and ADF faces. The table on view layer I've created dragging and dropping the list from DataControl.
    When I run the app, the table load fine but it's not sorting the table and on log the server give that error message posted before.
    This error is coming only when I use MSSQL server, on MySQL it's working well.
    Edited by: 969768 on 06/11/2012 04:14
    Edited by: 969768 on 06/11/2012 04:18

  • H:inputText and immediate="true" not updating cached backing bean value

    Hi,
    I am having a problem with h:inputText and immediate="true" when
    returning back to the same page.I looked through the forums but the
    only solution to remove the page from the session works only if I
    don't have to change any button label names in the page I am going back
    to.Unfortunately, I have to change a button name when I go back to the
    same page.The button name change works if i don't remove the page from
    session but then h:inputtext has stale values in it from the backing
    bean.I also need to avoid validation as it is a huge form.
    I have tried looking through the JSF forums but they didn't have any
    answers for a very similar question.
    I am not sure how exactly to use component binding for the input text and update the model values using an actionListener.I have tried puting a binding on an input text field and then used an actionListener instead of immediate="true' in the h:commandLink.But, putting context.renderResponse() in the actionListener method results in the model values not getting updated.
    I have also tried using component.processUpdates(facesContext) as in the UpdateModelValuePhase class -that too doesn't work.
    Thanks for any help,
    Vijay
    Details:
    The <h:inputText ..> does not populate the values back from a backing
    bean when immediate="true" is used when an action is called.
    <h:commandLink id="selectPrincipalId"
    action="#{application.selectPrincipal}" immediate="true">
    Only <h:inputText has the cached values from the first entry.
    <h:inputText id="principalLastName1Id"
    value="#{application.currentPrincipal.lastName}" size="10"/><== this
    has the cached value from the backing bean application.
    <h:outputText gets the new values from the backing bean when the same
    page is reentered.
    <h:outputText value="#{application.currentPrincipal.lastName}"></h:outputText><==
    this refreshes with the new value from the backing bean application.
    Here is the solution to rectify the problem:
    FacesContext facesContext = FacesContext.getCurrentInstance();
    ExternalContext externalContext = facesContext.getExternalContext();
    Map sessionMap = externalContext.getSessionMap();
    sessionMap.remove("/jsp/befg/tc/apply/enterCreditApplication.jsp");
    <== this is the name of the jsf page as defined in the
    faces-config.xml.

    Hi,I have encountered the same problem as you,and I find a solution myself,which is shown as follows,but I don't know if these is any hidden trouble in the code.
    <h:form>
    <h:commandLink action="#{app.action}" immediate="true" actionListener="#{app.update}">xxxx</h:commandLink>
    <h:inputText id="_id" value="#{app.val}" immediate="true"/> //must set immediate="true" else the model will be not updated
    <h:message for="_id"/>
    </h:form>
    public class App{
    public void update(ActionEvent event){
         FacesContext c = FacesContext.getCurrentInstance();
         UIViewRoot root =c.getViewRoot();
         root.processUpdates(c);//to update model and short-circuit the validators
    in such circumstance,the UIViewRoot's processUpdates method will be called in the actionlistener,and the back bean who titled to immediate(true)'s inputText will be updated, but the one who titled to immdiate(false)'s inputText will not be updated,Why?
    Can anyone tell me way?and how to solve?
    Thanks a lot!

  • Problem with immediate=true, maybe a Bug

    I'm using a dataTable for selecting an user. The selected userBean will be put to the session context with id "selectedUser". The next page allows to edit users values. This edit page contains a cancel button with immedtiate=true param to abort editing and go back to the list. The edit page contains some input fields like:
    <h:inputText id="firstName" value="#{selectedUser.firstName}" />
    <h:inputText id="lastName" value="#{selectedUser.lastName}" />
    These fields are showing correct values for the selected user. But after selecting another user from the list the edit page is showing the values of the previous selected user! By selecting the second user again and again after a while the edit page shows the correct values.
    Well, I've added a JSP expression to the edit page to show me if the selected user is the right one "Edit User (${selectedUser})". The value of this expression always shows the correct selected user.
    If I modify the command button from:
    <h:commandButton action="users" value="Cancel" immediate="true" />
    to:
    <h:commandButton type="reset" onclick="window.location.href='/faces/users'" value="Cancel" />
    the problem does not appear!!!
    For me it looks like a bug. Any ideas?
    Thx,
    Wolfgang

    Sorry for the imcomplete testcase, here it comes again:
    --- Users.java ---------------------------------------------
    package jsf.test;
    import java.util.ArrayList;
    import javax.faces.context.FacesContext;
    public class Users
    private ArrayList users;
    public Users()
    super();
    users = new ArrayList();
    users.add(new User("User_A", "firstName_A", "lastName_A"));
    users.add(new User("User_B", "firstName_B", "lastName_B"));
    users.add(new User("User_C", "firstName_C", "lastName_C"));
    public ArrayList getUsers()
    return users;
    public String edit()
    FacesContext context = FacesContext.getCurrentInstance();
    User user = (User)context.getExternalContext().getRequestMap().get("user");
    System.out.println("selectedUser: " + user);
    context.getExternalContext().getSessionMap().put("selectedUser", user);
    return "navToUser";
    --- User.java ---------------------------------------------
    package jsf.test;
    public class User
    private String loginName;
    private String firstName;
    private String lastName;
    public User()
    public User(String loginName, String firstName, String lastName)
    this.loginName = loginName;
    this.firstName = firstName;
    this.lastName = lastName;
    public String getLoginName()
    return loginName;
    public void setLoginName(String loginName)
    this.loginName = loginName;
    public String getFirstName()
    return firstName;
    public void setFirstName(String firstName)
    this.firstName = firstName;
    public String getLastName()
    return lastName;
    public void setLastName(String lastName)
    this.lastName = lastName;
    public String update()
    System.out.println("user update: " + this);
    return "navToUsers";
    public String toString()
    return firstName + " " + lastName;
    --- users.jsp ---------------------------------------------
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <html>
    <body>
    <f:view>
    <h:form id="selectUser">
    <b>Users</b><p>
    <h:dataTable id="users" value="#{users.users}" var="user">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Login Name" />
    </f:facet>
    <h:commandLink action="#{users.edit}">
    <h:outputText value="#{user.loginName}"/>
    </h:commandLink>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="First Name" />
    </f:facet>
    <h:commandLink action="#{users.edit}">
    <h:outputText value="#{user.firstName}"/>
    </h:commandLink>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Last Name" />
    </f:facet>
    <h:commandLink action="#{users.edit}">
    <h:outputText value="#{user.lastName}"/>
    </h:commandLink>
    </h:column>
    </h:dataTable>
    </h:form>
    </f:view>
    </body>
    </html>
    --- user.jsp ---------------------------------------------
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <html>
    <body>
    <f:view>
    <h:form>
    <b>User</b><p>
    <h:panelGrid columns="2" cellpadding="5">
    <h:outputText value="Login Name" />
         <h:inputText id="lognName" value="#{selectedUser.loginName}"/>
    <h:outputText value="First Name" />
         <h:inputText id="firstName" value="#{selectedUser.firstName}"/>
    <h:outputText value="Last Name" />
         <h:inputText id="lastName" value="#{selectedUser.lastName}"/>
    <h:outputText value=" " />
    <h:panelGroup>
    <h:commandButton action="navToUsers" value="Cancel" immediate="true"/>
    <%-- <h:commandButton type="reset" onclick="window.location.href='/faces/users.jsp'" value="Cancel"/> --%>
    <h:outputText value=" " />
    <h:commandButton action="#{selectedUser.update}" value="OK"/>
    </h:panelGroup>
    </h:panelGrid>
    </h:form>
    </f:view>
    </body>
    </html>
    --- faces-config.xml ---------------------------------------------
    <managed-bean>
    <description>
    Bean for TEST users.
    </description>
    <managed-bean-name>users</managed-bean-name>
    <managed-bean-class>jsf.test.Users</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    </managed-bean>
    <managed-bean>
    <description>
    Bean for TEST user.
    </description>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>jsf.test.User</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    <navigation-rule>
    <from-view-id>/users.jsp</from-view-id>
    <navigation-case>
    <from-outcome>navToUser</from-outcome>
    <to-view-id>/faces/user.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    <navigation-rule>
    <from-view-id>/user.jsp</from-view-id>
    <navigation-case>
    <from-outcome>navToUsers</from-outcome>
    <to-view-id>/faces/users.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>

  • Urgent Issue - Immediate=true vs Detail form behavior

    I have an ADF Faces Master Table and a Detail Form (both on the same page - this is a functional requirement). They were created using the ADF Faces Master Table Detail Form Control and are based on a Master Detail Entity based View Object.
    The underlying Entity Object has some basic validations (ex: Required Name, Address)
    I have different actions in the page (Save, Add, Delete), all of them execute the corresponding data control methods.
    For Delete and Add I want to bypass input validation so I set immediate="true". So far so good.
    Now the issue (or bug):
    1. The user selects a record from the master table.
    2. The user modifies some values of that record in the detail form (ex: name).
    3. The user hits Save - > Values are committed to the database and the master table is refreshed with the detail values.
    4. The user hits Add (note that previous values are still there).
    5. The user enters Add mode but the values from the previous record are still there.
    Correct behavior should be that the current form values are cleared out when hitting add.
    I already tried the following in the Entity Object Impl class with no luck:
    protected void create(AttributeList attributeList) {
    setName("");
    super.create(attributeList);
    The only way I see it works is by setting immediate="false", but validations are not bypassed here.
    Any suggestions / experience with this issue is greatly appreciated.
    Thanks,
    Claudio.

    Hi there, I had the same problem and between us at work we spent 5 days trying to figure this out. The solution is:
    * The 'Cancel' commandButton (or commandLink) has immediate="true"
    * The inputText fields do not specify immediate (and are therefore immediate="false")
    * The action in the backing bean invoked on Cancel click must return an outcome, eg. "list"
    * There must be a navigation rule in faces-config.xml for the action, eg. as follows
    <navigation-rule>
         <from-view-id>/Admin.jsp</from-view-id>
         <navigation-case>
              <from-outcome>list</from-outcome>
              <to-view-id>/Admin.jsp</to-view-id>
         </navigation-case>
    </navigation-rule>* sessionMap.remove("/Admin.jsp") is not necessary
    If the action outcome string is null or cannot be found in faces-config.xml, then stale values from the component tree are re-displayed - the bane of many JSF programmers lives. Tinkering with the UIViewRoot seems to have no effect.
    Hope this help...
    - Adam.

  • Error in dynamic query while sort allowed is true

    Dear all
    I m entering search creteria dynamically and search result comes in a table.I have set Sort allowed true for all colum in that table.So when I click on any colum for sorting and then search data, an order by clause will be added before dynamic section of the code.
    and query becomes as -
    SELECT pp.name,
    pp.segment1 project_number,
    pp.project_status_code,
    pps.project_status_name,
    pp.carrying_out_organization_id,
    hau.name organization,
    pp.project_type,
    pp.project_id,
    pp.start_date,
    pp.completion_date
    FROM pa_projects pp,
    pa_project_statuses pps,
    hr_all_organization_units_v hau
    WHERE pp.project_status_code = pps.project_status_code AND
    pp.carrying_out_organization_id = hau.organization_id AND
    pp.template_flag <> 'Y') QRSLT ORDER BY PROJECT_NUMBER asc AND pps.project_status_name ='Active'
    as u can see at the last line of code ' ORDER BY PROJECT_NUMBER asc ' is added before qynamic section 'AND pps.project_status_name ='Active' and it makes query invalid.
    If u have any suggestions ,Plz let me know.
    Thanks
    bhupendra

    Bhupendra,
    As per Oracle SQL Standard "Order by clause" always be the last synatx of Query.
    As per OAF Standard , always avoid for dynamic query, instead we can create View Object.
    As you are created dynamic query with "order by clause" syntax., The code is also adding where clause after the order by clause. So you are getting the error.
    So Delete the "order by clause", it will work fine.
    After adding the where clause (i.e. AND pps.project_status_name ='Active' ), You should add the setOrderByClause();
    Thanks,
    Kumar

  • Global problem with immediate="true"

    JSF specifies that immediate="true" in UICommands should skip the Validation and Update Model phases.
    The RI uses the Update Model phase to reset the local values of the input components after updating the model. That means that in the case of immediate="true", the local values are not reset, and thus saved by the state manager.
    The problem is that the next display of the page shows the previously entered values, instead of getting the values from the model, which is somewhat strange for a 'cancel' button.
    I think this is mainly a problem with the spec which clearly indicates that the clearing of the local values should be done in the update model phase.
    Is it possible to have a workaround for this ?

    the previous posts have been made long ago, but I'll give it a try:
    I think this behavior is still buggy or at least not logical.
    Example:
    I've got a dataTable which shows a list of entries, each row with an "edit" commandButton and a "new" commandButton below the list.
    If the user clicks an "edit" button, he is redirected to the "details" page where he can edit and save the values of this entry. This works as expected. But: On the "details" page, there's also a "cancel" button, which should navigate to the list again, without doing any validation or updating.
    If I set this "cancel" button to "immediate", navigation works, but then I'll always see the values of the canceled entry, regardless of which "edit" button I click in the list.
    If the "cancel" button is not immediate, validation fails when the user clicks "new" and then "cancel", because he gets an empty form, but some or all fields are required.
    There are two workarounds:
    1) Creating two different views, one for creating a new entry and one for editing.
    2) The "cancel" button is a simple html-button, with the "onlick='location.href=xxxyyy'" attribute.
    IMHO both workarounds are ugly. So, why is the view ignoring that there is a complete different entry object in the backing bean of the "details" input fields???
    BTW: I'm using JSF SUN RI 1.1.01 (same with 1.2 current snapshot).
    With MyFaces, everythings works but it has some other bugs, so I want to stick to the Sun RI.
    Thanks,
    Walter

  • Table Sorting: How is firstVisibleRow being affected?

    Dears,
    I'm confused at table sorting using Tablesorter.java.
    When sorting, how does Tablesorter affect the firstVisibleRow of the table?
    In the "[Working with tables|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/90ac0015-d1c5-2a10-d788-aed89990811d]" sample SDN provided, when press "sorting asending" or "sort descending", the table's first visible row changes automatically.
    I didn't understand why firstVisibleRow changed to be so. And I don't know how the firstVisibleRow will change to be.
    I checked the code of Tablesorter, and I also tried to debug into it, but didn't find any track.
    Any word is appreciated. Thanks in advance.
    Edited by: gangtee gangtee on May 2, 2008 4:59 PM

    Attached is Tablesorter.java
    package com.sap.tc.webdynpro.tests.utils;
    import java.text.Collator;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Comparator;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.StringTokenizer;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByIndex;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByKey;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractInputField;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractTableColumn;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCaption;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCheckBox;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDLink;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDProgressIndicator;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDRadioButton;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTable;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableCellEditor;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumn;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumnGroup;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextEdit;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextView;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection;
    import com.sap.tc.webdynpro.progmodel.api.IWDAction;
    import com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent;
    import com.sap.tc.webdynpro.progmodel.api.IWDNode;
    import com.sap.tc.webdynpro.progmodel.api.IWDNodeElement;
    import com.sap.tc.webdynpro.progmodel.api.IWDViewElement;
    import com.sap.tc.webdynpro.services.sal.localization.api.WDResourceHandler;
    * Helper class that makes a Web Dynpro table UI element sortable (column-wise).
    public final class TableSorter {
          * @param table
          * @param sortAction
          * @param comparators
         public TableSorter(IWDTable table, IWDAction sortAction, Map comparators) {
              init(table, sortAction, comparators, null);
         public TableSorter(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns) {
              init(table, sortAction, comparators, sortableColumns);
          * Initialisation stuff
         private void init(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns){
              this.table = table;
              if(sortableColumns == null){
                   sortableCols = null;
              }else{
                   sortableCols = new HashMap();
                   for (int i = 0; i < sortableColumns.length; i++) {
                        sortableCols.put(sortableColumns<i>, sortableColumns<i>);
              // sanity checks
              if (sortAction == null)
                   throw new IllegalArgumentException("Sort action must be given");
              if (table == null)
                   throw new IllegalArgumentException("Table must be given");
              if (table.bindingOfDataSource() == null)
                   throw new IllegalArgumentException(
                        "Data source of table with id '" + table.getId() + "' must be bound");
              // make the columns sortable
              String dataSourcePrefix = table.bindingOfDataSource() + ".";
              setComparatorsForColumns(dataSourcePrefix, table.iterateGroupedColumns(), comparators);
              //set up the table properties
              table.setOnSort(sortAction);
              table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.COL, "selectedColumn");
              table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.DIRECTION, "sortDirection");     
          * Try to make the given columns sortable (recusivly, if necessary)
         private void setComparatorsForColumns(String dataSourcePrefix, Iterator columnIterator, Map comparators){
              int index = 0;
              for (Iterator it = columnIterator; it.hasNext(); ++index) { // for every column: try to make it bindable
                   IWDAbstractTableColumn abstractColumn = (IWDAbstractTableColumn) it.next();
                   if(abstractColumn instanceof IWDTableColumn){
                        IWDTableColumn column = (IWDTableColumn)abstractColumn;
                        if(sortableCols == null || sortableCols.containsKey(column.getId())){
                             //try to make this column sortable
                             Comparator comparator = null;
                             if (comparators != null){
                                  comparator = (Comparator)comparators.get(column.getId());
                             NodeElementByAttributeComparator elementComparator = null;     
                             if (comparator instanceof NodeElementByAttributeComparator) {
                                  // the easy one, attribute and ordering are given
                                  elementComparator = (NodeElementByAttributeComparator)comparator;
                             } else { // attribute must be determined
                                  String bindingOfPrimaryProperty = bindingOfPrimaryProperty(column.getTableCellEditor());
                                  if (bindingOfPrimaryProperty == null || !bindingOfPrimaryProperty.startsWith(dataSourcePrefix)){
                                       //no attribute found or outside of data source
                                       column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                                       continue;
                                  String attributeName = bindingOfPrimaryProperty.substring(dataSourcePrefix.length());
                                  Collection subnodes = new ArrayList();
                                  if (attributeName.indexOf('.') >= 0){
                                       //attribute not immediately below data source
                                       String[] tokens = tokenize (attributeName, ".");
                                       for(int i=0; i<tokens.length-1; i++){
                                            subnodes.add(tokens<i>);
                                       attributeName = tokens[tokens.length-1];
                                  if(subnodes.size() == 0){
                                       elementComparator = new NodeElementByAttributeComparator(attributeName, comparator);
                                  }else{
                                       elementComparator = new NodeElementByAttributeComparator(attributeName, comparator, subnodes);
                             // set up internal data structures
                             comparatorForColumn.put(column, elementComparator);
                             //set sort state
                             column.setSortState(WDTableColumnSortDirection.NONE);
                        }else{
                             //column should not be sortable
                             column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                   }else if (abstractColumn instanceof IWDTableColumnGroup){
                        //it's just a column group -> try to bind the columns of the column group
                        IWDTableColumnGroup columnGroup = (IWDTableColumnGroup)abstractColumn;
                        setComparatorsForColumns(dataSourcePrefix, columnGroup.iterateColumns(), comparators);
          * Tokenizes the input string according to the given delimiters. The delimiters will be left out.
          * Example: tokenize("Hello_World", "_") results ["Hello", "World"]
         private String[] tokenize (String input, String delim){
              StringTokenizer tokenizer = new StringTokenizer(input, delim);
              String[] tokens = new String[tokenizer.countTokens()];
              int index = 0;
              while(tokenizer.hasMoreTokens()){
                   tokens[index] = tokenizer.nextToken();
                   index++;
              return tokens;
          * This method must be called from the event handler of this table sorter's
          * sort action. It performs the actual sort operation.
         public void sort(IWDCustomEvent wdEvent, IWDNode dataSource) {
              // find the things we need
              String columnId = wdEvent.getString("selectedColumn");
              String direction = wdEvent.getString("sortDirection");
              IWDTableColumn column = (IWDTableColumn) table.getView().getElement(columnId);
              NodeElementByAttributeComparator elementComparator = (NodeElementByAttributeComparator) comparatorForColumn.get(column);
              if (elementComparator == null){
                   //not a sortable column
                   column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                   return;
              // sorting
              elementComparator.setSortDirection(WDTableColumnSortDirection.valueOf(direction));
              dataSource.sortElements(elementComparator);
          * Returns the binding of the given table cell editor's property that is
          * considered "primary" or <code>null</code> if no such binding exists or no
          * such property can be determined.
         private static final String bindingOfPrimaryProperty(IWDTableCellEditor editor) {
              return editor instanceof IWDViewElement ? bindingOfPrimaryProperty((IWDViewElement) editor) : null;
          * Returns the binding of the given view element's property that is
          * considered "primary" or <code>null</code> if no such binding exists or no
          * such property can be determined.
         private static final String bindingOfPrimaryProperty(IWDViewElement element) {
              if (element instanceof IWDAbstractDropDownByIndex)
                   return ((IWDAbstractDropDownByIndex) element).bindingOfTexts();
              if (element instanceof IWDAbstractDropDownByKey)
                   return ((IWDAbstractDropDownByKey) element).bindingOfSelectedKey();
              if (element instanceof IWDAbstractInputField)
                   return ((IWDAbstractInputField) element).bindingOfValue();
              if (element instanceof IWDCaption)
                   return ((IWDCaption) element).bindingOfText();
              if (element instanceof IWDCheckBox)
                   return ((IWDCheckBox) element).bindingOfChecked();
              if (element instanceof IWDLink)
                   return ((IWDLink) element).bindingOfText();
              if (element instanceof IWDProgressIndicator)
                   return ((IWDProgressIndicator) element).bindingOfPercentValue();
              if (element instanceof IWDRadioButton)
                   return ((IWDRadioButton) element).bindingOfSelectedKey();
              if (element instanceof IWDTextEdit)
                   return ((IWDTextEdit) element).bindingOfValue();
              if (element instanceof IWDTextView)
                   return ((IWDTextView) element).bindingOfText();
              return null;
          * Instance of a comparator according to the ordering imposed by the
          * implementation of <code>Comparable</code>.
         private static final Comparator DEFAULT = new Comparator() {
               * Compares the given objects according to the ordering imposed by the first
               * ones <code>compareTo(Object)</code> function. Furthermore, <code>null</code>
               * is treated to be less than any object.
               * @see java.lang.Comparable#compareTo(java.lang.Object)
               * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
              public int compare(Object o1, Object o2) {
                   if (o1 == null && o2 == null)
                        return 0;
                   if (o1 == null)
                        return -1;
                   if (o2 == null)
                        return +1;
                   if (o1 instanceof Boolean && o2 instanceof Boolean)
                        return o1.toString().compareTo(o2.toString()); // false < true
                   if (o1 instanceof String && o2 instanceof String){
                        //Use a Collator for sorting according to the given Locale
                        Collator collate = Collator.getInstance(WDResourceHandler.getCurrentSessionLocale());
                        return collate.compare(o1, o2);                    
                   return ((Comparable) o1).compareTo((Comparable) o2);
          * Map of table column to comparator (<code>ReversableComparator</code>)
          * used for sorting that column (sortable columns only).
         private Map comparatorForColumn = new HashMap();
          * The table to be sorted.
         private IWDTable table = null;
          * Column-IDs of the columns, which should be sortable
         private Map sortableCols = null;
          * Generic comparator that compares node elements by a given attribute with
          * the help of a given comparator.
         public final class NodeElementByAttributeComparator implements Comparator {
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute according to the natural ordering of that attribute's
               * type (which must implement <code>java.lang.Comparable</code>).
              public NodeElementByAttributeComparator(String attributeName) {
                   this(attributeName, null, false, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute with the help of the given comparator. If no comparator
               * is given, the natural ordering of that attribute's type is used.
              public NodeElementByAttributeComparator(String attributeName, Comparator comparator) {
                   this(attributeName, comparator, false, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute either as objects (i.e. "in internal format") or as text
               * (i.e. "in external format") as indicated. The ordering is the natural
               * ordering of that attribute's type (which must implement
               * <code>java.lang.Comparable</code>) in case objects are compared or the
               * natural ordering of <code>java.lang.String</code> in case texts are compared.
              public NodeElementByAttributeComparator(String attributeName, boolean compareAsText) {
                   this(attributeName, null, compareAsText, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute according to the natural ordering of that attribute's
               * type (which must implement <code>java.lang.Comparable</code>). In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, Collection subnodes) {
                   this(attributeName, null, false, subnodes);
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute with the help of the given comparator. If no comparator
               * is given, the natural ordering of that attribute's type is used. In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, Comparator comparator, Collection subnodes) {
                   this(attributeName, comparator, false, subnodes);
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute either as objects (i.e. "in internal format") or as text
               * (i.e. "in external format") as indicated. The ordering is the natural
               * ordering of that attribute's type (which must implement
               * <code>java.lang.Comparable</code>) in case objects are compared or the
               * natural ordering of <code>java.lang.String</code> in case texts are compared. In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, boolean compareAsText, Collection subnodes) {
                   this(attributeName, null, compareAsText, subnodes);
               * Internal constructor.
              private NodeElementByAttributeComparator(
                   String attributeName,
                   Comparator comparator,
                   boolean compareAsText,
                   Collection subNodes) {
                   if (attributeName == null)
                        throw new IllegalArgumentException("Attribute name must not be null");
                   if (comparator == null)
                        comparator = DEFAULT;
                   this.attributeName = attributeName;
                   this.comparator = comparator;
                   this.compareAsText = compareAsText;
                   this.sortDirection = true;
                   this.subNodes = subNodes;
               * Sets the sort direction of this comparator to the given direction. The comparator sort in ascending order by default.
               * @see com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection
              public void setSortDirection(WDTableColumnSortDirection direction){
                   if(direction.equals(WDTableColumnSortDirection.UP)){
                        sortDirection = true;
                   }else if(direction.equals(WDTableColumnSortDirection.DOWN)){
                        sortDirection = false;
               * Compares the given objects which must be instances of <code>IWDNodeElement</code>
               * according to the values of the attribute given at construction time
               * with the help of the comparator given at construction time.
               * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
               * @see com.sap.tc.webdynpro.progmodel.api.IWDNodeElement
              public int compare(Object o1, Object o2) {
                   IWDNodeElement element1 = (IWDNodeElement) o1;
                   IWDNodeElement element2 = (IWDNodeElement) o2;
                   if(subNodes.size() > 0){
                        element1 = getSubNodeElement(element1, 0);
                        element2 = getSubNodeElement(element2, 0);
                   Object attributeValue1 = null;
                   Object attributeValue2 = null;
                   if(element1 != null){
                        attributeValue1 =
                             compareAsText
                                  ? element1.getAttributeAsText(attributeName)
                                  : element1.getAttributeValue(attributeName);
                   if(element2 != null){
                        attributeValue2 =
                             compareAsText
                                  ? element2.getAttributeAsText(attributeName)
                                  : element2.getAttributeValue(attributeName);
                   if(sortDirection){
                        return comparator.compare(attributeValue1, attributeValue2);
                   }else{
                        return comparator.compare(attributeValue2, attributeValue1);
               * Determines recursivly the child node, which have an attribute with the given name.
               * The path to this child node must be specified in the subnodes property of this comparator.
               * Start this method with index = 0.
              private IWDNodeElement getSubNodeElement(IWDNodeElement currentElement, int index){
                   if(currentElement == null || index >= subNodes.size()){
                        //end of recursion
                        return currentElement;
                   }else{
                        return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getCurrentElement(), index+1);
                        //return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getElementAt(0), index+1);
               * Name of the attribute used for comparisons.
              private final String attributeName;
               * Comparator used for comparing the attribute's values.
              private final Comparator comparator;
               * Indicates whether attribute values are compared as text (as opposed to
               * "as objects").
              private final boolean compareAsText;
               * Sort direction (true = ascending order, false = descending order)
              private boolean sortDirection;
               * List of child node names
               * (Description of the path from the given context node to the specified attribute)
              private Collection subNodes;

  • Problem in ADF Table Sorting Accessor Fields Generated from EJB 3

    Here are the things that I have done:
    1) created EJB entities for Employee and Department based on the HR schema
    2) created an HRFacade session bean
    3) generated DataControl
    4) created a browse page
    5) created an adf read only table with the following fields: employeeId, lastname, and departmentName with row selection, filtering and sorting enaabled.
    when I invoke sorting for the employeeId and lastname fields, the table sorts fine, but...
    when I invoke sorting on the departmentName field (an accessor field), the following error occured:
    WARNING: ADF: Adding the following JSF error message: Definition departmentName of type Attribute is not found in employeesFindAll.
    oracle.jbo.NoDefException: JBO-25058: Definition departmentName of type Attribute is not found in employeesFindAll.
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:589)
         at oracle.jbo.uicli.binding.JUCtrlValueBinding.findAttributeDef(JUCtrlValueBinding.java:559)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlRangeBinding.__setSortCriteria(FacesCtrlRangeBinding.java:247)
         at oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding$FacesModel.setSortCriteria(FacesCtrlHierBinding.java:346)
         at org.apache.myfaces.trinidad.component.UIXCollection.setSortCriteria(UIXCollection.java:464)
         at org.apache.myfaces.trinidad.component.UIXTable.setSortCriteria(UIXTable.java:196)
         at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:260)
         at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:140)
         at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:364)
         at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:147)
         at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:271)
         at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:140)
         at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:364)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:787)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:280)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:165)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:292)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:191)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:85)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:54)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:420)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:247)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:157)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.wls.JpsWlsFilter$1.run(JpsWlsFilter.java:96)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.wls.util.JpsWlsUtil.runJaasMode(JpsWlsUtil.java:146)
         at oracle.security.jps.wls.JpsWlsFilter.doFilter(JpsWlsFilter.java:140)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:70)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.dms.wls.DMSServletFilter.doFilter(DMSServletFilter.java:202)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3588)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2200)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2106)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1428)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Is this a bug or a not supported feature?
    We been stack on this... Help!!!

    I have a similar problem but related to the creation of Project Gantt Chart.
    oracle.jbo.NoDefException: JBO-25058: No se ha encontrado la definición XXXView2 del tipo Atributo en YYYView1.
    this is happened when i try to create a Project Gantt Chart whit 2 view objects that have a parent-child relationship where XXXView2 (SUBTASKS) is the child and YYYView1 (TASK) is the parent.
    still not find the solution.
    This is the bug?

  • ADF Table sort issue

    Hi,
    We are using ADF 11g.
    In application we have af:query search block and its result table. When we click on column header with some data present it is sorting the data, which is accepted behaviour.
    But when there is no data in the table, and click on column header, The blind search query is being exceuted and fetching all the data. The issue with this is the table has millions of records and we have 'selectively required' search on the page. So through search block a blind search is not allowed but on click of Sort of column we are not able to handel it, affecting the performance of application.
    What can be done to prevent blind search?
    Thanks,
    Manasa

    There could be so many ways.. One simple solution I see is disable sorting only when Table is empty,
    set the sortable property for columns like : #{bindings.employeeVO1.estimatedRowCount > 0 ? true : false}
    Amit
    Edited by: amseth on Jan 14, 2011 10:31 AM

  • Table sorter

    Hi,
         i have to implement a table sorter in one of my webdypro application. I have done all the steps mentioned in one of the blog and have also imported TableSorter.java class. i am getting sorting icons in column headers. but on clicking icon nothing happens...i think there is some problem with the java class which i have imported. So can anybody provide the code of tablesorter.java class.
    Thanks in advance,
        Reena

    Hi Reena,
    Here is the code.Just change the package name.
    * Created on Sep 6, 2007
    * To change the template for this generated file go to
    * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    package ibm.com.tradefund.utils;
    * @author Administrator
    * To change the template for this generated type comment go to
    * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
    import java.text.Collator;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Comparator;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.StringTokenizer;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByIndex;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractDropDownByKey;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractInputField;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDAbstractTableColumn;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCaption;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDCheckBox;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDLink;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDProgressIndicator;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDRadioButton;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTable;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableCellEditor;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumn;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTableColumnGroup;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextEdit;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTextView;
    import com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection;
    import com.sap.tc.webdynpro.progmodel.api.IWDAction;
    import com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent;
    import com.sap.tc.webdynpro.progmodel.api.IWDNode;
    import com.sap.tc.webdynpro.progmodel.api.IWDNodeElement;
    import com.sap.tc.webdynpro.progmodel.api.IWDViewElement;
    import com.sap.tc.webdynpro.services.sal.localization.api.WDResourceHandler;
    * Helper class that makes a Web Dynpro table UI element sortable (column-wise).
    public final class TableSorter {
          * @param table
          * @param sortAction
          * @param comparators
          * Creates a table sorter for the given table using the given sort action.
          * This constructor must be called from <code>wdDoModifyView()</code>, but
          * usually only when that hook is called for the first time. Store the newly
          * created instance in a context attribute with Java native type
          * <code>com.sap.tc.webdynpro.tests.utils.TableSorter</code>.
          * The given sort action's event handler will be bound to the <code>onSort</code>
          * event of the table and must at least call this table sorter's
          * <code>sort(wdEvent)</code> method.
          * Every column of the table is made sortable if possible according to the
          * following rules.
          * If a comparator is given for a column's ID and it is a
          * <code>NodeElementByAttributeComparator</code>, then that comparator defines
          * both the attribute and the ordering used to sort that column.
          * If any other comparator is given and an attribute can be determined from
          * that column's table cell editor, then that attribute is used to sort that
          * column according to the ordering imposed by the given comparator.
          * If no comparator is given but an attribute can be determined from
          * that column's table cell editor, then that attribute is used to sort that
          * column according to the natural ordering of that attribute's type.
          * Else that column is left untouched.
          * Additionally it is possible to define the sortable columns by their
          * TableColumn UI element ids.
          * @see sort()
          * @see NodeElementByAttributeComparator
          * @see com.sap.tc.webdynpro.clientserver.uielib.standard.api.IWDTable
         public TableSorter(IWDTable table, IWDAction sortAction, Map comparators) {
              init(table, sortAction, comparators, null);
         public TableSorter(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns) {
              init(table, sortAction, comparators, sortableColumns);
          * Initialisation stuff
         private void init(IWDTable table, IWDAction sortAction, Map comparators, String[] sortableColumns){
              this.table = table;
              if(sortableColumns == null){
                   sortableCols = null;
              }else{
                   sortableCols = new HashMap();
                   for (int i = 0; i < sortableColumns.length; i++) {
                        sortableCols.put(sortableColumns<i>, sortableColumns<i>);
              // sanity checks
              if (sortAction == null)
                   throw new IllegalArgumentException("Sort action must be given");
              if (table == null)
                   throw new IllegalArgumentException("Table must be given");
              if (table.bindingOfDataSource() == null)
                   throw new IllegalArgumentException(
                        "Data source of table with id '" + table.getId() + "' must be bound");
              // make the columns sortable
              String dataSourcePrefix = table.bindingOfDataSource() + ".";
              //TODO: remove the following line since this method is not longer available in later releases
              setComparatorsForColumns(dataSourcePrefix, table.iterateColumns(), comparators);
              setComparatorsForColumns(dataSourcePrefix, table.iterateGroupedColumns(), comparators);
              //set up the table properties
              table.setOnSort(sortAction);
              table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.COL, "selectedColumn");
              table.mappingOfOnSort().addSourceMapping(IWDTable.IWDOnSort.DIRECTION, "sortDirection");     
          * Try to make the given columns sortable (recusivly, if necessary)
         private void setComparatorsForColumns(String dataSourcePrefix, Iterator columnIterator, Map comparators){
              int index = 0;
              for (Iterator it = columnIterator; it.hasNext(); ++index) { // for every column: try to make it bindable
                   IWDAbstractTableColumn abstractColumn = (IWDAbstractTableColumn) it.next();
                   if(abstractColumn instanceof IWDTableColumn){
                        IWDTableColumn column = (IWDTableColumn)abstractColumn;
                        if(sortableCols == null || sortableCols.containsKey(column.getId())){
                             //try to make this column sortable
                             Comparator comparator = null;
                             if (comparators != null){
                                  comparator = (Comparator)comparators.get(column.getId());
                             NodeElementByAttributeComparator elementComparator = null;     
                             if (comparator instanceof NodeElementByAttributeComparator) {
                                  // the easy one, attribute and ordering are given
                                  elementComparator = (NodeElementByAttributeComparator)comparator;
                             } else { // attribute must be determined
                                  String bindingOfPrimaryProperty = bindingOfPrimaryProperty(column.getTableCellEditor());
                                  if (bindingOfPrimaryProperty == null || !bindingOfPrimaryProperty.startsWith(dataSourcePrefix)){
                                       //no attribute found or outside of data source
                                       column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                                       continue;
                                  String attributeName = bindingOfPrimaryProperty.substring(dataSourcePrefix.length());
                                  Collection subnodes = new ArrayList();
                                  if (attributeName.indexOf('.') >= 0){
                                       //attribute not immediately below data source
                                       String[] tokens = tokenize (attributeName, ".");
                                       for(int i=0; i<tokens.length-1; i++){
                                            subnodes.add(tokens<i>);
                                       attributeName = tokens[tokens.length-1];
                                  if(subnodes.size() == 0){
                                       elementComparator = new NodeElementByAttributeComparator(attributeName, comparator);
                                  }else{
                                       elementComparator = new NodeElementByAttributeComparator(attributeName, comparator, subnodes);
                             // set up internal data structures
                             comparatorForColumn.put(column, elementComparator);
                             //set sort state
                             column.setSortState(WDTableColumnSortDirection.NONE);
                        }else{
                             //column should not be sortable
                             column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                   }else if (abstractColumn instanceof IWDTableColumnGroup){
                        //it's just a column group -> try to bind the columns of the column group
                        IWDTableColumnGroup columnGroup = (IWDTableColumnGroup)abstractColumn;
                        setComparatorsForColumns(dataSourcePrefix, columnGroup.iterateColumns(), comparators);
          * Tokenizes the input string according to the given delimiters. The delimiters will be left out.
          * Example: tokenize("Hello_World", "_") results ["Hello", "World"]
         private String[] tokenize (String input, String delim){
              StringTokenizer tokenizer = new StringTokenizer(input, delim);
              String[] tokens = new String[tokenizer.countTokens()];
              int index = 0;
              while(tokenizer.hasMoreTokens()){
                   tokens[index] = tokenizer.nextToken();
                   index++;
              return tokens;
          * This method must be called from the event handler of this table sorter's
          * sort action. It performs the actual sort operation.
         public void sort(IWDCustomEvent wdEvent, IWDNode dataSource) {
              // find the things we need
              String columnId = wdEvent.getString("selectedColumn");
              String direction = wdEvent.getString("sortDirection");
              IWDTableColumn column = (IWDTableColumn) table.getView().getElement(columnId);
              NodeElementByAttributeComparator elementComparator = (NodeElementByAttributeComparator) comparatorForColumn.get(column);
              if (elementComparator == null){
                   //not a sortable column
                   column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
                   return;
              // sorting
              elementComparator.setSortDirection(WDTableColumnSortDirection.valueOf(direction));
              dataSource.sortElements(elementComparator);
          * Returns the binding of the given table cell editor's property that is
          * considered "primary" or <code>null</code> if no such binding exists or no
          * such property can be determined.
         private static final String bindingOfPrimaryProperty(IWDTableCellEditor editor) {
              return editor instanceof IWDViewElement ? bindingOfPrimaryProperty((IWDViewElement) editor) : null;
          * Returns the binding of the given view element's property that is
          * considered "primary" or <code>null</code> if no such binding exists or no
          * such property can be determined.
         private static final String bindingOfPrimaryProperty(IWDViewElement element) {
              if (element instanceof IWDAbstractDropDownByIndex)
                   return ((IWDAbstractDropDownByIndex) element).bindingOfTexts();
              if (element instanceof IWDAbstractDropDownByKey)
                   return ((IWDAbstractDropDownByKey) element).bindingOfSelectedKey();
              if (element instanceof IWDAbstractInputField)
                   return ((IWDAbstractInputField) element).bindingOfValue();
              if (element instanceof IWDCaption)
                   return ((IWDCaption) element).bindingOfText();
              if (element instanceof IWDCheckBox)
                   return ((IWDCheckBox) element).bindingOfChecked();
              if (element instanceof IWDLink)
                   return ((IWDLink) element).bindingOfText();
              if (element instanceof IWDProgressIndicator)
                   return ((IWDProgressIndicator) element).bindingOfPercentValue();
              if (element instanceof IWDRadioButton)
                   return ((IWDRadioButton) element).bindingOfSelectedKey();
              if (element instanceof IWDTextEdit)
                   return ((IWDTextEdit) element).bindingOfValue();
              if (element instanceof IWDTextView)
                   return ((IWDTextView) element).bindingOfText();
              return null;
          * Instance of a comparator according to the ordering imposed by the
          * implementation of <code>Comparable</code>.
         private static final Comparator DEFAULT = new Comparator() {
               * Compares the given objects according to the ordering imposed by the first
               * ones <code>compareTo(Object)</code> function. Furthermore, <code>null</code>
               * is treated to be less than any object.
               * @see java.lang.Comparable#compareTo(java.lang.Object)
               * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
              public int compare(Object o1, Object o2) {
                   if (o1 == null && o2 == null)
                        return 0;
                   if (o1 == null)
                        return -1;
                   if (o2 == null)
                        return +1;
                   if (o1 instanceof Boolean && o2 instanceof Boolean)
                        return o1.toString().compareTo(o2.toString()); // false < true
                   if (o1 instanceof String && o2 instanceof String){
                        //Use a Collator for sorting according to the given Locale
                        Collator collate = Collator.getInstance(WDResourceHandler.getCurrentSessionLocale());
                        return collate.compare(o1, o2);                    
                   return ((Comparable) o1).compareTo((Comparable) o2);
          * Map of table column to comparator (<code>ReversableComparator</code>)
          * used for sorting that column (sortable columns only).
         private Map comparatorForColumn = new HashMap();
          * The table to be sorted.
         private IWDTable table = null;
          * Column-IDs of the columns, which should be sortable
         private Map sortableCols = null;
          * Generic comparator that compares node elements by a given attribute with
          * the help of a given comparator.
         public final class NodeElementByAttributeComparator implements Comparator {
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute according to the natural ordering of that attribute's
               * type (which must implement <code>java.lang.Comparable</code>).
              public NodeElementByAttributeComparator(String attributeName) {
                   this(attributeName, null, false, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute with the help of the given comparator. If no comparator
               * is given, the natural ordering of that attribute's type is used.
              public NodeElementByAttributeComparator(String attributeName, Comparator comparator) {
                   this(attributeName, comparator, false, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute either as objects (i.e. "in internal format") or as text
               * (i.e. "in external format") as indicated. The ordering is the natural
               * ordering of that attribute's type (which must implement
               * <code>java.lang.Comparable</code>) in case objects are compared or the
               * natural ordering of <code>java.lang.String</code> in case texts are compared.
              public NodeElementByAttributeComparator(String attributeName, boolean compareAsText) {
                   this(attributeName, null, compareAsText, new ArrayList());
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute according to the natural ordering of that attribute's
               * type (which must implement <code>java.lang.Comparable</code>). In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, Collection subnodes) {
                   this(attributeName, null, false, subnodes);
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute with the help of the given comparator. If no comparator
               * is given, the natural ordering of that attribute's type is used. In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, Comparator comparator, Collection subnodes) {
                   this(attributeName, comparator, false, subnodes);
               * Creates a new comparator for the given attribute name that compares values
               * of that attribute either as objects (i.e. "in internal format") or as text
               * (i.e. "in external format") as indicated. The ordering is the natural
               * ordering of that attribute's type (which must implement
               * <code>java.lang.Comparable</code>) in case objects are compared or the
               * natural ordering of <code>java.lang.String</code> in case texts are compared. In addition it is possible
               * to define the path to a child node with the <code>java.util.Collection</code> subnodes.
               * (List of child node names in the correct order)
              public NodeElementByAttributeComparator(String attributeName, boolean compareAsText, Collection subnodes) {
                   this(attributeName, null, compareAsText, subnodes);
               * Internal constructor.
              private NodeElementByAttributeComparator(
                   String attributeName,
                   Comparator comparator,
                   boolean compareAsText,
                   Collection subNodes) {
                   if (attributeName == null)
                        throw new IllegalArgumentException("Attribute name must not be null");
                   if (comparator == null)
                        comparator = DEFAULT;
                   this.attributeName = attributeName;
                   this.comparator = comparator;
                   this.compareAsText = compareAsText;
                   this.sortDirection = true;
                   this.subNodes = subNodes;
               * Sets the sort direction of this comparator to the given direction. The comparator sort in ascending order by default.
               * @see com.sap.tc.webdynpro.clientserver.uielib.standard.api.WDTableColumnSortDirection
              public void setSortDirection(WDTableColumnSortDirection direction){
                   if(direction.equals(WDTableColumnSortDirection.UP)){
                        sortDirection = true;
                   }else if(direction.equals(WDTableColumnSortDirection.DOWN)){
                        sortDirection = false;
               * Compares the given objects which must be instances of <code>IWDNodeElement</code>
               * according to the values of the attribute given at construction time
               * with the help of the comparator given at construction time.
               * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
               * @see com.sap.tc.webdynpro.progmodel.api.IWDNodeElement
              public int compare(Object o1, Object o2) {
                   IWDNodeElement element1 = (IWDNodeElement) o1;
                   IWDNodeElement element2 = (IWDNodeElement) o2;
                   if(subNodes.size() > 0){
                        element1 = getSubNodeElement(element1, 0);
                        element2 = getSubNodeElement(element2, 0);
                   Object attributeValue1 = null;
                   Object attributeValue2 = null;
                   if(element1 != null){
                        attributeValue1 =
                             compareAsText
                                  ? element1.getAttributeAsText(attributeName)
                                  : element1.getAttributeValue(attributeName);
                   if(element2 != null){
                        attributeValue2 =
                             compareAsText
                                  ? element2.getAttributeAsText(attributeName)
                                  : element2.getAttributeValue(attributeName);
                   if(sortDirection){
                        return comparator.compare(attributeValue1, attributeValue2);
                   }else{
                        return comparator.compare(attributeValue2, attributeValue1);
               * Determines recursivly the child node, which have an attribute with the given name.
               * The path to this child node must be specified in the subnodes property of this comparator.
               * Start this method with index = 0.
              private IWDNodeElement getSubNodeElement(IWDNodeElement currentElement, int index){
                   if(currentElement == null || index >= subNodes.size()){
                        //end of recursion
                        return currentElement;
                   }else{
                        return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getCurrentElement(), index+1);
                        //return getSubNodeElement(currentElement.node().getChildNode((String)subNodes.toArray()[index], currentElement.index()).getElementAt(0), index+1);
               * Name of the attribute used for comparisons.
              private final String attributeName;
               * Comparator used for comparing the attribute's values.
              private final Comparator comparator;
               * Indicates whether attribute values are compared as text (as opposed to
               * "as objects").
              private final boolean compareAsText;
               * Sort direction (true = ascending order, false = descending order)
              private boolean sortDirection;
               * List of child node names
               * (Description of the path from the given context node to the specified attribute)
              private Collection subNodes;
    Re: Webdynpro Table: Column Header sort icon not visible
    Regards,
    Mithu

  • Selecting data from a table using Execute Immediate in 9i

    Hi,
    I was wondering how I would be able to do a SELECT on a table using EXECUTE IMMEDIATE. When I tried it (with the proc below), I got the following below. Can anyone tell me what I am doing wrong?
    Using Scott/Tiger I tried this:
    SQL> ed
    Wrote file afiedt.buf
    1 CREATE OR REPLACE PROCEDURE P2
    2 IS
    3 v_SQL VARCHAR2(100);
    4 BEGIN
    5 v_SQL := 'Select * from Emp';
    6 EXECUTE IMMEDIATE v_SQL;
    7* END;
    SQL> /
    Procedure created.
    SQL> exec p2
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on
    SQL> exec p2
    PL/SQL procedure successfully completed.
    SQL>
    Thanks in advance.
    Sincerely,
    Nikhil Kulkarni

    1 CREATE OR REPLACE PROCEDURE P2
    2 IS
    3 v_SQL VARCHAR2(100);
    erec emp%rowtype;
    4 BEGIN
    5 v_SQL := 'Select * from Emp';
    6 EXECUTE IMMEDIATE v_SQL into erec;
    7* END;
    SQL> /

  • Text Overlapping/Wrapping Issue in BSP(Table Sorter Using JQUERY)

    Hi ,
    I have a requirement to add a new column in existing table which has been built by Table Sorter method in JQUERY.
    I have added the new column but the issue is value for the new column is populated  on next line of the table.
    This could be a simple width issue, but i don't know JAVA much.Attached the image for reference.
    Code i have used is:
    <input type="text" name="t_rbclaim[<%= lv_tabix%>].reason" size="3" maxlenth="3" wrapping = "true"
         onBlur="javascript:this.value=this.value.toUpperCase();" value="<%= w_rbclaim-reason%>">
    Please let me know how to modify the above code in better way.

    Hi Raja,
    Can you please help on this problem. I want to know whether there is any funciton module to convert the univercel character set code (HTML Codepage) page to SAP codepage. We are going to use ECC 6.0 which is unicode system for background R/3. So we can get the correct character format if identify the correct conversion method.
    Please let me know if any information and expect some information on this.
    Regards,
    Saravanan V

  • Can't parse WSDL when useProxy=true

    Hello everyone.
    I'm using Flex since 1.5 and now try to migrate Flex2.0.
    Most of our application need to access data via WebService,
    and we use <mx:WebService> tag to access them.
    In our Flex1.5 environment, we also use Proxy service of Flex
    (with specifying useProxy=true), and it works fine.
    But in Flex2.0, our mxml application can't parse the same
    WSDL when useProxy=true!
    On the other hand, our application can parse correctly when
    not using proxy service. (useProxy=false and set crossdomain.xml on
    the root of datasource Web server.)
    I'was so confusing that I captured HTTP traffic between
    client application and server( both FlexDataService and Data source
    Web Server), with ServiceCapture.
    When useProxy=true, at first, client application sent request
    to Flex Data Service to get not only calling the SOAP operations
    but also calling WSDL itself. After that, Flex Data Service
    returned the response message as WSDL data, and I found the WSDL
    data was broken.
    When useProxy=false, of cource, the WSDL was passed
    datasource Web Server correctly and application could parse it
    without problem.
    These parse error depends on the WebService.
    I wonder this is some bug of Flex Data Service or not.......

    Hello, everyone.
    After that, I tried to change the encoding of WSDL, which was
    broken when useProxy=true, from UTF-16 to UTF-8.
    And I could get correct WSDL data from Flex Data Service's
    proxy.....
    It seems when the encoding of WSDL is UTF-16, the parse is
    failed, but I'm not sure this problem is happened commonly and this
    is some of the bug of Flex Data Services.

Maybe you are looking for