p:selectOneMenu not refreshing properly when pressing F5 - jsf

So before anything just to make it clear this is an issue that happens with firefox even in the showcase https://www.primefaces.org/showcase/ui/input/oneMenu.xhtml to replicate just select any value and hit f5 and the value will remain. Also check forum.primefaces.org/viewtopic.php?t=17525 for the details also check how to do autocomplete="off" at form level in JSF other solutions that didn't work for me
I have a little problem when hitting f5 to refresh page for some reason my selectOneMenu its keeping the previously selected value,I need him to have the default value or first one on the array again... any idea how can I fix this? or why does that happen? every other element of the page is succesfully reseting its value, this is the code of my selectOneMenu:
<p:panel styleClass="cds-panel-reset">
<p:selectOneMenu id="somOrigenConsulta" tabindex="1"
binding="#{consultaPagoPremiosMB.somOrigenConsulta}"
label="Origen" widgetVar="wvSomOrigenconsulta"
style="width: 140px !important;">
<p:ajax event="change" process="somOrigenConsulta"
update=":accordion:tbwPagarPremio:frmConsultapagopremioscod:pnlGrdDatosConsulta
:accordion:tbwPagarPremio:frmConsultapagopremioscod:dtbPagopremios"
listener="#{consultaPagoPremiosMB.mostrarDialogoOrigen()}" />
<f:selectItems
value="#{consultaPagoPremiosMB.aOrigenConsulta}" />
<p:ajax process="#this"
render=":accordion:tbwPagarPremio:frmConsultapagopremioscod:pnlGrdDatosConsulta" />
</p:selectOneMenu>
</p:panel>
Also it refreshes succesfully if I refresh by using CTRL+SHIFT+R, any idea why F5 doesn't???
could it be cache? https://www.saicharanreddy.com/whats-the-difference-between-f5-ctrlr-ctrlshiftr-ctrlf5-and-shiftf5-in-google-chrome-browser/
how can I deal with that in a selectonemenu holy..
I did some searching the problem seems to be mozilla, https://forum.primefaces.org/viewtopic.php?t=17525
But im not able to implement the autocomplete=off because it just doesn't appear to be an attribute of my selectonemenu (primefaces 7.0) please help another way to implement this

You can use dynamic="true" attribute. I got the same problem solved using this attribute.

The problem is firefox, it also happens in the showcase.
So I had a headache with this problem and I tried the first solution of this on the selectOneMenu but it didn't work, so I had to use javascript like this:
<script type="text/javascript">
$(document).ready(function(){
var oneMenu = document.getElementById('accordion:tbwPagarPremio:frmConsultapagopremioscod:somOrigenConsulta_input');
oneMenu.value="1";
})
</script>
and it started having always default value 1 when I hit F5, but I'm not 100% sure if this is a good solution.

Related

How to connect a commandButton with CheckBox

