View Javadoc
1   /*
2    * Copyright (C) 2003-2013 eXo Platform SAS.
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU Affero General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU Affero General Public License for more details.
13   *
14   * You should have received a copy of the GNU Affero General Public License
15   * along with this program. If not, see <http://www.gnu.org/licenses/>.
16   */
17  package org.exoplatform.ecm.webui.component.explorer.symlink;
18  
19  import java.io.Writer;
20  import java.util.ResourceBundle;
21  
22  import org.exoplatform.webui.application.WebuiRequestContext;
23  import org.exoplatform.webui.form.UIForm;
24  import org.exoplatform.webui.form.UIFormInputBase;
25  import org.exoplatform.webui.form.UIFormMultiValueInputSet;
26  
27  /**
28   * Created by The eXo Platform SAS Author : eXoPlatform exo@exoplatform.com Mar
29   * 7, 2013
30   */
31  public class UITranslationFormMultiValueInputSet extends UIFormMultiValueInputSet {
32  
33    /*
34     * (non-Javadoc)
35     * @see org.exoplatform.webui.form.UIFormMultiValueInputSet#processRender(org.
36     * exoplatform.webui.application.WebuiRequestContext)
37     */
38    @Override
39    public void processRender(WebuiRequestContext context) throws Exception {
40      if (getChildren() == null || getChildren().size() < 1)
41        createUIFormInput(0);
42  
43      Writer writer = context.getWriter();
44  
45      UIForm uiForm = getAncestorOfType(UIForm.class);
46      int size = getChildren().size();
47  
48      ResourceBundle res = context.getApplicationResourceBundle();
49      String addItem = res.getString("UIAddTranslationForm.action.SelectDocument");
50  
51      writer.append("<div class=\"input-append\">");
52      for (int i = 0; i < size; i++) {
53        UIFormInputBase uiInput = getChild(i);
54  
55        uiInput.setReadOnly(readonly_);
56        uiInput.setDisabled(!enable_);
57  
58        uiInput.processRender(context);
59  
60        if (i == size - 1) {
61          writer.append("<button type=\"button\" onclick=\"");
62          writer.append(uiForm.event("SelectDocument", getId())).append("\" title=\"" + addItem + "\"");
63          writer.append(" class=\"btn\" >" + addItem + "</button>");
64        }
65      }
66      writer.append("</div>");
67    }
68  }