2

スケジュールされたジョブに関するドキュメントを html として入力できるアプリケーション (AppWorx! 誰かこのタグを作成してください!) を使用しています。

私は、次のようなリンクを持つオンコール ドキュメントを作成しようとしています。

<a href="tel:+1806xxxxxxx">1 (806) xxx - xxxx</a>

ページは Java アプリ自体の内部に表示され、http:// へのリンクはユーザーのブラウザー ウィンドウで開かれます。しかし、上記のような tel リンクにより、大きなエラー ウィンドウがポップアップし、次のエラーが表示されます。

java.net.MalformedURLException: For input string: "+1806xxxxxxx"
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at java.net.URL.<init>(Unknown Source)
    at com.appworx.client.screen.modmgr.M$2.hyperlinkUpdate(NotesPanel.java:191)
    at javax.swing.JEditorPane.fireHyperlinkUpdate(Unknown Source)
    at javax.swing.text.html.HTMLEditorKit$LinkController.activateLink(Unknown Source)
    at javax.swing.text.html.HTMLEditorKit$LinkController.mouseClicked(Unknown Source)
    at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)

他のプロトコルも失敗します (http を除く)。mailto: リンクがある場合、上記のエラーではなく、メール アドレスのドメイン部分に移動します。

アプリがコンパイルされたこのクラスのバージョンは、何年も前のものだと思います。

このクラスの制限は何か、または回避策が存在するかどうかを誰か教えてもらえますか?

Appworx のドキュメントでは、アプリが jnlp から呼び出されない限り、http リンクでさえ機能しないことが示唆されています (これはどういうわけかサンドボックスのことですか?)。ただし、ここでは、他の方法でアプリケーションを起動する人は誰もいません。

4

1 に答える 1

1

このクラスの制限を誰か教えてもらえますか?

EditorKit クラスがいかに時代遅れであるかを示すために、Java 7 の時点でHTMLEditorKitは" HTML バージョン 3.2 (いくつかの拡張機能付き) をサポートし、バージョン 4.0 に移行しています"。URLMalformedURLExceptionクラス (投稿したトレースの責任者) が基本的なプロトコルのみをサポートしていることは驚くことではありません。

  • Http
  • https
  • FTP
  • ファイル
  • ジャー

回避策が存在するかどうか誰か教えてもらえますか?

コードに手を加えて (アクセスできる場合)、カスタム プロトコル ハンドラを使用して登録することができます。幸いなことに、 J2ME ポーランド プロジェクトtelの厚意により、プロトコル用に既に 1 つ用意されています。

package de.enough.polish.browser.protocols;

import java.io.IOException;

import javax.microedition.io.StreamConnection;
import javax.microedition.midlet.MIDlet;

import de.enough.polish.browser.ProtocolHandler;

/**
 * Protocol handler to handle the <code>tel:</code> protocol. This class calls the given phonenumber on MIDP 2.0 phones.
 * Example: &lt;a href=&quot;tel:+441231234567#22&quot;&gt;Call Me&lt;/a&gt;
 * Note that this handler requires MIDP 2.0 or higher.
 * The tel protocol handler allows you to separate the phone number and the dialtone (dtmf) that should be send after
 * establishing the phone call using the '#' sign.
 * 
 * This protocol could actually be realized using the ExternalProtocolHandler as well, however in this
 * way we can deal post dial tones (DTMF) in a better way - in the HTML code they just need to be 
 * separated from the phonenumber using a '#'.
 */
public class TelProtocolHandler
extends ProtocolHandler
{
    private MIDlet midlet;

    /**
     * Creates an TellProtocolHandler object using the default "tel" protocol name.
     * 
     * @param midlet the midlet object of the application
     */
    public TelProtocolHandler(MIDlet midlet)
    {
        this( "tel", midlet );
    }

    /**
     * Creates an TelProtocolHandler object using the specified protocol name.
     * 
     * @param protocolName the name of the protocol to handle
     * @param midlet the midlet object of the application
     */
    public TelProtocolHandler(String protocolName, MIDlet midlet)
    {
        super( protocolName );
        this.midlet = midlet;
    }


    /* (non-Javadoc)
     * @see de.enough.polish.browser.ProtocolHandler#getConnection(java.lang.String)
     */
    public StreamConnection getConnection(String url) throws IOException
    {
        this.midlet.platformRequest( "tel:" + extractMsisdn(url));
        return null;
    }

    /**
     * Strips the MSISDN part off an url. 
     * In contrast to other protocol handlers, the external protocol handler only uses a single colon to
     * separate the external protocol from the folllowing protocol, e.g. external:http://www.j2mepolish.org
     * 
     * @param url the url to remove the protocol from
     * 
     * @return the host and part part of the given url
     */
    protected String extractMsisdn(String url)
    {
        String msisdn = url.substring(this.protocolName.length() + 1);
        String separator = null;
        //#if polish.dtmf.separator:defined
            //#= separator = "${polish.dtmf.separator}";
            //# if (!separator.equals("#")) {
                //# int pos = msisdn.indexOf('#');
                //# if (pos != -1) {
                    //# msisdn = msisdn.substring(0, pos) + separator + msisdn.substring(pos + 1); 
                //# }
            //# }
        //#endif
        return msisdn;
    }

}

それが役立つことを願っています!

于 2013-11-05T22:51:03.550 に答える