Primefaces LayoutUnit does not expand when browser window is maximised - html

I have a Layout consisting of a north LayoutUnit containing a banner, a west LayoutUnit containing a vertical menu, and a central Layoutunit containing the main page content.
When I open a page with the browser minimised (e.g. browser width is half of the pc screen width) then it displays as much as it can in the view. However, if I then maximise the browser, it doesn't expand the content in the central LayoutUnit (see attached picture).
The code for the Layout is as follows:
<h:body>
<p:layout style="margin: 0px; gutter: 0px !important!" fullPage="false" >
<p:layoutUnit position="north" size="80" resizable="false" closable="false" collapsible="true" gutter="0" >
<div style="background-image: url('../resources/images/veges.jpg'); height: 80px; "> </div>
</p:layoutUnit>
<p:layoutUnit position="west" size="210" resizable="false" closable="false" collapsible="false" gutter="0">
<h:form id="menuForm">
<p:menu style="width:180px">
<p:menuitem value="Home" outcome="WelcomeMember" icon="fa fa-home" />
</p:menu>
<p:menu style="width:180px" toggleable="true">
<ui:include src="menu.xhtml" />
</p:menu>
<p:menu style="width:180px">
<p:menuitem value="Sign Out" action="#{loginBean.doLogout()}" icon="fa fa-sign-out" />
</p:menu>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center" collapsible="false" resizable="true" gutter="0" >
<ui:insert name="pageContent" >
This is the default page content
</ui:insert>
</p:layoutUnit>
</p:layout>
</h:body>
Does anyone know why this is happening and what I need to do to correct it?

Related

Primefaces tabbing focuses inside unopened sidebar

I have created a side menubar using the p:sidebar component. My problem is with accessibility. Using the tab key to navigate the page loses focus inside the unopened p:sidebar component. Meaning that when i navigate trough the page using the tab key, the focus goes inside the unopened p:sidebar, focus should only appear when the sidebar is open. How to correctly implement tab focus to the component and it's content? Also the xhtml included the p:sidebar contains p:link components that doesn't get tab focus at all when the p:sidebar is open.
My p:sidebar component:
<p:sidebar widgetVar="fssidebar" fullScreen="true" styleClass="ws-sidebar" onShow="document.getElementById('menuForm:foliLink').focus()" onHide="sidebarhide()">
<p:outputPanel id="menuPanel" styleClass="" style="float: left;">
<ui:include src="menu.xhtml"/>
</p:outputPanel>
</p:sidebar>
My menu.xhtml:
<?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">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<p:outputPanel id="menupanel">
<h:commandButton value="X" style="color:white" onclick="sidebarhide();" class="close" pt:aria-label="#{acc['header.closemenu']}" tabindex="0"/>
<h:form>
<p:remoteCommand name="sidebarhide" update="#all" global="false"/>
</h:form>
<h:form id="menuForm" style="float: left;">
<p:outputPanel>
<p:link value="Link to my page" href="https://www.mypage.com" target="_blank" tabindex="0"/>
</p:outputPanel>
<p:outputPanel>
<p:link value="Main Menu" href="#{ui['main.menu.url']}" target="_blank" tabindex="0" onkeydown="if(event.key==='Tab'){PF('myInplace').display.trigger('click');event.preventDefault();}"/>
</p:outputPanel>
<p:outputPanel>
<p:commandLink value="Menu Item 1" action="loading?faces-redirect=true" global="false" tabindex="0"/>
</p:outputPanel>
<p:outputPanel>
<p:commandLink value="Menu Item 2" action="profile?faces-redirect=true" styleClass="ws-menulink ws-font" global="false" tabindex="0"/>
</p:outputPanel>
<p:outputPanel>
<p:commandLink value="Menu Item 3" action="emv?faces-redirect=true" global="false" tabindex="0"/>
</p:outputPanel>
<p:outputPanel>
<p:link value="Menu Item 4" href="www.something.com" target="_blank" tabindex="0"/>
</p:outputPanel>
<p:outputPanel>
<p:link value="Menu Item 5" href="www.something.com" target="_blank" tabindex="0"/>
</p:outputPanel>
</h:form>
</ui:composition>

