How to localize FormOverlay component - vaadin-flow

Title and Description properties has setters for labels but username, password and buttons dont have.
Could I set localized text to these properties?
Thx

If you're referring to the login overlay, you can localize it through LoginOverlay#setI18n. For example:
LoginOverlay overlay = new LoginOverlay();
LoginI18n i18n = LoginI18n.createDefault();
i18n.getHeader().setTitle("My title");
i18n.getForm().setUsername("User");
i18n.getForm().setPassword("Pass");
i18n.setAdditionalInformation("Additional info");
i18n.getErrorMessage().setTitle("It's a disaster!!!");
overlay.setI18n(i18n);

Related

How to remove title fields in form design caption in Dynamics AX?

I open form with menuitembutton and in caption are visible title fields from datasource. Can I remove it? This form should be for creating new records and this title fields can be confusing.
In my case title bar is not replaced with text "New record". But I insert in run() method line Table_ds.create() and change in menuitem properties EnumTypeParameter, EnumParameter to value "FormOpenMode"
Some additional methods. You can change the caption a couple of ways.
Override the form's init method and this will work, but still leaves the (TitleField1, TitleField2) at the end of the caption.
public void init()
{
super();
element.design().caption("New Caption");
}
Alternatively, override the form's run() method and do something like this:
public void run()
{
super();
WinAPI::setWindowText(this.hWnd(), "New Caption without other stuff");
}
The title fields can be removed from the form title bar by clearing the TitleDatasource property of the form's design node.
Note that when a new record is created, the title fields in the form title bar will be replaced with the text "New record".

Is it possible to set description to a disabled text field in Vaadin?

I would like to add a tooltip to a disabled text field.
Do you have any ideas how can I do it?
I'm using Vaadin 6.8.13.
When I select a specific item in combo box, disabled text field will be enabled. Otherwise, text field will be disabled
TextField readonly = new TextField("Read-Only");
readonly.setValue("I am sitting here read only");
readonly.setReadOnly(true);
readonly.setDescription("Not this time Mojojojo");
Is this what you want?
Sure, why should it not work -- unless you have not even tried it first.
Disable the TextField via setEnabled(false) and add a description via setDescription('...'):
#Grapes([
#Grab('org.vaadin.spring:spring-boot-vaadin:0.0.5.RELEASE'),
#Grab('com.vaadin:vaadin-server:7.4.4'),
#Grab('com.vaadin:vaadin-client-compiled:7.4.4'),
#Grab('com.vaadin:vaadin-themes:7.4.4'),
])
import org.vaadin.spring.annotation.VaadinUI
import com.vaadin.server.VaadinRequest
import com.vaadin.ui.*
#VaadinUI
class MyUI extends UI {
protected void init(VaadinRequest request) {
setContent( new TextField().with{
caption = "I have a Caption"
value = "And a Value"
enabled = false
description = "And have a Description"
it
})
}
}
// spring run vaadin.groovy
Try disabling the label and then putting it inside a layout. Then set that layout's description. The user won't know the difference.
VerticalLayout layout = new VerticalLayout();
TextArea textArea = new TextArea("Hello World");
textArea.setEnabled(false);
VerticalLayout textAreaWrapper = new VerticalLayout();
textAreaWrapper.addComponent(textArea);
textAreaWrapper.setDescription("Some description");
layout.addComponent(textAreaWrapper);
this.setContent(layout);
this.setSizeFull();
You could create your own class which extends VerticalLayout and creates a TextArea inside it. That way you don't have to create a layout wrapper each time you just create your "MyTextArea" or whatever you want to call it.
Screenshot
N.B.
From your question I had originally thought the following code wouldn't work but it works fine? I haven't tried it in Vaadin 6.8.13 though. I am using Vaadin 7.1.2.
VerticalLayout layout = new VerticalLayout();
TextArea textArea = new TextArea("Hello World");
textArea.setEnabled(false);
textArea.setDescription("Some description");
layout.addComponent(textArea);
this.setContent(layout);
this.setSizeFull();

Approach for designing View in vaadin 7

