Permalink
Browse files

Secured forms

  • Loading branch information...
marpiec committed Apr 24, 2012
1 parent 7c84a53 commit 4b02b9010555b9662786d2cf228fa65a9a083fab
@@ -0,0 +1,13 @@
+package pl.marpiec.socnet.web.page.editUserProfilePage.component
+
+import pl.marpiec.socnet.service.userprofile.input.JobExperienceParam
+import pl.marpiec.socnet.web.wicket.SecureFormModel
+
+/**
+ * ...
+ * @author Marcin Pieciukiewicz
+ */
+
+class JobExperienceFormModel extends JobExperienceParam with SecureFormModel {
+
+}
@@ -11,6 +11,8 @@
<form wicket:id="newJobExperienceForm">
+ <input type="hidden" wicket:id="sessionToken" />
+
<div>
Nazwa firmy: <input wicket:id="companyName" />
</div>
@@ -14,6 +14,7 @@ import org.apache.wicket.model.CompoundPropertyModel
import org.apache.wicket.MarkupContainer
import pl.marpiec.socnet.model.{UserProfile, User}
import pl.marpiec.socnet.di.Factory
+import pl.marpiec.socnet.web.wicket.{SecureFormModel, SecureAjaxButton, SecureForm}
/**
* ...
@@ -42,11 +43,11 @@ class JobExperienceListPanel(id: String, val user: User, val userProfile: UserPr
}
- val newJobExperienceForm: Form[JobExperienceParam] = new Form[JobExperienceParam]("newJobExperienceForm") {
+ val newJobExperienceForm: SecureForm[JobExperienceFormModel] = new SecureForm[JobExperienceFormModel]("newJobExperienceForm") {
setOutputMarkupPlaceholderTag(true)
setVisible(false)
- setModel(new CompoundPropertyModel[JobExperienceParam](new JobExperienceParam))
+ setModel(new CompoundPropertyModel[JobExperienceFormModel](new JobExperienceFormModel))
add(new TextField[String]("companyName"))
add(new TextField[String]("position"))
@@ -55,7 +56,7 @@ class JobExperienceListPanel(id: String, val user: User, val userProfile: UserPr
add(new AjaxButton("cancelButton") {
def onSubmit(target: AjaxRequestTarget, form: Form[_]) {
- val model = form.getModel.asInstanceOf[CompoundPropertyModel[JobExperienceParam]].getObject
+ val model = form.getModel.asInstanceOf[CompoundPropertyModel[JobExperienceFormModel]].getObject
cleanModel(model)
newJobExperienceForm.setVisible(false)
showNewExperienceFormLink.setVisible(true)
@@ -68,10 +69,10 @@ class JobExperienceListPanel(id: String, val user: User, val userProfile: UserPr
}
})
- add(new AjaxButton("submitButton") {
- def onSubmit(target: AjaxRequestTarget, form: Form[_]) {
+ add(new SecureAjaxButton("submitButton") {
+ def onSecureSubmit(target: AjaxRequestTarget, form: Form[_]) {
- val model = form.getModel.asInstanceOf[CompoundPropertyModel[JobExperienceParam]].getObject
+ val model = form.getModel.asInstanceOf[CompoundPropertyModel[JobExperienceFormModel]].getObject
val newExperienceId = uidGenerator.nextUid
@@ -16,6 +16,9 @@
<input type="submit" wicket:id="deleteButton" value="usuń"/>
</div>
<form wicket:id="experienceForm">
+
+ <input type="hidden" wicket:id="sessionToken" />
+
<div>
Nazwa firmy: <input wicket:id="companyName" />
</div>
@@ -12,6 +12,7 @@ import org.apache.wicket.markup.html.form.{TextArea, TextField, Form}
import org.apache.wicket.ajax.markup.html.form.AjaxButton
import pl.marpiec.socnet.di.Factory
import pl.marpiec.socnet.model.{UserProfile, User}
+import pl.marpiec.socnet.web.wicket.SecureForm
/**
* ...
@@ -56,15 +57,15 @@ class JobExperiencePanel(id: String, val user: User, val userProfile: UserProfil
})
- add(new Form[JobExperienceParam]("experienceForm") {
+ add(new SecureForm[JobExperienceFormModel]("experienceForm") {
- val jobExperienceModel = new JobExperienceParam
+ val jobExperienceModel = new JobExperienceFormModel
jobExperienceModel.companyName = jobExperience.companyName
jobExperienceModel.position = jobExperience.position
jobExperienceModel.description = jobExperience.description
jobExperienceModel.id = jobExperience.id
- setModel(new CompoundPropertyModel[JobExperienceParam](jobExperienceModel))
+ setModel(new CompoundPropertyModel[JobExperienceFormModel](jobExperienceModel))
add(new TextField[String]("companyName"))
add(new TextField[String]("position"))
@@ -73,7 +74,7 @@ class JobExperiencePanel(id: String, val user: User, val userProfile: UserProfil
add(new AjaxButton("cancelButton") {
def onSubmit(target: AjaxRequestTarget, form: Form[_]) {
- val model = form.getModel.asInstanceOf[CompoundPropertyModel[JobExperienceParam]].getObject
+ val model = form.getModel.asInstanceOf[CompoundPropertyModel[JobExperienceFormModel]].getObject
model.companyName = jobExperience.companyName
model.position = jobExperience.position
model.description = jobExperience.description
@@ -89,7 +90,7 @@ class JobExperiencePanel(id: String, val user: User, val userProfile: UserProfil
add(new AjaxButton("submitButton") {
def onSubmit(target: AjaxRequestTarget, form: Form[_]) {
- val model = form.getModel.asInstanceOf[CompoundPropertyModel[JobExperienceParam]].getObject
+ val model = form.getModel.asInstanceOf[CompoundPropertyModel[JobExperienceFormModel]].getObject
jobExperience.companyName = model.companyName
jobExperience.position = model.position
jobExperience.description = model.description
@@ -10,7 +10,7 @@ import pl.marpiec.socnet.web.page.editUserProfilePage.component.PersonalSummaryF
* @author Marcin Pieciukiewicz
*/
-class SecureForm[M](id:String) extends Form[M](id) {
+class SecureForm[M <: SecureFormModel](id:String) extends Form[M](id) {
add(new HiddenField[String]("sessionToken"))

0 comments on commit 4b02b90

Please sign in to comment.