how to populate Struts 2 UI select tag? - select

How can I populate Struts 2 UI select tag?
I keep getting the error:
tag select, field list: The requested list key roles could not be resolved as a collection/array/map/enumeration/iterator type.

Most likely that would be if your list roles is not initialized ( null ) .
Or another reason can be if you have not declared an appropriate getter .

Related

default value - Opentext category attribute

Hi I am trying to update the attribute of type user with the currently logged in user but I didn't see any options to add a default value to the attribute of type user. Is there any option to add the default values to the Category Attributes especially attribute of type user.

Could not get element id from s58c147845272f_products_2_suppliers_0_contacts Failing part: contacts sonata_admin symfony3

The Setup
I am working on a project using Symfony 3 and SonataAdminBundle 3.1.
I am using the nested form method of sonata admin where I have 4 entities:
Category, Product, Supplier, and Contact. They all have one-to-many relation with each other respectively.
I am using sonata_type_collection to put products in category form, and using the same to put suppliers in product form, and using the same to put contacts in the supplier form. The contact form has a sonata_type_model_list field for zipcodes.
The Problem
I am facing the following error when I click the add new contact button on the supplier form from within the category > product form.
Could not get element id from
s58c147845272f_products_2_suppliers_0_contacts Failing part: contacts
The error does not show up when I save the form step by step - like i add a product to the category form then save the form, then add a supplier to product and then save the form, and when i add the contact - the contact form is loaded and the above mentioned exception is not thrown. Also When I go directly to Supplier form and add the contact there, the exception is not thrown.
It is only when the supplier is not saved from within the category form that the above exception is thrown.
any help is highly appreciated.
Check if any of your properties have underscore in the name, like my_file. Try to change it into myFile and also accordingly change code in your Admin class:
$formMapper->add('my_file', 'file'); => $formMapper->add('myFile', 'file');.
Update:
I think I know what it is specifically - you probably have reference to your parent in your children. If that's the case, then add in your Admin classes for entities that have reference to the parents:
$formMapper->add('[parent_reference_attribute]', 'sonata_type_model_hidden');
Replacing [parent_reference_attribute] with name of your field referencing the parent.
Then exception should be gone, at least it was in my case.

How to hide ID field in MVC4 view

I am new to MVC4. I have a form for displaying user roles and a link for editing.
This template is created by entity scaffold.
Whenver user clicks edit link a jquery modal popup displays for editing. The form contains 2 fields ID and User Role .
I wished not to display the Id part so i commented the ID part display . But after updating i will get the error like
Store update, insert, or delete statement affected an unexpected number of
rows (0). Entities may have been modified or deleted since entities were loaded.
Refresh ObjectStateManager entries
I then debugged and found the ID was 0. So I tritd with displaying ID It worked.
why is this happening. How can I dispaly and edit form without ID field.
Add a hidden input for the ID property in your form
#Html.HiddenFor(m => m.ID)
or add a route value in the form (refer all the overloads here)
#using (Html.BeginForm("actionName", "controllerName", new { ID = Model.ID })`

How to handle autopopulated selects (from oneToMany relation) in Symfony form?

I have a ProductCategory class that has a parent and some children, properly annotated using Doctrine.
Then I have a ProductCategoryType (form class) that I use to render the html form.
Doctrine does its magic and creates a select box for parent which consists of previously added categories.
My problem: How to I prepend a default option (say '0' => 'No parent category') and how do I remove a particular category from list (ex: the currently edited category, so user can't select the very category to be its own parent)?
This can easily be achieved by using DataTransformers.
You can find more information in the documentation chapter How to use Data Transformers.

Using custom property in WHERE IN clause with $X{} in Jasper Reports

I currently have a parameter called countries of type java.util.List and I'm using it in a WHERE IN clause as follows:
AND $X{IN, rd.country_id, countries}
In my app I must convert my List<Country> to List<Integer> so that I can use it to make the IN clause, otherwise Jasper would create something like country_id IN ("Argentina", "Brazil") instead of using the IDs.
I was wondering if its possible to use List<Country> as my parameter and telling $X{} to use the field id to create the IN clause so that I can use the toString() method to show what countries the user has selected, any idea? thanks
One method i can think of right now is to have a java class which will take your List of type countryname and return List of type countryId .
you have to make another parameter of type List.This parameter will call the java method.and then you can use this parameter in you query
I assume that the answer provided by #Lisa is not working in this case.
Edit:
Place the java class in your project classpath
The "<>" tags were not visible
I'm not sure how you're deploying this report, but could you set the input control's visible column to the country name, but set the value column to the country ID?
If you're unable to edit the input control, what about modifying your query to handle the country name to ID conversion?
SELECT *
FROM myTable
WHERE countryID IN (SELECT countryID
FROM countryTable
WHERE $X{IN, countryName, countries}
)