tel scheme (telephone)

Splash Forums Rewrite Users tel scheme (telephone)

Tagged: 

This topic contains 5 replies, has 2 voices, and was last updated by  Christian Kaltepoth 3 years, 2 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #23755

    christophe
    Participant

    I am using urls containing the phone scheme tel:somephonenumberhere, it seems rewrite only supports mailto:someemailhere, here is the stacktrace:
    java.lang.IllegalArgumentException: [tel:] is not a valid URL fragment. Consider encoding relevant portions of the URL with [class org.ocpsoft.urlbuilder.util.Encoder]
    at org.ocpsoft.urlbuilder.AddressBuilder.create(AddressBuilder.java:82)
    at org.ocpsoft.rewrite.servlet.impl.HttpRewriteWrappedResponse.encodeURL(HttpRewriteWrappedResponse.java:388)
    at com.sun.faces.context.ExternalContextImpl.encodeResourceURL(ExternalContextImpl.java:543)
    at javax.faces.context.ExternalContextWrapper.encodeResourceURL(ExternalContextWrapper.java:132)
    at com.sun.faces.renderkit.html_basic.OutputLinkRenderer.renderAsActive(OutputLinkRenderer.java:239)
    at com.sun.faces.renderkit.html_basic.OutputLinkRenderer.encodeBegin(OutputLinkRenderer.java:107)

    The view code:
    <h:outputLink value="tel:#{listItem.mobile}">#{listItem.mobile}</h:outputLink>

    Note I am also using the fax scheme. I do not think I should have to do any modification to continue using those schemes.
    I was using PrettyFaces before I migrated to Rewrite.

    #23756

    Hi,

    it seems like Rewrite tries to create a java.net.URI from your URL which fails. Could you perhaps post the full stacktrace. There should be a caused by part which may be interesting.

    BTW: You can work around this problem by simply using a plain <a> link instead, which I would prefer in any cases because it doesn’t create an extra component in the component tree:

    
    <a href="#{listItem.mobile}">
      #{listItem.mobile}
    </a>
    
    #23758

    christophe
    Participant

    Caused by: java.net.URISyntaxException: Expected scheme-specific part at index 4: tel:
    at java.net.URI$Parser.fail(URI.java:2809)
    at java.net.URI$Parser.failExpecting(URI.java:2815)
    at java.net.URI$Parser.parse(URI.java:3018)
    at java.net.URI.<init>(URI.java:578)
    at org.ocpsoft.urlbuilder.AddressBuilder.create(AddressBuilder.java:77)
    … 73 more

    Could indeed use simple html in that case.

    #23759

    Is it possible that #{listItem.mobile} is null or empty in your case? I just tested whether URI can parse tel URLs and and seems to work fine. I only doesn’t work if I try to parse tel: which is NOT valid and throws exactly the same exception like you got.

    Perhaps you could do something like this:

    
    <h:outputLink value="tel:#{listItem.mobile}" rendered="#{ not empty listItem.mobile }">
      #{listItem.mobile}
    </h:outputLink>
    
    #23761

    christophe
    Participant

    As I did not get any errors with this code using PrettyFaces I suspected it was some bug of Rewrite, the error helped find out that I was missing not empty checks in that part of the code. The mailto: never failed because the email is required… So thanks for Rewrite and taking some time helping me out.

    #23762

    It’s not really a bug in Rewrite. But Rewrite seems to fail for invalid URLs while PrettyFaces doesn’t.

    However, I’m glad to hear you fixed your problem. 🙂

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Comments are closed.