Filter by category name in view panel and pager save state behavior - save

I have the following problem:
I have a XPage that has a combobox whose chosen value restricts the category of view panel through the property 'filter by category name'. The XPage has a pager save state, however this does not save the state of the restricted view the category chosen in the combobox.
I need to open a document in view panel and act on the document through an agent for example to direct to the view again it remains in the previous state, with for example restricted to the chosen category.
Do this case you will have to ride in the url that the agent is calling the restriction chosen category? There syntax in this regard to XPage?
Thanks a lot!

The value in the combobox should be bound to a sessionScope variable. Then bind the category filter in the view to the sessionScope variable. That will save the chosen category.

When exiting the document are you calling #{javascript:viewStateBean.restoreState()} ?

Related

Editing single item in useFieldArray

I'm using and loving react-hook-form. I've run across an issue where I have a list of items (let's say in the left column), then when you click on any item it will display an edit component for the selected item in the right column. The issue is when I switch between items, nested array values don't seem to update the data correctly.
I think I understand that because a new edit component isn't created for each parent item (I'm just passing the selected index down) the nested useFieldArray in the edit component still references the first parent item. If that's the case, I'm not exactly sure how to make sure a new useFieldArray is created for each item that gets selected.
Here's a codesandbox replicating the issue:
https://codesandbox.io/s/dreamy-brattain-r74lx
Any help is much appreciated.
I think you can just map over the childItems prop of your watched item inside your <Details /> component instead of using fields. As you are using watch the <Details /> will be re-rendered after appending a new child item.
If your <Details /> component should get more complex i would also suggest to use useWatch here instead of passing watch. Check this quote from the documentation for useWatch:
Behaves similarly to the watch API, however, this will isolate
re-rendering at the component level and potentially result in better
performance for your application.
Here is an example using useWatch:

IBM BPM: Is it possible to hide a column of a table dynamically based on user choice?

Since I'm new to this technology (Coach UI) I wanted to know an information, is it possible to delete a column based on the user's choice?
That is, I have a modal that contains the column fields and if I choose to hide a column it hides it dynamically.
Thank you in advance for the reply, I have been on this problem for 2 days :(
Configurations of Controls in BPM can be either provided with values or bound to a variable.
Binding configuration item to a variable will give you the ability to change it dynamically, by changing the value of that variable.
For your request, you can click on the purple icon next to Columns (image bellow) to switch to binding mode, then select a varible of type TableColumn (This BO is available in the UI Toolkit itself, open the BO to check the documentation).

ComboBox with hidden keys

Is it possible in vaadin 12 to have comboboxes such that it displays a user-friendly value but behind the scenes it stores a hidden code? I found this example from 5 years ago but it doesn't apply to Vaadin 12 comboboxes: https://vaadin.com/forum/thread/7821327/combo-box-hidden-values
(If there's a good, reasonably clean way to do it, please point me in the right direction! I would think this is a common sought-after feature)
Items are assigned to ComboBox either directly using setItems or indirectly through setDataProvider.
The item itself is not sent to the browser and shown in the dropdown. Instead, for each item ComboBox generates a string label that is shown in the UI and an internal id that is used on the server for mapping back to the original item instance when the user makes a selection.
The generated id is internal to ComboBox and has no external meaning. In particular, it's not based on any value in the item itself such as the item's primary key in the application's database.
The label is by default based on doing toString() for each item. You can customize how the label is created by assigning an item label generator callback that receives an item instance and returns the label string to use for that item.
If you for example have a combo box for selecting persons, then you could configure it in e.g. this way:
ComboBox<Person> personSelector = new ComboBox<>();
personSelector.setItems(allPersons);
personSelector.setItemLabelGenerator(person ->
person.getFirstName() + " " + person.getLastName());
If I understand you correctly, there is built-in feature in ComboBox for this, the method is called setItemLabelGenerator(..), which allows to define e.g. lambda expression that returns String which is used for ComboBox items instead of the property from underlying data object.
The linked Forum discussion you found is about similar thing in our previous generation of the framework, there has been some renaming of the API here.

Too many options in the View Data Class select list when creating a view

Is there a way to restrict the options available in the view data class select list in the MVC add view dialog box. I really would only like to have models from a single assembly in it?
Just skip the ViewData class and type it in manually after the view is created. I find that faster than scrolling through that awefull list.
When you start typing the list filters itself so that you can find the type more easily.

pass multiple values present in ListBoxFor to controller, while postback

I am using asp.net mvc 2.0 in my application and the application requires to get multiple values from a ListBox, from view to controller.
The scenerio is like that, I have two listbox say ListBox1 and ListBox2 and on the load of a page, I initally load Listbox1 with some data.
Now a user can transfer some of the data from one Listbox1 to Listbox2 and then want to select multiple data present in ListBox2 in the controller.
I have used two "ListBoxFor" for this purpose and provide "IEnumerable" to the ListBox control in view as a property of a class.
Now when I post back the data to controller, I don't get the the data correspond to "ListBox2" in my class object.
In short, I want to select multiple data which is present in ListBox2, in my controller on postback of form.
Please help and provide sample for this.
An http post will not contain all values in a select box, only the one(s) selected. You could use javascript to select all values (make sure select is set to multiple), but that's not my preferred way since it changes the way the page looks to the user.
I would recommend using javascript to add the selected values to hidden fields. It would work something like this:
Your model has a List selections
on select, javascript is used to move from ListBox1 to ListBox2
in addition, a new and the second
On unselect, you would remove the input and update all inputs with a higher index to index - 1 in order to retain sequential-ness
Then when you post, the data will be automatically bound to your model's selections list.

Resources