Hello Juan,
this was tricky! The String parameter for RenderSupport.addScript(...) somewhere deep in the code is passed to String.format(...). In String.format(...) the percent sign indicates a conversion. "%," is no valid conversion, hence the Exception. To get rid of that error you have to mask the "%". This is done by doubling it up (i.e. "%%"). I have rewritten your Mixins java class and it works.


import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ClientElement;
import org.apache.tapestry5.RenderSupport;
import org.apache.tapestry5.annotations.AfterRenderBody;
import org.apache.tapestry5.annotations.InjectContainer;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

public class ModalPage {

    /**
     * Added this for the code to compile.
     */
    @InjectContainer
    private ClientElement element;

    /**
     * DEPRECATED, better use {@link JavaScriptSupport}.
     */
    @Inject
    private RenderSupport renderSupport;

    @Parameter(value = "null", defaultPrefix = BindingConstants.LITERAL)
    private String boxParams;

    @AfterRenderBody
    public void afterRenderTemplateLink() {

String comando = String.format("new ModalPage('" + element.getClientId() + "', " + braceWithQuotes(this.doubleUpPercentInBoxParams()) + ");");

        renderSupport.addScript(comando);
    }

    /**
* {@link RenderSupport#addScript(String)} passes the string argument to * {@link String#format(String, Object...)}. This causes trouble, if string * contains "%" as this is misinterpreted as a format conversion. We need to
     * mask it. In String format this is done with "%%".
     *
     * @return
     */
    private String doubleUpPercentInBoxParams() {

        return this.boxParams.replaceAll("%", "%%");
    }

    private String braceWithQuotes(String value ) {
        return value.equals("null") ? value : "'" + value + "'";
    }

}

Am 06.07.2011 17:34, schrieb Juan Alba:
sorry guys, de error shown is this one, not the one sent before:

org.apache.tapestry5.internal.services.RenderQueueException
Render queue error in AfterRenderBody[proxy/menu/EndPoint:showendpointlink]:
Conversion = o, Flags = ,



On Wed, Jul 6, 2011 at 12:17 PM, Juan Alba<juan.a...@condortech.com.ar>wrote:

Hi,

Thanks for the help Nillehammer, here is the code:

/*JAVA*/
public class ModalPage {

    @Parameter(value="null", defaultPrefix = BindingConstants.LITERAL)
     private String boxParams;

     @AfterRenderBody
     public void afterRenderTemplateLink() {

        String comando = String.format("new ModalPage('"
  + element.getClientId() + "', " + braceWithQuotes(boxParams) + ");");

             renderSupport.addScript(comando);
     }

private String braceWithQuotes(String value) {
return value.equals("null") ? value : "'"+value+"'";
  }

}


/*TML*/

<div class="row">
<t:actionLink t:id="myLink" id="myLink" title="${message:listendpoint}"
  t:mixins="condorTapestryLib/ModalPage"
t:boxParams="width:50%,opacity:0.7,escKey:true,overlayClose:false">

  ${message:endpoints}
</t:actionLink>
</div>


--
http://www.winfonet.eu


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to