cancel
Showing results for 
Search instead for 
Did you mean: 

new button action problem with page rendering

friedman30
Champ in-the-making
Champ in-the-making
Hi,

i've used web-client-config-actions.xml file to create 2 buttons that affect an Index property of contents. (the idea is to sort the table by this Index and leave the users the ability to move the content up and down by changing this Index).

so. now i have a full control of the Index property, and the buttons work fine,
but i can't get the table to render with the new parameters after the Index is changed….

i am calling the sort method of the table (UIRichList) right after changing the index properties at the action method of the button, but still - i don't see the sorted table till the next time i enter the page… :?

what should i do to make the table render with the new sorted dataModel after the action of the button is invoked? ? ?   
:?:  :?:  :?:

Thanks,

Dror
3 REPLIES 3

friedman30
Champ in-the-making
Champ in-the-making
I solved the problem, and now i can see the rendered table right after the button is pressed.

but…. :? 
… I am not sure it is the best way (i'm actually quite sure it is not).

what i've done is to get the model from the session, and change the 'Index' property there.

Map session = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
      BrowseBean browseBean = (BrowseBean)session.get("BrowseBean");
      UIRichList spacesRichList = browseBean.getSpacesRichList();
      ArrayList <MapNode>arr = (ArrayList)spacesRichList.getValue();
      if(arr != null)
      {
         for(MapNode node:arr)
         {
            Long currentIndex = (Long)node.get("{custom.model}Index");
            if(currentIndex == index-1)
            {
               node.put("{custom.model}Index", index);
            }
            if(currentIndex == index)
            {
               node.put("{custom.model}Index", index-1);
            }
         }
         spacesRichList.setValue(arr);
      }
this solved the rendering problem, but the model is not saved this way….. (i can't understand why  :shock: )

so, i've added the code that i used at the first time, and changed the 'Index' property once more. this time i used nodeService.

List<ChildAssociationRef> list = nodeService.getParentAssocs( ref);      
      ChildAssociationRef parent = list.get( 0);          
      List<ChildAssociationRef> childRefs = nodeService.getChildAssocs(parent.getParentRef(),
            ContentModel.ASSOC_CONTAINS,
            RegexQNamePattern.MATCH_ALL);

      for (ChildAssociationRef childAssRef : childRefs)
      {
         if ((Long)nodeService.getProperty(  childAssRef.getChildRef(), qualifiefName) == index - 1)
         {
            nodeService.setProperty(childAssRef.getChildRef(), qualifiefName, index);
            break;
         }
      }   

      nodeService.setProperty( ref, qualifiefName, –index);

so now I got it working, but i am changing the same property twice to get it done….


what is the way to address the data model once, change a property, and render the page with the new data model ????

thanks,

Dror :?:

gavinc
Champ in-the-making
Champ in-the-making
You could try calling….

UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();

you may also need to call reset on the Node object representing the thing you are changing. The client has a cache of the node's properties so after changing one you need to call reset() to get them re-read from the server.

These 2 things may help you.

friedman30
Champ in-the-making
Champ in-the-making
this works  Smiley Very Happy

thanks!!