Struts2 radio buttons internationalization - internationalization

I have a JSP page that allows user to choose a color using radio button. The available colors are in the following enum
enum Colors{RED, BLUE, GREEN};
and I'm displaying them using s:radio tag
<s:radio name="selectedColor" list="#com.example.Colors#values()" ></s:radio>
This works fine and displays the list of all colors present in enum. Now I want to internationalization this list so that the lables with each radio button should be displayed using getText() in listValue
<s:radio name="selectedColor" list="#com.example.Colors#values()" listValue="getText(XYZ)"></s:radio>
what should I write in place of XYZ to get the desired result?

I'd probably do the I18N lookup on the business side of things (outside of the view layer) and just pass in a list of value/text objects, or a map of label/value pairs (I usually just use a map to avoid having to create a transfer object).
IIRC the listValue attribute would be a property name on the list object; I don't recall if you could actually specify a method like that.

Related

Kendo Grid - Customize Filter Row

there is a feature called "Filter Row" in Kendo Grid
http://demos.telerik.com/kendo-ui/grid/filter-row
I want to add a drop-down list instead of a text box or a number box, to the filter box. It's for filtering a column that has countries. So I want list of countries in a drop-down list. How can I do this?
It's very similar to the custom Filter Menu (http://demos.telerik.com/kendo-ui/grid/filter-menu-customization). I made the mistake of no using valuePrimitive: true. You might not want it in your situation but keep that in mind.
Here's a sample: http://dojo.telerik.com/OKaS
Also, the filter menu should take up the editor model of the column but it's not always what you want.
Edit
Starting from 2014 Q2 SP1, the template function now receives an object containing "datasource" and "element". In my example, you would have to change the dropdown initialization from "container.kendoDropDownList" to "container.element.kendoDropDownList". The datasource is empty in my example but I'm assuming this can be used to pass the choices to a control without requiring another datasource or to externalize your current. I have not experimented with this feature but I suggest you do before taking my sample blindly.
As Pluc mentioned earlier valuePrimitive: true will help you create a custom filter for your grid/columns to send id's to your controller, if you are not using setting this property true you will receive an Object in your controller instead of a number, the conversion will not be made automatically . This is still working as of 2019

Using NSArrayController to bind model objects to an inspector view, how to catch special cases like empty and multiple selections?

I have inspector view and because it contains a lot of UI I want to explore cocoa bindings to connect it to the model. The inspector view will update depending on the currently selected object in an outline view and the inspector view displays controls to alter properties (like colour, name, shape etc.) that can be changed.
This works well when only one row in the outline view is selected because the view has a one-to-one relationship with the model object. However, there are two special cases that I want to be able to catch:
Empty selection
If no items in the outline view are selected I want to display a special "No items selected view" placeholder view.
Multiple selection
If multiple items are selected I can either display a "Multiple items selected view" placeholder view or I can decide to let the changes apply globally to all selected model objects.
My question is how can these special cases be caught when using bindings? Moreover, how can I do behaviour "A" when there is an empty selection and behaviour "B" when there is a multiple section. This sort of thing is trivial when using target/action because you can just code the logic into the action method.
Bindings seem great when propagating changes to values but I'm unsure how to go about implementing bindings that require different decisions based on current selection state.

AngularJS: "Global" menu buttons for multiple views

I've (very) recently dived into Angular, but I'm struggling a bit with how to design my layout.
For my site I've created a menu containing an input field and some buttons. The idea is that the input field combined with either of the buttons should service a function. So say for viewA, the input field should only act as a search bar. If the user however clicks one of the buttons the input field value should be used to as a basis to create a new item in another viewB.
The search function works great for viewA, but I'm unable to make the buttons switch views. I'm suspecting (or know, but don't know how to address it) this is because the mentioned buttons are outside the view (ng-view) and thus don't have a controller.
I've searched around for "multiple controllers / views", where suggestions vary from using the include function or create a service. Problem is I have no idea what would best practise or if it's even necessary for my case.
The menu + input field is another view. It should have its own controller. Based on the route – $on($routeChangeSuccess, ...) – you can use ng-switch to switch between the appropriate HTML/template in that view. If your templates are large, you can use ng-include inside the ng-switch directives. Otherwise don't bother, and just in-line the HTML inside each ng-switch-when.
For an example of how so use $routeChangeSuccess (but not ng-switch), see https://stackoverflow.com/a/11910904/215945

Django crispy form, hide/show fields in the template

i'm using Crispy-Form and Bootstrap within Django. It works very well.
Now, i would like to have a field showing only when another field has input.
Basically i've a multpile select list called A visible, and a text field, B, hidden.
once the the user focus/select one or more value in A, B should become visible. And if none are selected it should become invisible.
Does cripsy form have this feature or the possibility to write the JS?
Or do i've to write the JS in the html page where the form is rendered?
ciao
I've done something similar once. I assigned a class 'hidden' to the inputs that you want to be initially hidden. This can be done by nesting the fields in a Div, and assigning a css_class. See http://django-crispy-forms.readthedocs.org/en/d-0/layouts.html#universal-layout-objects
Then use javascript to remove the 'hidden' class when a certain action occurs.
If you decide to use jQuery, you can use the following function:
$("input[name='a_hidden_field']").removeClass('hidden')

Get NSComboBox to work like an HTML Combo

Is it possible to have the values displayed in an NSComboBox be different from what is retrieved with objectValueOfSelectedItem?
So, it will display an object's string name but it's int recordId is returned instead of the string name? Other than using selected index and getting it from the source array, of course...
Are you looking for NSPopUpButton? It's more similar to an HTML <select>. An NSComboBox lets users directly type in new values, as well as pick them from a list, but you can't do that with plain HTML.
In any event, you should be able to give either control a bunch of custom objects that have a recordid property, and then retrieve the selection using [[comboBox objectValueOfSelectedItem] recordid]. You'll also need to write a custom formatter for these objects.
PopupButton is it.
objectValueOfSelectedItem wont work for me since it returns what is displayed and I want a string displayed but int returned.

Resources