layout collapsible doesnt work - primefaces

i m working on a project. project main page has a layout with 2 layoutunits and each layoutunit have forms. when i run project page is loading correctly but one of layoutunit collapsible property does not work. when i click on it layoutunit is closing then opening again.
i m using primefaces 5.3 and i m not a elit user.
<p:layout fullPage="true" widgetVar="layoutWdgt">
<p:layoutUnit style=" font-size: 14px!important" position="west" collapsible="true" header="#{kullanici.adsoyadkullanici}" >
<h:form id="anamenu">
<p:panelMenu style="width: 250px; height: 600px!important">
<p:submenu label="Genel" icon="fa fa-cog">
<p:menuitem value="Ana Gösterge Tablosu 1" actionListener="#{turnPage.changePage(101)}" update="mainform:panel1" />
<p:menuitem value="Ana Gösterge Tablosu 2" actionListener="#{turnPage.changePage(102)}" update="mainform:panel1" />
</p:submenu>
<p:submenu label="Demografik Göstergeler" icon="fa fa-area-chart">
<p:menuitem value="Nüfus Piramidi" actionListener="#{turnPage.changePage(201)}" update="mainform:panel1" />
<p:menuitem value="Genel Demografik Göstergeler" actionListener="#{turnPage.changePage(202)}" update="mainform:panel1"/>
<p:menuitem value="Kırsal ve Kentsel Nüfus" actionListener="#{turnPage.changePage(203)}" update="mainform:panel1"/>
<p:menuitem value="0-14 Yaş Nüfus Oranları" actionListener="#{turnPage.changePage(204)}" update="mainform:panel1"/>
<p:menuitem value="65 Yaş Üstü Nüfus Oranları" actionListener="#{turnPage.changePage(205)}" update="mainform:panel1" />
<p:menuitem value="Toplam Yaş Bağımlılık Oranları" actionListener="#{turnPage.changePage(206)}" update="mainform:panel1" />
</p:submenu>
</p:panelMenu>
</h:form>
</p:layoutUnit>
<p:layoutUnit id="layoutcenter" style="font-size: 14px" position="center" collapsible="true" >
<h:form id="mainform">
<p:outputPanel id="panel1">
<ui:include src="#{turnPage.pathpage}" />
</p:outputPanel>
</h:form>
</p:layoutUnit>
</p:layout>
</h:body>

Unable set focus on cursor

I have a very strange behavior only when using Google Chrome.
When I open my website (i am using primefaces) at the first time I am unable set focus on cursor.
The “workaround” will be to open another tab and suddenly I get the control back on the cursor.
Any I idea why this happen and how can I resolve it ?
(only with Chrome).
Thanks
<ui:define name="content">
<p:layout fullPage="true" >
<p:layoutUnit position="north" size="50" resizable="false" closable="false" collapsible="false">
<h:form>
<ui:include src="menu_header.xhtml"/>
</h:form>
</p:layoutUnit>
<p:layoutUnit id="center" position="center">
<h:form id="mainForm" prependId="false">
</h:form>
</p:layoutUnit>
<p:layoutUnit position="south" size="30" resizable="false" closable="false" collapsible="false" style="overflow:hidden">
<div id="footer" class="ui-widget ui-widget-header ui-corner-all">
<h:outputText value="#{navMenuBean.footer}" styleClass="defualtTextSize"/>
</div>
</p:layoutUnit>
</p:layout>
</ui:define>

Primefaces menubar right align submenu

