JPro-one / jpro-routing

Small web-framework for JPro
https://www.jpro.one
Apache License 2.0
6 stars 0 forks source link

LinkUtil.setLink() for phone_no is no longer works in latest stable jpro-routing build! #10

Closed ctoabidmaqbool closed 1 year ago

ctoabidmaqbool commented 1 year ago

Hi devs! In latest stable jpro-routing build e.g. one.jpro:jpro-routing-core:0.14.0, phone_no as link e.g. LinkUtil.setLink() no longer works!

Error:

java.lang.AssertionError: assertion failed: Invalid link: 'tel:+923020506910''
    at scala.Predef$.assert(Predef.scala:223)
    at one.jpro.routing.LinkUtil$.setLink(LinkUtil.scala:51)
    at one.jpro.routing.LinkUtil$.setLink(LinkUtil.scala:41)
    at one.jpro.routing.LinkUtil.setLink(LinkUtil.scala)
    at com.jpro.hellojpro.InfoPage.content(App.java:80)
    at one.jpro.routing.View.realContent$lzycompute(View.scala:14)
    at one.jpro.routing.View.realContent(View.scala:14)
    at one.jpro.routing.sessionmanager.SessionManagerWeb.gotoURL(SessionManagerWeb.scala:46)
    at one.jpro.routing.sessionmanager.SessionManager.$anonfun$gotoURL$2(SessionManager.scala:59)
    at one.jpro.routing.sessionmanager.SessionManager.$anonfun$gotoURL$2$adapted(SessionManager.scala:57)
    at simplefx.experimental.parts.FXFuture.$anonfun$map$6(FXFuture.scala:170)
    at simplefx.cores.interfaces.parts.CoreTypesBindable$SOBindableAssign.$colon$eq(CoreTypesBindable.scala:150)
    at simplefx.cores.interfaces.parts.CoreTypesBindable$SOBindableAssign.$colon$eq$(CoreTypesBindable.scala:149)
    at simplefx.cores.standard.parts.CoreTypesBindable$BindableImpl.$colon$eq(CoreTypesBindable.scala:24)
    at simplefx.experimental.parts.FXFuture.$anonfun$map$5(FXFuture.scala:170)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at simplefx.cores.standard.parts.CoreTimeEvent.runOnceWhen(CoreTimeEvent.scala:139)
    at simplefx.cores.standard.parts.CoreTimeEvent.runOnceWhen$(CoreTimeEvent.scala:137)
    at simplefx.cores.standard.Core.runOnceWhen(Core.scala:9)
    at simplefx.cores.interfaces.parts.CoreTimeEvent$OnceWhenBoolean.$minus$minus$greater(CoreTimeEvent.scala:159)
    at simplefx.experimental.parts.FXFuture.$anonfun$map$3(FXFuture.scala:170)
    at simplefx.cores.standard.parts.CoreTimeEvent.$anonfun$runAsAnimation$1(CoreTimeEvent.scala:64)
    at simplefx.cores.standard.parts.CoreTimeEvent$$anon$2.handle(CoreTimeEvent.scala:46)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.lambda$handle$0(AnimationTimer.java:58)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at javafx.animation.AnimationTimer$AnimationTimerReceiver.handle(AnimationTimer.java:57)
    at com.sun.scenario.animation.AbstractPrimaryTimer.timePulseImpl(AbstractPrimaryTimer.java:356)
    at com.sun.scenario.animation.AbstractPrimaryTimer$MainLoop.run(AbstractPrimaryTimer.java:266)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:581)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:565)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulseFromQueue(QuantumToolkit.java:558)
    at com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$12(QuantumToolkit.java:358)
    at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
    at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
    at java.base/java.lang.Thread.run(Thread.java:833)

In previous jpro-routing only warning was shown as:

Warning, link is not valid: tel:+923020506910

Sample program:

package com.jpro.hellojpro;

import com.jpro.routing.LinkUtil;
import com.jpro.routing.Route;
import com.jpro.routing.RouteApp;
import com.jpro.routing.View;
import com.jpro.webapi.WebAPI;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.LinkedHashMap;
import java.util.Map;

import static com.jpro.routing.RouteUtils.get;
import static com.jpro.routing.RouteUtils.redirect;

public class App extends RouteApp {
    private Stage pStage;

    @Override
    public void start(Stage pStage) {
        this.pStage = pStage;
        super.start(pStage);
    }

    @Override
    public Route createRoute() {
        return Route.empty()
                .and(redirect("/", "/info"))
                .and(get("/info", (r) -> new InfoPage(pStage)));
    }
}

class InfoPage extends View {
    private Stage pStage;

    public InfoPage(Stage pStage) {
        this.pStage = pStage;
    }

    @Override
    public String title() {
        return "Sample JPro Page";
    }

    @Override
    public String description() {
        return "This is a simple page where JPro testing done.";
    }

    @Override
    public Node content() {
        VBox root = new VBox(10);
        root.setAlignment(Pos.CENTER);
        root.setPrefSize(500, 1000);

        Label lblText = new Label("+92 (302) 050-6910");
        LinkUtil.setLink(lblText, "tel:+923020506910");

        Label lblText1 = new Label("cto.ms@outlook.com");
        LinkUtil.setLink(lblText1, "mailto:cto.ms@outlook.com");

        Label lblText2 = new Label("Home");
        LinkUtil.setLink(lblText2, "/");

        root.getChildren().addAll(lblText, lblText1, lblText2, btnGetParm);

        return root;
    }

In simple HTML:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Sample Page</title>
</head>
<body>
    <h1>Sample Page</h1>

    <a href="index.html">Home</a>
    <br>
    <a href="tel:+923020506910">+92 (302) 050-6910</a>
    <br>
    <a href="mailto:cto.ms@outlook.com">cto.ms@outlook.com</a>
</body>
</html>
ctoabidmaqbool commented 1 year ago

If using LinkUtil.gotoPage() instead of LinkUtil.setLink() like this:

Label lblText = new Label("+92 (302) 050-6910");
lblText.setOnMouseClicked(event -> {
    LinkUtil.gotoPage(lblText, "tel:+923020506910");
});

Different error happens:

goto: tel:+923020506910
Warning - Invalid Link: tel:+923020506910
Error while loading the path tel:+923020506910
FlorianKirmaier commented 1 year ago

We verify now the link, whether it's valid. Seems like we don't handle tel: and mailto: correctly. We will take a look into it.

FlorianKirmaier commented 1 year ago

You can try out version 0.15.0-SNAPSHOT. It should work with this version.

ctoabidmaqbool commented 1 year ago

@FlorianKirmaier Yes, 0.15.0-SNAPSHOT solves the above issue! Thanks!!!