Caption raw format, please?

Hi! How to make caption "
Like


this

"? The point is: how to say:

<span class="foo">Like</span> <span class="bar">these</span>


?

With a Label in [tt]
Label.CONTENT_XHTML
[/tt] mode. Unfortunately, HTML is not allowed in captions.

I don’t know if there is any good reason for it, except that it’s not implemented yet. In general, allowing HTML in any component can be a security risk if the value can come from a user.


Bo Maryniuk cries

I need something like:


+------------+------------+
| My caption | My warning |
+------------+------------+
|+-----------------------+|
||_                      ||
|+-----------------------+|
+-------------------------+
| My just other caption   |
+------------+------------+
|+-----------------------+|
||_                      ||
|+-----------------------+|
+-------------------------+

You mean that value:

String query = "SELECT * FROM FOO WHERE UID = '%s'";
ResultSet thatwasjustveryverysecure = dbConnection.createStatement()
                  .executeQuery(String.format(query, this.userNameField.getValue()));

…right? :slight_smile:

In Vaadin captions, icons, descriptions and errors are handled by the layout - no the component. Layout can show these as it wishes.

If this is a common need to be used by several components, you could implement a simple (reusable) layout component that would contain just one component and show its error and caption as described above. The you could wrap the components with above described need with the layout component.

I’ve been wanting a similar thing that is found from the Label component to be part of all components for a while now, i.e.

Button b = new Button(“My Button”, Button.CONTENT_XHTML);
TextField tf = new TextField();
tf.setCaption(“My Field”, TextField.CONTENT_XHTML);

The API could be something a bit prettier, but the idea is what I’m proposing…

Hi! :slight_smile:
Not that I see you properly understood me. Warning stuff is not a knock-out yellow nag-screen into user’s face usually shown on sub-error or when something missing. That’s what showNotification(…) does. What I am talking here is a separation of contents during a regular runtime. For example, you want to display a widget, e.g. TextField, in your app something like this:

Reply to user
Joonas

(last logged in at 6/4/10 12:25 PM)
:
[Hi there, man!..]

[ OK ]

In this case, where is user name and date-time, I can put some span tags in order CSS treat it differently. E.g. username I want to make bold and date/time gray and italic. How I suppose to do that, if Vaadin burns entire caption with one style? Now there is no way to do that, so that’s was my point.

In other words, Java Swing allows you HTML mode of your labels (these are captions to the fields), where you can define your pattern and substitute values if required. Hence I would like to have the same mode in Vaadin to make things flexible.

How about this:

TextField field = new TextField();
field.setCaptionTemplate("<span class=\"uid\">%s</span> <span class=\"date\">%s</span>", 
                        Caption.CONTENT_XHTML);
field.setCaption("Joonas", this.myGreatFormatter.format(new Date()));

In this case if setCaption meets an array, then it applies to thing like:

 public void setCation(Object... array) {
    super.setCaption(String.format(this.captionTemplate, array));
}

Then later you don’t need to mess up with the HTML over and over again, but take a care about only clear values. What you think?