I just added a utility in AjaxUtils,
boolean isAjaxComponent(IRequestCycle cycle, String compId)

If you do boolean ajax = AjaxUtils.isAjaxComponent(cycle, thisId)
instead of
boolean ajax = AjaxUtils.isAjaxCycle(cycle)
it should do the trick. BTW, I'm not committing this small change
'cause i'm too lazy right now to setup a test page for it :)

On 5/23/07, Zsombor <[EMAIL PROTECTED]> wrote:



On 5/23/07, Miguel Angel Hernández <[EMAIL PROTECTED]> wrote:
>
> I solved this by implementing an extension of the tacos IdBean class and
> reimplementing the render component method like this:
>
> protected void renderComponent(IMarkupWriter writer, IRequestCycle
> cycle) {
>         String element = getElement();
>
>         if (element == null)
>             throw new ApplicationRuntimeException(
>                     "element property is not bound", this, null, null);
>
>         boolean rewinding = cycle.isRewinding ();
>         boolean ajax = AjaxUtils.isAjaxCycle(cycle);
>
>         // trigger registration of id, no matter what...
>         String thisId = getBeforeId();
>         setAfterId(thisId);
>         boolean isInAjaxRequest = false;
>         if(ajax) {
>             AjaxWebRequest ajaxWebReq = (AjaxWebRequest) cycle
>                     .getAttribute(AjaxWebRequest.AJAX_REQUEST);
>              isInAjaxRequest = ajaxWebReq.containsComponentId (thisId);
>         }
>         if (!rewinding && !(ajax && isInAjaxRequest)) {
>             writer.begin(element);
>
>             renderInformalParameters(writer, cycle);
>             writer.attribute ("id", thisId);
>         }
>
>         renderBody(writer, cycle);
>
>         if (!rewinding && !(ajax && isInAjaxRequest)) {
>             writer.end(element);
>         }
>         setClientId(null);
>     }
>
> The trick is adding the isInAjaxRequest to the condition for rendering
> the element emulated by the Id. This means that if the request its an ajax
> request but doesn't has this element in its updateComponents collection it
> renders as normal.
>
> This worked nice for me, and I wonder if this should be added to the
> original IdBean?
>
> thanks
>
> Miguel



Ahh, I see. You have recursive idBean-s ! Yes, I think you are correct, in
that case div-s should be emitted, if it's not the outer most idBean. Thanks
for figuring out, for us, and for you :) I will check in, when I will have
time

BR,
 Zsombor



On 5/22/07, Miguel Angel Hernández <[EMAIL PROTECTED]> wrote:
> >
> >
> > Hello everybody,
> >
> > I have the following problem while I'm trying to implement my own
> > Dialog:
> >
> > I have a tacos:Id div inside a component:
> >
> > <div jwcid="[EMAIL PROTECTED]:Id">
> >        <span jwcid=" [EMAIL PROTECTED]"
> > ancla="literal:superSubmit" muestra="ognl:muestraFC">
> >                <form jwcid="@tacos:AjaxForm">
> >                     <span jwcid=" [EMAIL PROTECTED] :AjaxEventSubmit"
> > action="listener:doSomething"
> >
> > effects="template:{highlight:{any:'[255,255,184], 500, 500'}}"
> >                         updateComponents="ognl:{'changing_part'}"
> >                         />
> >                     This is a custom dialog.
> >                     <br/>
> >                      <div jwcid="[EMAIL PROTECTED]:Id">
> >                     Actual: <span jwcid="@Insert"
> > value="ognl:actual"/>
> >                     </div>
> >                     <br/>
> >                     New: <span jwcid="@TextField" value="ognl:valor"
> > eventListener="onchange= components.newChange.id"/>
> >                     <br/>
> >                     <input jwcid="@tacos:AjaxSubmit"
> > listener="listener:borraPopup"
> >                         value="do something"
> > updateComponents="ognl:{'my_dialog'}"/>
> >
> >                 </form>
> >        </span>
> >     </div>
> >
> >
> > And whenever I update 'my_dialog' element as an updateElement
> > parameter form an ajax response,
> > my div is lost (i,e. element isn't rendered, just it contents). So it
> > can no longer be updated by my AjaxEventSubmit.
> >  The problem clearly seems to be:
> >
> > protected void renderComponent(IMarkupWriter writer, IRequestCycle
> > cycle)
> >     {
> >         String element = getElement();
> >
> >         if (element == null)
> >             throw new ApplicationRuntimeException("element property is
> > not bound", this,
> >                     null, null);
> >
> >         boolean rewinding = cycle.isRewinding();
> >         boolean ajax = AjaxUtils.isAjaxCycle(cycle);
> >
> >         // trigger registration of id, no matter what...
> >         String thisId = getBeforeId();
> >         setAfterId(thisId);
> >         if (!rewinding && !ajax)
> >         {
> >             writer.begin(element);
> >
> >             renderInformalParameters(writer, cycle);
> >             writer.attribute("id", thisId);
> >         }
> >
> >         renderBody(writer, cycle);
> >
> >         if (!rewinding && !ajax)
> >         {
> >             writer.end(element);
> >         }
> >         setClientId(null);
> >     }
> >
> > I guess this is to avoid nesting the element in itself whenever its
> > updated directly (not as a nested component) by an AjaxResponse.
> >
> > Still, I'm trying to find a way to include an updatable div like
> > component inside my dialog, in order to be updated by any AjaxSubmit inside
> > the
> > dialog.
> >
> > Any Ideas?
> >
> > thanks in advance
> >
> > Miguel Hernández
> >
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Tacos-devel mailing list
> Tacos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tacos-devel
>
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Tacos-devel mailing list
Tacos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tacos-devel




--
Andreas Andreou - [EMAIL PROTECTED] - http://andyhot.di.uoa.gr
Tapestry / Tacos developer
Open Source / JEE Consulting
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Tacos-devel mailing list
Tacos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tacos-devel

Reply via email to