Hi all,
I didn't find any clean solution with the help of SmartGWT library, how to use link like LinkItem in DynamicForm.
If you need to open some Window or do something else in current screen of application through <a href='#' onclick='onLinkClick();'>Link</a> link without open new browser window, you can use this code for example. The originally idea taken from gwt-ext forum.
If you know another good idea how to make it, any help will be appreciated.
package com.smartgwt.sample.showcase.client.search;
import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
public class SimpleSearchForm extends DynamicForm
{
public SimpleSearchForm()
{
initializeControls();
publishJs();
}
private void initializeControls()
{
final DynamicForm form = this;
form.setAutoFocus(true);
form.setNumCols(2);
form.setWidth(300);
form.setTitleOrientation(TitleOrientation.TOP);
TextItem firstName = new TextItem("fName");
firstName.setTitle("First name");
firstName.setSelectOnFocus(true);
firstName.setWrapTitle(false);
TextItem lastName = new TextItem("lName");
lastName.setTitle("Last name");
lastName.setWrapTitle(false);
StaticTextItem label = new StaticTextItem();
label.setShowTitle(false);
label.setHint("<a href='#' onclick='onLinkClick();'>Link</a>");
form.setFields(firstName, lastName, label);
form.draw();
}
private static void onLinkClick()
{
SC.confirm("Hello", new BooleanCallback()
{
public void execute(Boolean value)
{
//...
}
});
}
// Set up the JS-callable signature as a global JS function.
private native void publishJs() /*-{
$wnd.onPickDescriptionClick = @com.smartgwt.sample.showcase.client.search.SimpleSearchForm::onLinkClick();
}-*/;
}
I didn't find any clean solution with the help of SmartGWT library, how to use link like LinkItem in DynamicForm.
If you need to open some Window or do something else in current screen of application through <a href='#' onclick='onLinkClick();'>Link</a> link without open new browser window, you can use this code for example. The originally idea taken from gwt-ext forum.
If you know another good idea how to make it, any help will be appreciated.
package com.smartgwt.sample.showcase.client.search;
import com.smartgwt.client.types.TitleOrientation;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
public class SimpleSearchForm extends DynamicForm
{
public SimpleSearchForm()
{
initializeControls();
publishJs();
}
private void initializeControls()
{
final DynamicForm form = this;
form.setAutoFocus(true);
form.setNumCols(2);
form.setWidth(300);
form.setTitleOrientation(TitleOrientation.TOP);
TextItem firstName = new TextItem("fName");
firstName.setTitle("First name");
firstName.setSelectOnFocus(true);
firstName.setWrapTitle(false);
TextItem lastName = new TextItem("lName");
lastName.setTitle("Last name");
lastName.setWrapTitle(false);
StaticTextItem label = new StaticTextItem();
label.setShowTitle(false);
label.setHint("<a href='#' onclick='onLinkClick();'>Link</a>");
form.setFields(firstName, lastName, label);
form.draw();
}
private static void onLinkClick()
{
SC.confirm("Hello", new BooleanCallback()
{
public void execute(Boolean value)
{
//...
}
});
}
// Set up the JS-callable signature as a global JS function.
private native void publishJs() /*-{
$wnd.onPickDescriptionClick = @com.smartgwt.sample.showcase.client.search.SimpleSearchForm::onLinkClick();
}-*/;
}
Comment