In a html page I have a h:commandButton that I want to make it to work in combination with a h:selectBooleanCheckbox, so every time I press the button the checkbox will be checked and otherwise.
Is it possible to do that directly in the html, and not in the java code behind it?
<h:commandButton value="#{userBean.buttonText()}" action="#{userBean.changeOutput()}"/>
<h:panelGrid columns="4" rendered="#{userBean.details}" styleClass="clicked" >
<h:outputText .... />
<h:outputText ..../>
</h:panelGrid>`
If you are using JSF 2, you have to update the area that include your checkbox, using f:ajax tag.
You can find a lot of examples here in stackoverflow, look this example just hide/show a div: After showing / hiding a JSF element with AJAX how to hide the triggering element?
Hope it helps.

JSF select Primefaces selectOneMenu inside dialog hiding menu option z-index

View:
<p:dialog header="Search in code tables" widgetVar="dlg" resizable="true">
<p:selectOneMenu id="tableId" value="#{xxx.tableId}"
required="true" label="tableId">
<f:selectItems value="#{xxx.tables}" ></f:selectItems>
</p:selectOneMenu>
The z-index for the dialog causes the menu options to hide behind it.
I am following standard example from Primefaces showcase:
http://www.primefaces.org/showcase/ui/overlay/dialog/loginDemo.xhtml
This appears to be a know n issue
http://forum.primefaces.org/viewtopic.php?f=3&t=33972
Can someone suggest a proper fix.
okay I have managed to figure this out.
I was missing a appendTo telling which component to append the select:
<p:selectOneMenu id="tableId" value="#{xxx.tableId}"
required="true" label="tableId" appendTo="#this" >
This fixes the z-index as well as adding a scrollbar to the drop down.
I have not been able to find this anywhere so posting this self answer.
Try to use panelStyle for selectOneMenu.
Using appendTo = "#this" may cause something like this:
You could use panelStyle = "position:fixed" instead.
Regards.

Select one many doesn't appear correctly

I am developing a primefaces web page. The problem i have is that when i try to use a select one menu with primefaces, the menu appears with the color of the button that when clicked shows the menu.
<p:selectOneMenu id="nombre" value="#{actividad.nombre} style="width:150px">
<f:selectItem itemLabel="Nombre" itemValue="" noSelectionOption="true" />
<f:selectItems value="#{actividad.a}" />
</p:selectOneMenu>
If i change it to it appears correctly but i want to use the one from primefaces
to make the interface look good. Any suggestions on why this happens, Thank you!!
Give the correct doctype to your page.
Your page should also have all the required tags properly (<head>, <body> etc)
Validate the output HTML and see if it is validateable. (Note that not all Primefaces components output validateable code)
Check on multiple browsers and see what is happening.

Equivalent of RichFaces 4 <rich:popupPanel> for RichFaces 3

I am looking for something like <rich:popupPanel> in RichFaces 4, but then for RichFaces 3. I haven't found anything like in documenation. There is only <rich:modalPanel> which doesn't suit my needs, because it has problems displaying my datamodel in table. The selection doesn't work, it always returns no rows selected. If I put my table component in <rich:panel> or <rich:togglePanel>, then it works fine.
Is there any popup window excluding <rich:modalPanel> in RichFaces 3?
I dont have 50 reputation to ask you more details in a comment, so i will answer directly hoping this is what you're asking about.
I think you mean that your problem is that the content of the ModalPanel is not rerendered dynamically. but for this you can wrap your table (or the components you want to update) in an <a4j:outputPanel> with ajaxRendered="true"
Setting ajaxRendered="true" will cause the <a4j:outputPanel> to be updated with each Ajax response for the page, even when not listed explicitly by the requesting component. This can in turn be overridden by specific attributes on any requesting components.
http://docs.jboss.org/richfaces/latest_4_0_X/Component_Reference/en-US/html/chap-Component_Reference-Containers.html#sect-Component_Reference-Containers-a4joutputPanel
In my code I have something like :
<a4j:commandLink id="timelineBtn" action="#{timelineBean.doGenerateLog}"
oncomplete="Richfaces.showModalPanel('timelinePnl');return false;"
value="#{labels['timeline.button.lbl']}"/>
that opens the modalPanel :
<rich:modalPanel style="width:800;height:600;" id="timelinePnl">
<a4j:outputPanel id="dataPanel" ajaxRendered="true">
<!-- your components to be updated go here -->
</a4j:outputPanel>
</rich:modalPanel>
So my content is updated with the results of my timelineBean.doGenerateLog method each time i open the modalPanel .

Primefaces autocomplete rendered in a wrong place

I am using PrimeFaces 4.0, JSF2, jBoss EAP 6.1, Bootsrtap 3. I've got two places in my project where I use <p:autocomplete>, one renders OK the other does not. Suggestion part of auto complete should appear inside a <div> container at the bottom of the page:
<div id="searchForm:j_id_8t_5k_panel" class="ui-autocomplete-panel ui-widget-content ui-corner-all ui-helper-hidden ui-shadow"></div>
but my buggy one renders in the same place where <p:autocomplete> tag should be, it actually replaces input with plain <ul> with suggestions that you can not click.
I am using proper JSF tags like <h:body> etc.
My autocomplete component:
<p:autoComplete value="#{search.item}" completeMethod="#{search.autocomplete}"
var="item" itemLabel="#{item.label}" itemValue="#{item}" converter="objectConverter"
forceSelection="true" minQueryLength="3" scrollHeight="200"
global="false" />
Anyone had a similar problem?
The cause of my problem was that I've put my <p:autocomplete> inside a <p:outputPanel autoUpdate="true">. After removing autoUpdate everything works fine! Don't really know why it should break an autocomplete element, but it does. Hope it helps someone.

Resources