Chat example not working - Illegal character in path

UI Components for JSF
Post Reply
vished
Posts: 479
Joined: 02 Feb 2014, 17:38

04 Nov 2015, 21:41

Hello,

I tried so create the chat example, but I got following error:

Code: Select all

Illegal character in path at index 31: /webApp/primepush/{room}
Here my xhtml:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:mg="http://at.irian/mygourmet"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>PrimeFaces Push Chat</title>
    <style type="text/css">
        .ui-widget {font-size: 13px;}
        .ml10 {margin-left: 10px}
        .chatPanel {height: 200px; margin-bottom: 10px; overflow-y: auto}
        .message {width: 50%}
    </style>
</h:head>
<h:body>

<p:growl id="growl" showDetail="true" />
             
<h:form id="form">
    <p:remoteCommand name="updateList" update="users" process="@this" />
 
    <p:fieldset id="container" legend="PrimeChat" toggleable="true">
 
        <h:panelGroup rendered="#{chatView.loggedIn}">
            <h:panelGrid columns="2" columnClasses="publicColumn,usersColumn" style="width:100%">
                <p:outputPanel id="public" layout="block" styleClass="ui-corner-all ui-widget-content chatlogs" />
 
                <p:dataList id="users" var="user" value="#{chatUsers.users}" styleClass="usersList">
                    <f:facet name="header">
                        Users
                    </f:facet>
 
                    <p:commandButton title="Chat" icon="ui-icon-comment" oncomplete="PF('pChat').show()" update=":form:privateChatContainer">
                        <f:setPropertyActionListener value="#{user}" target="#{chatView.privateUser}" />
                    </p:commandButton>
                    #{user}
                </p:dataList>
            </h:panelGrid>
 
            <p:separator />
 
            <p:inputText value="#{chatView.globalMessage}" styleClass="messageInput" />
            <p:spacer width="5" />
            <p:commandButton value="Send" actionListener="#{chatView.sendGlobal}" oncomplete="$('.messageInput').val('').focus()" />
            <p:spacer width="5" />
            <p:commandButton value="Disconnect" actionListener="#{chatView.disconnect}" global="false" update="container" />
        </h:panelGroup>
 
        <h:panelGroup rendered="#{not chatView.loggedIn}" >
            Username: <p:inputText value="#{chatView.username}" disabled="true" />
 
            <p:spacer width="5" />
            <p:commandButton value="Login" actionListener="#{chatView.login}" update="container"
                             icon="ui-icon-person" disabled="true" />
        </h:panelGroup>
 
    </p:fieldset>
 
    <p:dialog widgetVar="pChat" header="Private Chat" modal="true" showEffect="fade" hideEffect="fade">
        <h:panelGrid id="privateChatContainer" columns="2" columnClasses="vtop,vtop">
            <p:outputLabel for="pChatInput" value="To: #{chatView.privateUser}" />
            <p:inputTextarea id="pChatInput" value="#{chatView.privateMessage}" rows="5" cols="30" />
 
            <p:spacer />
            <p:commandButton value="Senden" actionListener="#{chatView.sendPrivate}" oncomplete="PF('pChat').hide()" />
        </h:panelGrid>
    </p:dialog>
</h:form>
 
<p:socket onMessage="handleMessage" channel="/{room}" autoConnect="false" widgetVar='subscriber' />
 
<script type="text/javascript">
    function handleMessage(message) {
        var chatContent = $(PrimeFaces.escapeClientId('form:public')),
        text = (message.user) ? message.user + ':' + message.text: message.text;
 
        chatContent.append(text + '<br />');
 
        //keep scroll
        chatContent.scrollTop(chatContent.height());
 
        if(message.updateList) {
            updateList();
        }
    }
</script>

</h:body>
</html>
Whats wrong?
PF 8.0

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests