Hi,
I'm trying to get the aui-restful table working for my gadget plugin, to have a nice ui.
Unfortunately I found out that my @POST-annotated create() methods provided Javabean parameter is always empty.
This is my ajs.restfulTable part of config.js where the AUI table is set up:
new AJS.RestfulTable({ autoFocus: true, el: jQuery("#config-fields-table"), allowReorder: true, resources: { all: baseUrl +"/rest/otrs-config/1.0/alltickets", self: baseUrl +"/rest/otrs-config/1.0/ticketfield" }, columns: [ { id: "fieldname", header: AJS.I18n.getText("common.words.name") }, { id: "colname", header: AJS.I18n.getText("common.words.description") } ] });
And here is the Serverside Java Beanclass:
@XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public static final class TicketField { @XmlElement private Integer id = 0; @XmlElement private String fieldname = ""; @XmlElement private String colname = ""; public String getColname() { return colname; } public void setColname(String colname) { this.colname = colname; } public String getFieldname() { return fieldname; } public void setFieldname(String fieldname) { this.fieldname = fieldname; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @Override public String toString(){ return "id: "+id+" fieldname: "+fieldname+" colname: "+colname ; } }
...and finally the create() Method:
@POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public Response create(final TicketField bean) { logger.error("created ticketfield:"+bean); return Response.ok(transactionTemplate.execute(new TransactionCallback() { @Override public Object doInTransaction() { PluginSettings settings = pluginSettingsFactory.createGlobalSettings(); List<TicketField> fields = findAllTicketFields(); bean.setId(createTicketFieldID()); if (fields.contains(bean) == false) { fields.add(bean); } settings.put(fieldsListKey, fields); return bean; } })).build(); }
Does anyone see what am I doing wrong??
Thanks in advance
Community moderators have prevented the ability to post new answers.
I found the answer, and it's disappointing: The post request is empty!! https://answers.atlassian.com/questions/173421/restful-table-post-request-is-empty
Maybe I should show you the response of a GET /ticket/id Request:
Instead of something like '[{"id": 1, "colname": "age", "fieldname": "Age"}]'
I get something like '["de.package.path.to.resource.class.TicketResource@TicketField_345234sdf"]'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try to change
public static final class TicketField
to
public class TicketField
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
why should I change this? I have many other REST classes that are marked as final, and it works with them. And in the official Documentation, the classes are also marked as final. see https://developer.atlassian.com/display/AUI/RESTful+Table
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Forgot to mention the output of the log-statement:
" /rest/otrs-config/1.0/ticketfield [acocon.jira.otrs.rest.TicketFieldsResource] created ticketfield:id: 0 fieldname: colname: "
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.