AJAX request in JSF running in GlassFish 4.1 - jsf

In the JSF Application there is this problem:
The application contains some elements inside a t:dataTable that are f:ajax enabled as following:
<h:form id="form" enctype="multipart/form-data">
<t:dataTable id="someTable" ...>
...
<f:facet name="header">
<t:commandLink action="#{someBean.someAction()}">
<t:outputText value="Some command"/>
<f:ajax execute="#this" render="someTable"/>
</t:commandLink>
</f:facet>
...
</t:dataTable>
</h:form>
The "Some command" should do something and refresh the "someTable" only.
Now the problem is: this scenario is WORKING under GlassFish 3.1.2, but under GlassFish 4.1 it is problematic as following:
The "Some command" works perfectly, and updates the someTable without any problem, but no other non-ajax action elements outside the someTable (or inside the Table) works.
They work, but do not show what they do, so that when we refresh the page, the changes appear.
Now, I tried to make the AJAX as following:
<f:ajax execute="#this" render="form"/>
And everything seems to be working just fine.
I need to update only the table, not the whole form.
Does anyone have a solution (web.xml config) or some tip?
There is no PrimeFaces/ICEFaces/RichFaces used in this project.
Thanks
EDIT: The names are correct (without : as prefixes, or anything else). The exact same scenario works perfectly under GlassFish 3.1.
Do we need to look into some security settings, or other configurations?
EDIT2: as #Tiny said in his comment, without multipart/form-data it worked, but then we can't make any Upload. The Upload doesn't work anymore.

Related

Primefaces changing value of inputSwitch inside deferred outputPanel

We are using JSF and Primefaces to control a SparkStream inside a Web-Application running on Tomcat. When we start or stop this Stream this takes about 15seconds in which the Web-GUI keeps loading.
Now we wanted to use deferred loading for long-loading content to make sure the Web-GUI is still accessible even if the Bean needs some time for responding. Anyway if we do so, our p:inputSwitch does not work correctly anymore. Everytime we load or refresh the page, the value in the Bean is set to false.
<h:form>
<p:panel id="control" header="Streaming-Control" collapsed="false" toggleable="true">
<p:outputPanel deferred="true">
<p:inputSwitch id="test" value="#{SomeBean.someBoolean}">
<p:ajax update="test"/>
</p:inputSwitch>
</p:outputPanel>
</p:panel>
</h:form>
We need to put the inputSwitch inside the deferred outputPanel because it should not be accessible until the whole page is rendered completely (which means the Stream is running or stopped, but not starting or being stopped atm).
PrimeFaces Version is 6.0.
Always try the newest version ;)
It could be fixed already: https://github.com/primefaces/primefaces/issues/2912

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, how to conditionally render a component without creating it

I work with primefaces 3.4.1 and myfaces 2.1.9.
I need to show a component within a tab conditionally.
For the moment my code looks like that :
<p:tab id="tab" title="tabTitle">
<h:panelGroup id="tabContent">
<componentX:component id="component1" rendered="#{not condition}" />
<componentY:component id="component2" rendered="#{condition}" />
</h:panelGroup>
</p:tab>
I voluntarily changed the name of the components and arguments
My problem is with this solution component1 and component2 are both created. So the server will be working to generate the two components event if one is never shown.
My question is, is there a (clean) way to have this rendering result without creating both components?
I had the same results with c:if and c:choose, I am running out of ideas.
You can use c:if here without problems...

filtering <rich:column> in composition component