I've discovered I can play a commandbutton in the options facet (right side of menubar), however I can't seem to add a submenu in the same way. I want an actual menu dropdown aligned to the right, not a button.
Any ideas?
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head title="Primefaces Test">
<style>
.ui-layout-north {
z-index: 20 !important;
overflow: visible !important;
}
.ui-layout-north .ui-layout-unit-content {
overflow: visible !important;
}
</style>
</h:head>
<h:body>
<h:form>
<p:layout fullPage="true">
<p:layoutUnit position="north">
<p:menubar>
<p:submenu label="Mail">
<p:menuitem value="Gmail" url="http://www.google.com" />
<p:menuitem value="Hotmail" url="http://www.hotmail.com" />
<p:menuitem value="Yahoo Mail" url="http://mail.yahoo.com" />
</p:submenu>
<p:submenu label="Videos">
<p:menuitem value="Youtube" url="http://www.youtube.com" />
<p:menuitem value="Break" url="http://www.break.com" />
</p:submenu>
<f:facet name="options">
<p:commandButton value="logout" />
<p:submenu label="Videos">
<p:menuitem value="Youtube" url="http://www.youtube.com" />
<p:menuitem value="Break" url="http://www.break.com" />
</p:submenu>
</f:facet>
</p:menubar>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:outputText value="Hello, world." />
</p:layoutUnit>
</p:layout>
</h:form>
</h:body>
</html>
-- Shane
I solve it using something like this:
style="position: absolute; right: 6px;"
Just try it.
I ended up just forgetting the whole "options" facet and used css float instead, I hope this helps someone:
<h:body>
<h:form>
<p:layout fullPage="true">
<p:layoutUnit position="north">
<p:menubar>
<p:submenu label="Mail">
<p:menuitem value="Gmail" url="http://www.google.com" />
<p:menuitem value="Hotmail" url="http://www.hotmail.com" />
<p:menuitem value="Yahoo Mail" url="http://mail.yahoo.com" />
</p:submenu>
<p:submenu label="Videos">
<p:menuitem value="Youtube" url="http://www.youtube.com" />
<p:menuitem value="Break" url="http://www.break.com" />
</p:submenu>
<p:submenu label="Videos2" style="float:right">
<p:menuitem value="Youtube" url="http://www.youtube.com" />
<p:menuitem value="Break" url="http://www.break.com" />
</p:submenu>
</p:menubar>
</p:layoutUnit>
<p:layoutUnit position="center">
<h:outputText value="Hello, world." />
</p:layoutUnit>
</p:layout>
</h:form>
</h:body>
--Shane
If you are using bootstrap the you can just use the built in flexbox classes
NOTE: This is a primeng (angular) example and will align ALL items right.
<p-menubar [model]="items" styleClass="d-flex justify-content-end"></p-menubar>

Primefaces Chat outputPanel displays no scrollbar

I'm facing an issue with the Primefaces Chat demo from the Primefaces showcase. The outputPanel component does not display a scroll bar like in the showcase demo. Here is my code and screenshot below:
<h:head>
<script type="text/javascript">
function handleMessage(data) {
var chatContent = $(PrimeFaces.escapeClientId('form:public'));
chatContent.append(data + '<br />');
//keep scroll
chatContent.scrollTop(200); <----------- have tried "chatContent.height()"
}
</script>
</h:head>
<h:body>
<p:growl id="growl" showDetail="true" />
<h:form id="form">
<p:fieldset id="container" legend="UserChat" 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="#{chatView.users}" styleClass="usersList">
<f:facet name="header">
Users
</f:facet>
<p:commandButton title="Chat" icon="ui-icon-comment" oncomplete="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}" />
<p:spacer width="5" />
<p:commandButton value="Login" actionListener="#{chatView.login}" update="container"
icon="ui-icon-person" />
</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="Send" actionListener="#{chatView.sendPrivate}" oncomplete="pChat.hide()" />
</h:panelGrid>
</p:dialog>
</h:form>
<p:socket onMessage="handleMessage" channel="/chat" autoConnect="true" widgetVar="subscriber"/>
</h:body>
Any clues about what i'm doing wrong?
Thanks and best regards!
The issue may be you didn't specify chatlogs css class, you should add it as below:
<style type="text/css">
.chatlogs {
height: 210px !important;
max-height: 210px !important;
overflow-y: scroll !important;
overflow-x: hidden !important;
}
</style>
And if you would like to scroll to bottom, you can try:
chatContent.scrollTop(chatContent[0].scrollHeight);