• pageTreeNode : selected property should be computable

    By Michael Bourak 1 decade ago

    Hi,

     Currently, thefor the PageTreeNode, the "selected" property does not accept hard coded or computed values.

    I looked at the code and it looks for selection (a regexp) ... but does not use the computed expression if we put one in selected.

    I suspect it can be true for other properties too, no checked yet.

     

    Here is the modified method to correct this :(have to add a selected private variable, and save/restore it in state management part too).

     

     

    @Override

    public boolean isSelected() {

    // Added by Michael : check for a value or a value binding first

    if (null != this.selected) {

    return this.selected;

    }

    ValueBinding _vb = getValueBinding("selected"); //$NON-NLS-1$

    if (_vb != null) {

    Boolean val = (java.lang.Boolean) _vb.getValue(FacesContext.getCurrentInstance());

    if(val!=null) {

    return val;

    }

    }

    //  end : Added by Michael

     

    // Look if there is a selection string and if it matches the navigation path

    String selection = getSelection();

    if(StringUtil.isNotEmpty(selection)) {

    FacesContext ctx = FacesContext.getCurrentInstance();

    ConversationState cs = ConversationState.get(ctx, false);

    if(cs!=null) {

    String navPath = cs.getNavigationPath();

    if(StringUtil.isNotEmpty(navPath)) {

    return navPath.matches(selection);

    }

    }

    return false;

    }

     

    // Else if it points to a page, then see if the page matches

    String page = ExtLibUtil.getPageXspUrl(getPage());

    if(StringUtil.isNotEmpty(page)) {

    FacesContext ctx = FacesContext.getCurrentInstance();

    String currentPage = ((UIViewRootEx)ctx.getViewRoot()).getPageName();

    return StringUtil.equals(page, currentPage);

    }

     

    return super.isSelected();

    }

    • This had been changed recently

      By Philippe Riand 1 decade ago

      In the 853 release, it first look at the selection. If this returns true, then it is selected. Else, it then look for the XPages URL and return true if it matches. Finally, it uses the isSelected(). I understand what you mean, but changing this behavior can currently break application. The PageTreeNode is finally a helper. You can still use a BasicLeafNode and have a completely custom behavior there.