You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Kristian Lind <kl...@gmail.com> on 2013/08/14 04:07:04 UTC
Formtable
Hi.
is it not possible the add a ActionLink to a FormTable. ?
I have a submit button..
Button button = new Submit("save", "Save", this, "onSaveOptionFormTable");
button.addStyleClass("btn btn-primary");
optionFormTable.getForm().add(button);
But I would like to use a ActionLink, cause I need to go to another page
and need to set a parameter, and would like to have the button ( ActionLink
) together with the save button.
ActionLink addOptionLink = new ActionLink("addOptionLink", "New Option",
this, "OnAddOptionLink");
addOptionLink.addStyleClass("btn btn-primary");
addOptionLink.setParameter("productId", productId);
optionFormTable.getForm().add(addOptionLink);
But the link does not show up... only the Save button.
--
Best regards
Kristian Lind
Re: Formtable
Posted by Kristian Lind <kl...@gmail.com>.
Here is what I did...
ActionLink addOptionLink = new ActionLink("addOptionLink", "New Option",
this, "OnAddOptionLink");
optionFormTable.addActionLink(addOptionLink);
public class JSIFormTable extends FormTable {
private static final long serialVersionUID = 1L;
protected final List<ActionLink> actionLinks = new ArrayList<>();
public JSIFormTable() {
super();
}
public JSIFormTable(String name, Form form) {
super(name, form);
}
public JSIFormTable(String name) {
super(name);
}
public void addActionLink(ActionLink actionLink){
if (actionLink == null) {
throw new IllegalArgumentException("Null actionLink parameter");
}
actionLinks.add(actionLinks.size(), actionLink);
}
public void removeActionLink(ActionLink actionLink){
actionLinks.remove(actionLink);
}
public List<ActionLink> getActionLinks() {
return actionLinks;
}
/**
* Render the Form Buttons to the string buffer.
* <p/>
* This method is only invoked if the Form is created by the FormTable,
* and not when the Form is defined externally.
*
* @param buffer the StringBuffer to render to
*/
protected void renderButtons(HtmlStringBuffer buffer) {
Form form = getForm();
List<Button> buttonList = form.getButtonList();
List<ActionLink> actionLinks = getActionLinks();
if (!buttonList.isEmpty()) {
buffer.append("<table cellpadding=\"0\" cellspacing=\"0\"");
if (getAttribute("width") != null) {
buffer.appendAttribute("width", getAttribute("width"));
}
buffer.append("><tbody><tr><td");
buffer.appendAttribute("align", form.getButtonAlign());
buffer.append(">\n");
buffer.append("<table class=\"buttons\" id=\"");
buffer.append(getId());
buffer.append("-buttons\"><tbody>\n");
buffer.append("<tr class=\"buttons\">");
for (Button button : buttonList) {
buffer.append("<td class=\"buttons\"");
buffer.appendAttribute("style", form.getButtonStyle());
buffer.closeTag();
button.render(buffer);
buffer.append("</td>");
}
for (ActionLink actionLink : actionLinks) {
buffer.append("<td class=\"buttons\"");
buffer.closeTag();
actionLink.render(buffer);
buffer.append("</td>");
}
buffer.append("</tr>\n");
buffer.append("</tbody></table>\n");
buffer.append("</td></tr></tbody></table>\n");
}
}
}
On Tue, Aug 13, 2013 at 10:41 PM, Bob Schellink <sa...@gmail.com> wrote:
> Hi,
>
> Doesn't look like it does. You could override the method
> Formtable#protected void renderButtons to enable this. Or use the FormTable
> constructor which accepts a Form object.
>
> regards
>
> Bob
>
>
> On Wed, Aug 14, 2013 at 4:07 AM, Kristian Lind <kl...@gmail.com> wrote:
>
>> Hi.
>>
>> is it not possible the add a ActionLink to a FormTable. ?
>>
>> I have a submit button..
>>
>> Button button = new Submit("save", "Save", this, "onSaveOptionFormTable");
>> button.addStyleClass("btn btn-primary");
>> optionFormTable.getForm().add(button);
>>
>> But I would like to use a ActionLink, cause I need to go to another page
>> and need to set a parameter, and would like to have the button ( ActionLink
>> ) together with the save button.
>>
>> ActionLink addOptionLink = new ActionLink("addOptionLink", "New Option",
>> this, "OnAddOptionLink");
>> addOptionLink.addStyleClass("btn btn-primary");
>> addOptionLink.setParameter("productId", productId);
>> optionFormTable.getForm().add(addOptionLink);
>>
>> But the link does not show up... only the Save button.
>>
>>
>>
>> --
>> Best regards
>>
>> Kristian Lind
>>
>
>
--
Best regards
Kristian Lind
Re: Formtable
Posted by Bob Schellink <sa...@gmail.com>.
Hi,
Doesn't look like it does. You could override the method
Formtable#protected void renderButtons to enable this. Or use the FormTable
constructor which accepts a Form object.
regards
Bob
On Wed, Aug 14, 2013 at 4:07 AM, Kristian Lind <kl...@gmail.com> wrote:
> Hi.
>
> is it not possible the add a ActionLink to a FormTable. ?
>
> I have a submit button..
>
> Button button = new Submit("save", "Save", this, "onSaveOptionFormTable");
> button.addStyleClass("btn btn-primary");
> optionFormTable.getForm().add(button);
>
> But I would like to use a ActionLink, cause I need to go to another page
> and need to set a parameter, and would like to have the button ( ActionLink
> ) together with the save button.
>
> ActionLink addOptionLink = new ActionLink("addOptionLink", "New Option",
> this, "OnAddOptionLink");
> addOptionLink.addStyleClass("btn btn-primary");
> addOptionLink.setParameter("productId", productId);
> optionFormTable.getForm().add(addOptionLink);
>
> But the link does not show up... only the Save button.
>
>
>
> --
> Best regards
>
> Kristian Lind
>