Merge branch 'keywordEditFix' into develop
This commit is contained in:
commit
d1228ab958
src/main/java/se/su/dsv/scipro
admin/pages/match
match/panel
|
@ -3,7 +3,6 @@
|
|||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<div wicket:id="feedback"></div>
|
||||
<div wicket:id="dialog">
|
||||
<div wicket:id="editPanel"></div>
|
||||
</div>
|
||||
|
|
|
@ -43,11 +43,7 @@ public class AdminKeywordPage extends AbstractAdminMatchPage {
|
|||
|
||||
public AdminKeywordPage(PageParameters pp) {
|
||||
super(pp);
|
||||
|
||||
feedback = new FeedbackPanel("feedback");
|
||||
feedback.setOutputMarkupId(true);
|
||||
add(feedback);
|
||||
|
||||
|
||||
dialog = new Dialog("dialog");
|
||||
dialog.setModal(true);
|
||||
dialog.setAutoOpen(false);
|
||||
|
@ -61,21 +57,9 @@ public class AdminKeywordPage extends AbstractAdminMatchPage {
|
|||
public void onClick(AjaxRequestTarget target) {
|
||||
target.addComponent(dialog);
|
||||
dialog.setTitle("Create new keyword");
|
||||
final Keyword k = new Keyword();
|
||||
Keyword k = new Keyword();
|
||||
k.setKeyword("blsbls");
|
||||
dialog.replace(new KeywordEditPanel("editPanel", new Model<Keyword>(k)) {
|
||||
@Override
|
||||
public void onPress(AjaxRequestTarget target) {
|
||||
target.addComponent(feedback);
|
||||
try {
|
||||
info("Saved keyword");
|
||||
} catch (Exception e) {
|
||||
error("Something went wrong when trying to save the keyword");
|
||||
}
|
||||
dialog.close(target);
|
||||
target.addComponent(dp.getWMC());
|
||||
}
|
||||
});
|
||||
dialog.replace(new KeywordEditPanel("editPanel", new Model<Keyword>(k)));
|
||||
dialog.open(target);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,8 +4,11 @@
|
|||
<wicket:panel>
|
||||
<b>Enter keyword:</b>
|
||||
<br>
|
||||
<form wicket:id="form">
|
||||
<input type="text" wicket:id="inputField"/>
|
||||
<button wicket:id="saveLink">Save keyword</button>
|
||||
<!-- <button wicket:id="saveButton">Save keyword</button> -->
|
||||
<input type="submit" wicket:id="saveButton" value="Save keyword" />
|
||||
</form>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
|
@ -2,6 +2,7 @@ package se.su.dsv.scipro.match.panel;
|
|||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.html.form.Button;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
|
@ -10,13 +11,14 @@ import org.apache.wicket.model.Model;
|
|||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
import se.su.dsv.scipro.springdata.services.KeywordService;
|
||||
|
||||
/**
|
||||
* @author: fred-fri@dsv.su.se
|
||||
* created: 2012-08-31 13:59
|
||||
*/
|
||||
public abstract class KeywordEditPanel extends Panel {
|
||||
public class KeywordEditPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private KeywordService keywordService;
|
||||
|
@ -24,19 +26,32 @@ public abstract class KeywordEditPanel extends Panel {
|
|||
private AjaxLink<Void> saveLink;
|
||||
private TextField<String> inputField;
|
||||
|
||||
public abstract void onPress(AjaxRequestTarget target);
|
||||
|
||||
public KeywordEditPanel(String id, final IModel<Keyword> model) {
|
||||
super(id, model);
|
||||
add(new KeywordEditForm("form", model));
|
||||
}
|
||||
|
||||
private class KeywordEditForm extends Form<Keyword> {
|
||||
private static final long serialVersionUID = 147769845081961025L;
|
||||
|
||||
add(inputField = new TextField<String>("inputField", new PropertyModel<String>(model, "keyword")));
|
||||
add(saveLink = new AjaxLink<Void>("saveLink") {
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
System.out.println(inputField.getModelObject());
|
||||
onPress(target);
|
||||
}
|
||||
});
|
||||
public KeywordEditForm(String id, final IModel<Keyword> model) {
|
||||
super(id, model);
|
||||
add(inputField = new TextField<String>("inputField", new PropertyModel<String>(model, "keyword")));
|
||||
Button button = new Button("saveButton") {
|
||||
|
||||
private static final long serialVersionUID = 8805671593150004137L;
|
||||
|
||||
@Override
|
||||
public void onSubmit() {
|
||||
try{
|
||||
System.out.println(model.getObject());
|
||||
info("success");
|
||||
} catch (Exception e){
|
||||
error("error");
|
||||
}
|
||||
}
|
||||
};
|
||||
add(button);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user