0

I'm building a website in html which uses Java server faces to access a Java bean. I have got it to work using xhtml but i realised that i need some functionality from html5 so i'm trying to rebuild the front-end using html5.

The working index.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://xmlns.jcp.org/jsf/html">
<body>
<h:form>
        username:
        <h:inputText id="userName" size="10" maxlength="20" value="#{LoginBean.username}"/>
        <br></br>
        password:
        <h:inputText id="password" size="10" maxlength="20" value="#{LoginBean.password}"/>
        <br></br>
        <h:commandButton id="submit" value="submit" action="#{LoginBean.login()}"/>
        <br></br>
    </h:form>
</body>

The bean LoginBean.java

@ManagedBean(name = "LoginBean")
@SessionScoped
public class LoginBean
{
String username;
String password;

public String login() throws Exception
{
    Scanner s = new Scanner(new URL("http://172.17.0.3:8080/login?username=" + username + "&password=" + password).openStream(), "UTF-8").useDelimiter("\\A");
    String out = s.next();
    s.close();
    Boolean bool = new Gson().fromJson(out, Boolean.class);

    if (bool)
    {
        return "userPage";
    } else
    {
        return "index";
    }
}

public String getUsername()
{
    return username;
}

public void setUsername(String username)
{
    this.username = username;
}

public String getPassword()
{
    return password;
}

public void setPassword(String password)
{
    this.password = password;
}
}

The button is supposed to save the username and password and if 172.17.0.3:8080/login accepts the login then the UserPage.html is supposed to load. So is it possible to do the same thing in html5?

David
  • 5
  • 2
  • What functionality do you need? JSF and html 5 work perfectly fine together. I think you habe a wrong conception of both jsf and html/html5 – Kukeltje Dec 19 '18 at 18:37
  • yeah, I probably have something mixed up. I want some html5 code that does the same thing as index.xhtml. – David Dec 19 '18 at 18:42
  • 'Some' html code is unclear. An `h:inputText` generates an html input that is part of html(5) – Kukeltje Dec 19 '18 at 19:23
  • Hmm, alright. I thought xhtml and html5 used different syntax because it didn't work when I tried to port it to html5, but if that code should work for both then I probably have some other problem. Thank you for the help! – David Dec 19 '18 at 19:29
  • https://stackoverflow.com/questions/19189372/javaserver-faces-2-2-and-html5-support-why-is-xhtml-still-being-used – Kukeltje Dec 19 '18 at 19:41

0 Answers0