I am newbie to vaadin. I have to develop PoC on vaadin. Service layer is already written using spring. As a part of Poc I have to develop a screen below.
When request comes to my UI class, it will call my View using navigator. This view consists of one tabsheet and each tab have its own functionality and depends on other tab values too. First tab is search tab. It displays all the records came from db in the tab content area(Table/Grid addon. I dont know what to use). Each record have access to other two tabs. The other two tabs has fields to map each record's property. As of now, i have taken dummy data to display.
I wrote the view like this . But I am confused weather this approach is correct or not.
#VaadinView(UserView.NAME)
public class UserView extends VerticalLayout implements View {
public static final String NAME = "user";
public UserView(){
// For Tabs
TabSheet tabs = new TabSheet();
// first tab component
VerticalLayout layout = new VerticalLayout();
// for search fields
HorizontalLayout searchArea = new HorizontalLayout();
FormLayout searchAreaName = new FormLayout();
TextField name = new TextField("name");
FormLayout searchAreaEmail = new FormLayout();
TextField email = new TextField("email");
searchAreaName.addComponent(name);
searchAreaEmail.addComponent(email);
searchArea.addComponent(searchAreaName);
searchArea.addComponent(searchAreaEmail);
// for search table
BeanContainer<String, test.User> users = new BeanContainer<String, User>(
User.class);
users.setBeanIdProperty("userId");
users.addBean(new User("sudheer", "sudheer#kewil.com", "1"));
users.addBean(new User("sridhar", "sridhar#kewil.com", "2"));
users.addBean(new User("ranga", "ranga#kewil.com", "3"));
Table table = new Table("", users);
table.setSizeFull();
table.setPageLength(6);
layout.addComponent(searchArea);
layout.addComponent(table);
Tab tabOne = tabs.addTab(layout, "User Search", null);
// second tab component
VerticalLayout userLayout = new VerticalLayout();
userLayout.addComponent(new TextField("user name"));
userLayout.addComponent(new TextField("email"));
tabs.addTab(userLayout, "main details", null);
// tab change event
addComponent(tabs);
tabs.setHeight("50%");
tabs.setWidth("50%");
setComponentAlignment(tabs, Alignment.MIDDLE_CENTER);
}
#Override
public void enter(ViewChangeEvent event) {
}
}
I haven't implemented pagination also. Before going forward, I would like to know any other best approaches to go ahead.
Any suggestions would help me very much. Thanks in advance.
Anybody.. please help me out. I am going blindly with my appproach
Here is what I do in such cases:
Use the Blackboard event bus to fire events. These events carry a payload that essentially is the id of the record clicked/selected.
The other tabs or views are registered as a listener of this event. When the event is fired, the listeners extract the record/entity id from the payload, fetch the entity object from the back-end, and display it accordingly.
This approach ensures loosely-coupled components.
I hope it helps.

Working with textarea

How can I work with textareas using watin? There is no function like "browser.TextArea(...)".
Is there another name for textareas? I only need to find it and work with rows/cols.
Use the TextField method to access a TextArea.
From the Watin Homepage (modified for this question)
[Test]
public void SearchForWatiNOnGoogle()
{
using (var browser = new IE("http://www.google.com"))
{
// If there was a TextArea with the name q - the next line would get the TextArea object and assign it to the textField variable.
var textField = browser.TextField(Find.ByName("q"));
// Do what you need to do with the TextArea, for example, get the text from the textArea:
string textAreaText = textField.Value;
}
}
Just came across this myself. I thought I would post a more complete answer for people that are still stumped by this. Just use the GetAttributeValue method on the TextField instance like so:
TextField field = Document.TextField(Find.ByName("comments"));
Assert.AreEqual("10", field.GetAttributeValue("rows"));
Assert.AreEqual("42", field.GetAttributeValue("cols"));

text field in a dialog box on a BlackBerry

I want to create an empty dialog box with a text field inside. When the user enters data inside the box he must be redirected to another screen. I want the Dialog box to come up without any statements but must include a textfield
That should be doable with a PopupScreen, EditField and maybe a ButtonField so the user can let you know he/she is done entering data.
Just create standard OK dialog and then add an EditField to it.
BasicEditField inputField = new BasicEditField();
Dialog d = new Dialog(Dialog.D_OK_CANCEL, "Enter your Username:", Dialog.OK, null, Dialog.DEFAULT_CLOSE);
d.add(inputField);
int i = d.doModal();
if (i == Dialog.OK) {
Dialog.inform("Your Username is : " + inputField.getText());
}
Here's a complete tutorial

Resources