Hello there,
I have the model class Job
@Entity
public class HttpScheduledJob extends ScheduledJob {
private Authentication authentication;
.......
}
which has an authentication
@Entity
@Embeddable
public class Authentication {
private Long id;
private String schema;
private String username;
private String password;
.......
}
I would like to be able to edit a job using a beaneditform.
I have the EditJob page:
public class EditJob {
@Inject
private BeanModelSource beanModelSource;
@Inject
private Messages messages;
@Property
private BeanModel<Job> jobModel;
@Autowired
@Inject
private JobService jobService;
@Property
private ScheduledJob job;
@InjectPage
private Index index;
void onActivate(String name) {
job = jobService.getJobByName(name);
jobModel = beanModelSource.createEditModel(Job.class, messages);
}
}
Object onSuccess() {
jobService.update(job);
return index;
}
}
EditJob.tml
<html t:type="Layout" title="Edit Job"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
<t:beaneditform t:id="jobEditForm" t:submitLabel="Save" t:object="job"
t:model="jobModel">
</html>
then I have the AppPropertyEditBlocks.java:
public class AppPropertyEditBlocks {
@Property
@Environmental
private PropertyEditContext context;
@Component(parameters = { "label=prop:context.label",
"clientId=prop:context.propertyId",
"annotationProvider=context", "validate=prop:usernameValidator"
})
private TextField username;
@Component(parameters = { "label=prop:context.label",
"clientId=prop:context.propertyId",
"annotationProvider=context" })
private TextField password;
@Component(parameters = { "label=prop:context.label",
"clientId=prop:context.propertyId",
"annotationProvider=context" })
private TextField schema;
@Inject
private ComponentResources resources;
public Authentication getAuthentication() {
return (Authentication) this.context.getPropertyValue();
}
public FieldValidator getUsernameValidator() {
return context.getValidator((Field)this.username);
}
}
and the AppPropertyEditBlock.tml:
<html t:type="Layout" title="Edit"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
<t:block id="Authentication">
Authentication:
<div>
<t:label for="username"> Username: </t:label>
<t:textfield t:id="username" t:value="authentication.username"
/>
</div>
<div>
<t:label for="password"> Password: </t:label>
<t:textfield t:id="password" t:value="authentication.password"
/>
</div>
<div>
<t:label for="schema"> Schema: </t:label>
<t:textfield t:id="schema" t:value="authentication.schema" />
</div>
</t:block>
and in AppModule.java I add:
public static void
contributeDefaultDataTypeAnalyzer(MappedConfiguration<Class, String>
configuration) {
configuration.add(Authentication.class, "authentication");
}
public static void
contributeBeanBlockSource(Configuration<BeanBlockContribution>
configuration) {
configuration.add(new EditBlockContribution("authentication",
"AppPropertyEditBlocks", "authentication"));
}
if I attempt to edit something within the form an press the save button I
get the following exception:
org.apache.tapestry5.ioc.internal.OperationException
Failure writing parameter 'value' of component
AppPropertyEditBlocks:username: Property 'authentication' (within property
expression 'authentication.username', of
foo.web.pages.AppPropertyEditBlocks@68cd6d94) is null.
trace:
Triggering event 'action' on EditJob:httpjobeditform.form
The authentication fields do show up on the edit page, but after I added
them I am unable to edit the job.
This is the first application I have ever written in Tapestry and I am no
doubt doing something foolish, any help would be greatly appreciated.
--
View this message in context:
http://tapestry.1045711.n5.nabble.com/New-to-Tapestry-problem-with-EditBlock-tp4727269p4727269.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]