Hopefully someone can help, because I am quite stuck on this issue. I cannot find much help elsewhere...
The high-level goal: creating a custom tag that will aid in the reuse of an extendedDataTable in Richfaces. I have a custom tag that I would like to be similar to:
<mytag:customTable bean="#{myBean}"/>
The (simplified) file that contains code for the table is as follows (table.xhtml)
<!--...header stuff -->
<ui:component>
<a4j:outputPanel>
<h:form>
<rich:extendedDataTable
value="#{bean.theData}"
var="entity"
id="table">
<rich:column filterMethod="#{...}">
<f:facet name="header">
<h:inputText value="#{bean.filterValue}">
<a4j:support event="onkeyup" reRender="table"/>
</h:inputText>
</f:facet>
<h:outputText value="#{entity.item}"/>
</rich:column>
</rich:extendedDataTable>
</h:form>
</a4j:outputPanel>
</ui:component>
Due to the constraints of the application, using the filterBy="#{...}" attribute inside the <rich:column> tag does not give me what I need.
Accordingly, I have to use the filterMethod attribute. When I hardcode the table with,
<rich:column filterMethod="#{bean.filterFunction}">
then everything works fine. However, I would like to keep the tag more general and NOT hardcode this. Instead, I would like
to also pass the name of the filtering function (e.g. <mytag:customTable bean="#{myBean}" flFcn="#{myBean.filterFunction}"> ). The problem is that
I cannot get any version of this to work properly.
From searching other threads, I see that the way to pass a method to an 'action' attribute has a syntax like: action="#{bean[fcnName]}" where fcnName is just a String (see http://digitaljoel.nerd-herders.com/2009/08/25/passing-action-methods-in-facelets-using-array-notation/).
I have confirmed that this way works correctly when it's an action . However,
this does not seem to help me in this case with filterMethod (perhaps b/c the function signature is different?). Based on those solutions, I would need something like:
<mytag:customTable bean="#{myBean}" flFcn="filterFunction"> with <rich:column filterMethod="#{bean[flFcn]}">
I have not found anything among the many permutations of EL syntax that works. Everytime, this approach throws an exception saying that 'bean' resolved to null.
To check that the bean was actually recognized, I had it print a String via <h:outputText value="#{bean.someString}"/>
(removing the offending filterMethod=...)and there is NO problem. Therefore the problem seems to lay entirely on whatever filterMethod receives. I found what I believe to be a very similar issue here, but that does not seem to be answered.
Thanks in advance!
I'm facing the same problem using RichFaces 3.3.3 and JSF 1.2 without having a usable solution.
Found a JIRA-entry at RichFaces which is still open and thus probably will not be fixed anymore.

JSF Primefaces TabView problems

I asked this in the PF Forum but no one seems to want to answer so I though I'd try my luck here.
I have a ui:repeat that is not being updated correctly after an Ajax call when it is within a TabView.
Simple scenario is I have a ui:repeat pointing at an ArrayList (ArrayList contains simple pojos with a String). Within this I have an h:inputText whose value is the pojo's String getter/setter. The ui:repeat is contained within a h:panelGroup. I use a p:commandButton to run an action to update the ArrayList (just add a couple of objects to it a Math.random value for the String) and then update the h:panelGroup. The updated values in the ArrayList are not reflecting in the ui:repeat input fields. This only appears to be affecting input fields as outputText fields do update correctly. Also if I do the same for a p:dataTable the input field are updated correctly. If I remove the Tabview and Tab tags it works fine.
As it works when removing the Tabs I can only assume this is a bug and not designed to work like this. If someone could please confirm if this is so or if there is a viable work around. I need to use a ui:repeat as my fields are not in a tabular format. This has only occurred since migrating from PF 2.2. I'm currently on PF 3.1, Weblogic 10.3.4 and Mojarra 2.0.4
<p:tabView>
<p:tab title="Test">
<h:form prependId="false">
<p:commandButton id="testStringCheck"
value="Test String Check"
process="#form"
update="testPanel"
action="#{testBean.generateVOwithRandomStrings}">
</p:commandButton>
<h:panelGroup id="testPanel" layout="block">
<ui:repeat value="#{testBean.voList}" var="entry">
<h:outputText value="#{entry.randomString}"/>
<p:inputText style="display:block;"
value="#{entry.randomString}"
size="15">
</p:inputText>
</ui:repeat>
</h:panelGroup>
</h:form>
</p:tab>
</p:tabView>
As a workaround I've used a p:datagrid instead of a ui:repeat. This achieves the look I had in the the ui:repeat so I'm happy. Hopefully this bug will be fixed on future releases.
This is something of a bug in Primefaces commandButton. See the following thread:
http://forum.primefaces.org/viewtopic.php?f=3&t=17454
You can try replacing
<p:commandLink id="testStringCheck" ... update="#form" />
With an <h:commandLink>
<h:commandLink id="testStringCheck" render="#form"/>
Also from the above link here is an interesting method that somebody posted that enables you to correctly find the correct clientId to update.
http://paste.kde.org/177698/
temp solution: insert outside h:panelGroup:
<p:outputPanel defered="true" delay="1" ..>
and update outputPanel instead of panelGroup
Or use a datalist component instead of ui:repeat.
One more, i'm not sure but you can try, so update class instead id:
<h:panelGroup id="testPanel" layout="block" styleClass="testPanelCl" ../>
and update : #(.testPanelCl), don't forget id of panelGroup, without id JSF can not update by class

Resources