Update... It seems if I refresh the page then the selected items show

On 1/11/06, Chris Chiappone <[EMAIL PROTECTED]> wrote:
> Still Confused.  I know that my selectedItems collection contains my
> object, yet the currSelected never returns true.  Actually it seems to
> only get called once when the page loads.  Shouldn't isCurrSelected()
> get executed everytime linkToggle listener gets called?
> I'll include my code again with some mods since last time:
>
>        public void toggleCase(IRequestCycle irc) {
>                String caseid = (String) irc.getListenerParameters()[0];
>                TrCase trCase = 
> getCaseHome().findCaseById(Long.parseLong(caseid));
>                Collection<TrCase> c = getSelectedItems();
>
>                boolean contains = containsItem(c, trCase.getIdAsString());
>
>                if (contains) {
>                        log.info("Selected Item contains Case #"+ 
> trCase.getId());
>                        c.remove(trCase.getIdAsString());
>                } else {
>                        log.info("Selected Item doesn't contain Case #"+ 
> trCase.getId());
>                        c.add(trCase);
>                }
>                setSelectedItems(c);
>                AjaxWebRequest ajax = (AjaxWebRequest) irc
>                                .getAttribute(AjaxWebRequest.AJAX_REQUEST);
>                if (ajax != null)
>                        ajax.addStatusResponse("Case selected..");
>
>        }
>
>        public Collection<TrCase> getCases(){
>                log.info("Getting cases from DB...");
>                List cases = new ArrayList<TrCase>(getCaseHome()
>                .findCasesBySupportId(getVisitObject().getPortaluser()
>                                .getSupportid()));
>                return cases;
>        }
>
>        private boolean containsItem(Collection<TrCase> c, String item){
>                Iterator<TrCase> it = c.iterator();
>                boolean contains = false;
>                while(it.hasNext()){
>                        TrCase test = it.next();
>
>                        if(item.equals(test.getIdAsString())){
>                                contains = true;
>                                continue;
>                        }
>                }
>                return contains;
>        }
>
>        //public abstract Collection<TrCase> getCases();
>        //public abstract void setCases(Collection<TrCase> cases);
>        @Persist
>        public abstract Collection<TrCase> getSelectedItems();
>        public abstract void setSelectedItems(Collection<TrCase> 
> selectedItems);
>
>
>        public void openCaseListener(IRequestCycle cycle) {
>                cycle.activate(getOpenCasePage());
>        }
>
>        public abstract boolean isOpenCases();
>        public abstract void setOpenCases(boolean openCases);
>
>        public boolean isCurrSelected() {
>                boolean contains = containsItem(getSelectedItems(),
> getCurrCase().getIdAsString());
>                log.info("Current Selected returns "+ contains);
>                return contains;
>        }
>
> Annotations in the same class:
>        @Component(id="foreachCase", type="tacos:PartialFor", bindings = {
>                "source=cases", "value=currCase",
>                "evenOdd=ognl:page.beans.evenOdd"})
>        public abstract PartialForBean getForeachCase();
>
>        @Component(id="linkToggle", type="tacos:AjaxDirectLink",
>                        bindings = {"listener=listener:toggleCase",
>                        "parameters=ognl:currCase.idAsString",
>                        "updateComponents=ognl:{'selectedCases', 
> currCase.idAsString}",
>                        
> "effects=template:{highlight:{selectedCases:'[255,255,184], 500,
> 500','${currCase}':'[255,255,184], 500, 500'}}",
>                        "statusElement=literal:status"})
>        public abstract AjaxDirectLink getLinkToggle();
>
> And the html:
>
>                <div jwcid="[EMAIL PROTECTED]" id="selectedCases"><span
>                                                                jwcid="@If" 
> condition="ognl:not selectedItems.empty">
>                                                        <h3>Selected Cases</h3>
>                                                        <ul>
>                                                                <li 
> jwcid="@tacos:PartialFor" source="ognl:selectedItems"
>                                                                        
> value="ognl:selectItem" element="li"><span jwcid="@Insert"
>                                                                        
> value="ognl:selectItem.id" /></li>
>                                                        </ul>
>                                                        </span></div>
>                                                        <div id="status"></div>
>                                                        <div id="cases"><span 
> jwcid="foreachCase">
>                                                        <div jwcid="@Any" 
> class="ognl:beans.evenOdd.next"
>                                                                
> id="ognl:currCase.id">
>
>                                                        <div><a 
> jwcid="linkToggle" class="toggle"> <span jwcid="@Insert"
>                                                                
> value="ognl:currSelected ? 'Hide' : 'Details'" /></a> <span
>                                                                
> jwcid="@Insert" value="ognl:currCase.id"
>                                                                
> class="ognl:currSelected ? 'detailHeading' : 'heading'" /></div>
>
>                                                        <span jwcid="@If" 
> condition="ognl:currSelected">
>                                                        <div 
> class="caseDetail">
>                                                        <div 
> class="acase"><!-- <img jwcid="flagImage" width="34"
> height="18" />--><br />
>                                                        <span jwcid="@Insert" 
> value="ognl:currCase.id" /></div>
>
>
> On 1/11/06, Jesse Kuhnert <[EMAIL PROTECTED]> wrote:
> > You shuold be able to,but are now getting into an area that is anyone's
> > guess. If you can provide me a web address to hit your page in, or a very
> > very easy to deploy web-app I can look further into it and make appropriate
> > documentation and/or library changes based on what you're running into..
> >
> > On 1/11/06, Edgar Chan Carrillo <[EMAIL PROTECTED]> wrote:
> > >
> > > Thanks for the response Jesse.
> > > Yes.I think it is.
> > > My page starts with a search option and an empty list...I do a search and
> > > render the result using PartialFor (a list of divs with ids corresponding
> > > of
> > > the ids of the objects'result query).
> > > Each generated div include an AjaxDirectLink to show aditional info for
> > > the
> > > element.
> > >
> > > The firefox dom inspector correctly shows the generated divs and ids, no
> > > matter how many times i perform the search. I think that means the dom
> > > objects already exists in the page by that time.
> > > Can i do this?
> > >
> > >
> >
> >
>
>
> --
> ~chris
>


--
~chris

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to