Sunday, 18 August 2013

Set and Get values in a java file using js

Set and Get values in a java file using js

pI have 3 java clases, and one js file:/p ppublic class User implements
Serializable { /p precodeprivate String userId; private Maplt;String,
CustomUserInfogt; customInfo = new HashMaplt;String, CustomUserInfogt;();
public void setCustomInfo(Maplt;String, CustomUserInfogt; customInfo) {
this.customInfo = customInfo; } public Maplt;String, CustomUserInfogt;
getCustomInfo() { return customInfo; } /code/pre p...etc }/p ppublic class
CustomUserInfo implements Serializable{ /p precodeprivate String key;
private String value; ...etc public CustomUserInfo() { } public
CustomUserInfo(CustomUserInfo other) { setKey(other.getKey());
setValue(other.getValue()); ...etc } public String getKey() { return key;
} public void setKey(String key) { this.key = key; } public String
getValue() { return value; } public void setValue(String value) {
this.value = value; } /code/pre p..etc }/p ppublic class UserServices {/p
precode@POST @Path(/setCustomKey) @Consumes({MediaType.APPLICATION_JSON})
@Description( label = Update key value, value = Allows a user to update a
key value.) public Response setCustomKey() { .....I NEED THE CODE HERE }
@Inject @CurrentUser User user; @get @Path(/getCustomKey)
@Consumes({MediaType.APPLICATION_JSON}) @Description( label = retrieve key
value, value = Allows a user to retrieve a key value.) public Response
getCustomKey() { .....I NEED THE CODE HERE } /code/pre p}/p pmy js file:/p
pvar Company = { I NEED TO MAKE THE AJAX CALLS FROM HERE ...etc }/p pWhen
the aplication runs a user is created with no customUserInfo. I need to
add a key named company with a value of IBM while the application is
running. I want to use an $ajax call to set and retrieve this new key and
value within a .js file, but I don't know how to do it. I created a java
class named UserServices where I want to set and retrieve this
key(company) and value(IBM). I have pieces here and there, but I'm having
a lot of trouble putting it all together: the java files on one end, the
ajax call in the middle, and the javascript on the other end!/p

No comments:

Post a Comment