import java.util.Arrays;\r
import java.util.List;\r
\r
+import com.gitblit.wicket.WicketUtils;\r
+import org.apache.wicket.Component;\r
import org.apache.wicket.ajax.AjaxRequestTarget;\r
import org.apache.wicket.ajax.markup.html.AjaxLink;\r
import org.apache.wicket.ajax.markup.html.form.AjaxButton;\r
\r
setOutputMarkupId(true);\r
\r
+ final IModel<String> keyFeedback = Model.of("");\r
final List<SshKey> keys = new ArrayList<SshKey>(app().keys().getKeys(user.username));\r
final ListDataProvider<SshKey> dp = new ListDataProvider<SshKey>(keys);\r
final DataView<SshKey> keysView = new DataView<SshKey>("keys", dp) {\r
// update the panel\r
target.addComponent(SshKeysPanel.this);\r
}\r
+ keyFeedback.setObject("");\r
}\r
};\r
if (!canWriteKeys) {\r
"span5",\r
keyComment));\r
\r
+ Component addKeyFeedback = new Label("addKeyFeedback", keyFeedback).setOutputMarkupId(true);\r
+ WicketUtils.setCssStyle(addKeyFeedback, "color: red; font-weight: bold;");\r
+ addKeyForm.add(addKeyFeedback);\r
+\r
addKeyForm.add(new AjaxButton("addKeyButton") {\r
\r
private static final long serialVersionUID = 1L;\r
String data = keyData.getObject();\r
if (StringUtils.isEmpty(data)) {\r
// do not submit empty key\r
- error(getString("gb.addSshKeyErrorEmpty"));\r
- target.addComponent(getPage().get("feedback"));\r
+ keyFeedback.setObject(getString("gb.addSshKeyErrorEmpty"));\r
+ target.addComponent(addKeyFeedback);\r
return;\r
}\r
\r
key.getPublicKey();\r
} catch (Exception e) {\r
// failed to parse the key\r
- error(getString("gb.addSshKeyErrorFormat"));\r
- target.addComponent(getPage().get("feedback"));\r
+ keyFeedback.setObject(getString("gb.addSshKeyErrorFormat"));\r
+ target.addComponent(addKeyFeedback);\r
return;\r
}\r
\r
keys.clear();\r
keys.addAll(app().keys().getKeys(user.username));\r
\r
+ keyFeedback.setObject("");\r
+\r
// update the panel\r
target.addComponent(SshKeysPanel.this);\r
}\r
+ else keyFeedback.setObject("Key not added.");\r
}\r
});\r
\r