Primefaces DataTable filtering warning - primefaces

I'm using primefaces 3.5, and i have a DataTable component in my form.
When i try to use filters like this primefaces showcase, I'm getting this warning message:
WARNING: DataTable j_idt7:j_idt8:someList has filtering enabled but no filteredValue model reference is defined, for backward compatibility falling back to page viewstate method to keep filteredValue. It is highly suggested to use filtering with a filteredValue model reference as viewstate method is deprecated and will be removed in future.
Can anyone help?

From here :
See the user guide on page 133 'Data Filtering' in the chapter
dataTable. There is a new attribute filteredValue that should point to
a List in a ViewScoped managed bean to store the filtered values the
user typed in.

Related

What should be done to get around or resolve the PrimeFaces exception requiring the definition of a lazy attribute or one that doesn't result in null?

I am in the progress of upgrading a legacy application from PrimeFaces 6.2 to 11.0.0 (which is the newest available with maven - https://mvnrepository.com/artifact/org.primefaces/primefaces). I have had to make a number of changes, including adding Object as the parameter for RowEditEvent and TreeNode objects (which are now generic) and changing instantiations of DefaultStreamedContent to use .builder(). Now, I am facing the following error whenever I try to run the application and navigate to certain pages:
"javax.faces.FacesException: Unable to automatically determine the lazy attribute. Either define the lazy attribute on the component or make sure the value attribute doesn't resolve to null."
It looks like an exception is being thrown rather than a warning as is noted in the conversation here: https://github.com/primefaces/primefaces/issues/8436. It also looks like it was fixed, but for version 12 (which is not on the maven central repository).
I am wondering what my options are, or what could be done about this. Should I go back to an older version?
As a workaround you could create an application factory which sets the lazy attribute to false.
See: https://primefaces.github.io/primefaces/11_0_0/#/core/globalattributes
Is it a lazy DataTable which uses LazyDataModel? If yes, just set lazy=true, otherwhise set lazy=false

How to use resolveWidgetVar before PrimeFaces 8?

https://github.com/primefaces-extensions/primefaces-extensions/blob/master/core/src/main/java/org/primefaces/extensions/renderer/CommandButtonSingleClickRenderer.java
This appears to be an elegant solution to disable and enable PrimeFaces CommandButton and available in version 8 and up of PrimeFaces.
Unfortunately, I'm unable to compile it in PrimeFaces 6.1, Java 8.
It now compiles with the suggested update, Thanks, but the method doesn't return the correct type - String.
It could be related to the structure of our DOM, we have multiple layers of xhtml, the first loaded index.xhtml doesn't have any buttons. But the CommandButtonSingleClickRenderer.java is being called. The properties of the CommandButton are all default values.
protected String getAttributeValue(final FacesContext context, final CommandButton button, final String attribute)
returns null
Added a check for null prior to the call to getToggleJS to get the pages with buttons loaded.
What is required in the commandButton ?
How do you call the CommandButtonSingleClickRenderer from xhtml ?
In PrimeFaces 8, the default String resolveWidgetVar(FacesContext context) method was introduced in the Widget interface.
Before that, so in PrimeFaces 6.1, you should use button.resolveWidgetVar().
See also the source of CommandButtonRenderer in PrimeFaces 6.1.

ADF MODEL exception to page jsf

is it possible (and if so how) to route the MODEL exception messages to be presented on the JSF page and NOT in a popup?
scenario:
JSF page contains master-detail tables
when a user clicks on a row of the master table, there are some operations (Iterator+ExceuteWithParams) executed in the detailImpl.java (by prepareRowSetForQuery(ViewRowSetImpl vrs).
some of those operations can return exceptions from the DB. we don't want those exception messages to be presented as popups, but instead to be shown inside the JSF page in a certain place that will be used for those messages (Ex. af:outputText). the component needs to be updated with the new error every time it was thrown from the model
how it can be done?
examples please
try experimenting with 'af:messages' component.

How to display server Log in Primefaces Log Component

I see it is possible in the docs but can't seem to find a way of implementing it.
 Log API is also available via global PrimeFaces object in case you’d
like to use the log component to display your logs.
Using Primefaces 6.2
Primefaces Log Component
Binding Log4J to <p:log id="log" />
Everything in #Kukeltje's answer is true.
Still, if your end-game is to see your server logs in the front-end of your JSF app, I would do the following:
Add a DB appender to your logging framework so that all logs are written to the database.
https://logging.apache.org/log4j/2.x/manual/appenders.html#JDBCAppender
https://logback.qos.ch/manual/appenders.html#DBAppender
Create a jsf datatable to view the logs in. https://www.primefaces.org/showcase/ui/data/datatable/basic.xhtml
Initially, I would recommend that you filter the logs when retrieving it from the DB to only show the newest ones in the table, otherwise the table might be too big to load within a reasonable time. As a permanent solution, I would recommend that you implement the LazyDataModel
https://www.primefaces.org/showcase/ui/data/datatable/lazy.xhtml
It can be very handy to be able to filter and /or sort by log severity, time, and all the fields supported by by your logging framework.
Non related: Splunk has a universal forwarder utility that can submit a copy of your logs to a splunk server so that you can analyze your logs in near realtime. https://www.splunk.com/en_us/download/universal-forwarder.html
hope it is not too late.
I figured it out. From your Java Bean, you can use the PrimeFaces obj to execute a javascript in that way you can use for example the Primefaces.info('your log message'); to print in your log.
example function:
public void sendMessageToLog(int count) {
String text = "PrimeFaces.info('Testing Logger #" + count + "');";
PrimeFaces pf = PrimeFaces.current();
pf.executeScript(text); // This will execute the script in your page
}

MvvmCross 4 support for UWP, AppShell missing Frame

I have created a new solution for my MvvmCross app that supported Windows Store and I want to support UWP on Windows 10. I have moved over the PCL successfully, but I am having problems getting the basic UWP app working using a sample provided by MS (NavigationMenu) which uses the SplitView and the AppShell pattern they are recommending for the new navigation/command model. I referenced a helpful blog post (http://stephanvs.com/implementing-a-multi-region-presenter-for-windows-10-uwp-and-mvvmcross/), which gave me some guidance on how to integrate mvvmcross into the AppShell, but startup is failing because the AppShell does not have a valid Frame defined. Frame is a read-only property, and I have been unable to see where this is being set up.
I am using the standard AppShell implementation from the NavigationMenu with the following changes as recommended in the blog post:
public sealed partial class AppShell : MvxWindowsPage // was Page
public Frame AppFrame { get { return this.Frame; } } // was this.frame
Except for code after the error, there are no differences in the setup. In looking at the MvxWindowsPage implementation, there doesn't seem to be anything special as it still invokes the Page initialization. Is there something obvious I am missing?
So the link to the blogpost is correct, in other words you'll need to use MultiRegions from MvvmCross to get this working.
But what the blogpost doesn't show is a complete working version...
I've added one on my github here:
https://github.com/Depechie/MvvmCrossUWPSplitView
Some pointers to take away, like I said in the comments.
Your view where the SplitView will be present, needs to have a property to return a valid Frame to look for while injecting new views. This can be returned like this return (Frame)this.WrappedFrame.UnderlyingControl; found in the code here https://github.com/Depechie/MvvmCrossUWPSplitView/blob/master/MvvmCrossUWP.Win/Views/FirstView.xaml.cs#L13
Than all views you want to load up in the SplitView will need to reference to the region you defined in that SplitView, in my case I named it FrameContent as seen here https://github.com/Depechie/MvvmCrossUWPSplitView/blob/master/MvvmCrossUWP.Win/Views/FirstView.xaml#L48
So use that name for the region attribute in all to be loaded views like so [MvxRegion("FrameContent")] example here https://github.com/Depechie/MvvmCrossUWPSplitView/blob/master/MvvmCrossUWP.Win/Views/SecondView.xaml.cs#L7
I see what you're trying to do with the SplitView template that's provided by Microsoft. There is however a mismatch between things managed by MvvmCross and UWP.
By default MvvmCross maps ViewModels to Views based on naming conventions. What you are trying to do is use a view 'AppShell' (which is derived of Windows.UI.Xaml.Controls.Page) that doesn't adhere to the default MvvmCross convention.
The way I choose to implement this SplitView (Hamburger) functionality is by deleting the provided AppShell class entirely. I then created a new view named HomeView (since I have a ViewModel with the name HomeViewModel) and added the SplitView control there as described in the post you mentioned above.
For completeness I've created a Gist with the App.xaml.cs and HomeView.xaml as you requested. You can find them here: https://gist.github.com/Stephanvs/7bb2cdc9dbf15cb7a90f