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
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