I want to bindBiderectional() DatePicker. Here is what I did
#FXMLController("title.fxml")
public class Controller {
#FXML
private DatePicker dp_date_from;
#Inject
private Model model;
...
#PostConstruct
public void init(){
...
dp_date_from.valueProperty().bindBidirectional(model.dateFromProperty());
...
}
Model Class
#FlowScoped
public class Model {
private ObjectProperty<LocalDate> dateFrom;
public ObjectProperty<LocalDate> dateFromProperty() {
return dateFrom;
}
...
}
It throws an error:
io.datafx.controller.FxmlLoaderException:java.lang.reflect.InvocationTargetException
What can be the reason for that?
Error, is thrown in application itself, it doesn't write anything in a console. I've debegged the code, and when it comes to line dp_date_from.valueProperty... it goes here for throwing an exception:
public <T> ViewContext<T> createByController(Class<T> controllerClass, String fxmlName, ViewConfiguration viewConfiguration, Object... viewContextResources) throws FxmlLoadException {
try {
Object e = controllerClass.newInstance();
ViewMetadata metadata = new ViewMetadata();
FXMLController controllerAnnotation = (FXMLController)controllerClass.getAnnotation(FXMLController.class);
if(controllerAnnotation != null && !controllerAnnotation.title().isEmpty()) {
metadata.setTitle(controllerAnnotation.title());
}
if(controllerAnnotation != null && !controllerAnnotation.iconPath().isEmpty()) {
metadata.setGraphic(new ImageView(controllerClass.getResource(controllerAnnotation.iconPath()).toExternalForm()));
}
FXMLLoader loader = this.createLoader(e, fxmlName, viewConfiguration);
Node viewNode = (Node)loader.load();
ViewContext context = new ViewContext(viewNode, e, metadata, viewConfiguration, viewContextResources);
context.register(e);
context.register("controller", e);
this.injectFXMLNodes(context);
context.getResolver().injectResources(e);
Method[] var11 = e.getClass().getMethods();
int var12 = var11.length;
for(int var13 = 0; var13 < var12; ++var13) {
Method method = var11[var13];
if(method.isAnnotationPresent(PostConstruct.class)) {
method.invoke(e, new Object[0]);
}
}
return context;
} catch (Exception var15) {
throw new FxmlLoadException(var15);
}
}
Thanks, the error is due to I didn't initialized dateFrom. I've just added this part into Model class
public ObjectProperty<LocalDate> dateFromProperty() {
if(dateFrom == null){
dateFrom = new SimpleObjectProperty<>();
}
return dateFrom;
}
Thanks to everybody
Related
i'm trying to implement a lucene filter to remove a prefix from a term in a query.
It seems that sometime after multiple queries, the filter has been reused so the char buffer is dirty.
Code below is simplified, prefix is an external parameter.
public static class PrefixFilter extends TokenFilter {
private final PackedTokenAttributeImpl termAtt = (PackedTokenAttributeImpl) addAttribute(CharTermAttribute.class);
public PrefixFilter(TokenStream in) {
super(in);
}
#Override
public final boolean incrementToken() throws IOException {
if (!input.incrementToken()) {
return false;
}
String value = new String(termAtt.buffer());
value = value.trim();
value = value.toLowerCase();
value = StringUtils.removeStart(value, "prefix_");
if (value.isBlank()) {
termAtt.setEmpty();
} else {
termAtt.copyBuffer(value.toCharArray(), 0, value.length());
termAtt.setLength(value.length());
}
return true;
}
}
So after 10 or twelve queries, the value "prefix_a" became "abcde".
So i'm trying to add termBuffer offset end value in this way:
termAtt.setEmpty();
termAtt.resizeBuffer(value.length());
termAtt.copyBuffer(value.toCharArray(), 0, value.length());
termAtt.setLength(value.length());
termAtt.setOffset(0, value.length());
But i don't know if it's correct. Can anyone help me?
Thanks.
See if this helps you,
/**
* Standard number token filter.
*/
public class StandardnumberTokenFilter extends TokenFilter {
private final LinkedList<PackedTokenAttributeImpl> tokens;
private final StandardnumberService service;
private final Settings settings;
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
private final PositionIncrementAttribute posIncAtt = addAttribute(PositionIncrementAttribute.class);
private State current;
protected StandardnumberTokenFilter(TokenStream input, StandardnumberService service, Settings settings) {
super(input);
this.tokens = new LinkedList<>();
this.service = service;
this.settings = settings;
}
#Override
public final boolean incrementToken() throws IOException {
if (!tokens.isEmpty()) {
if (current == null) {
throw new IllegalArgumentException("current is null");
}
PackedTokenAttributeImpl token = tokens.removeFirst();
restoreState(current);
termAtt.setEmpty().append(token);
posIncAtt.setPositionIncrement(0);
return true;
}
if (input.incrementToken()) {
detect();
if (!tokens.isEmpty()) {
current = captureState();
}
return true;
} else {
return false;
}
}
private void detect() throws CharacterCodingException {
CharSequence term = new String(termAtt.buffer(), 0, termAtt.length());
Collection<CharSequence> variants = service.lookup(settings, term);
for (CharSequence ch : variants) {
if (ch != null) {
PackedTokenAttributeImpl token = new PackedTokenAttributeImpl();
token.append(ch);
tokens.add(token);
}
}
}
#Override
public void reset() throws IOException {
super.reset();
tokens.clear();
current = null;
}
#Override
public boolean equals(Object object) {
return object instanceof StandardnumberTokenFilter &&
service.equals(((StandardnumberTokenFilter)object).service) &&
settings.equals(((StandardnumberTokenFilter)object).settings);
}
#Override
public int hashCode() {
return service.hashCode() ^ settings.hashCode();
}
}
https://github.com/jprante/elasticsearch-plugin-bundle/blob/f63690f877cc7f50360faffbac827622c9d404ef/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/analysis/standardnumber/StandardnumberTokenFilter.java
I write warehouse application and firstly I wrote code which will be displayed in console. Now i want to display it as window in javafx. How I can throw it to javaFX label? Below is code which i have as validators and now i want to throw it in javafx. I have also implement user service which send login and password and check it by validators. Im working in scenebuilder. Maybe anyone has easier solution for check login, password and throw information about wrong length?
Validator
public class UserValidator {
private UserDao userDao = UserDaoImpl.getInstance();
private static UserValidator instance = null;
public static UserValidator getInstance() {
if(instance == null) {
instance = new UserValidator();
}
return instance;
}
private final int LOGIN_MIN_LENGTH = 5;
private final int LOGIN_MAX_LENGTH = 20;
private final int PASSWORD_MIN_LENGTH = 8;
private final int PASSWORD_MAX_LENGTH = 20;
public boolean isValidateAddUser(User user) throws UserLoginIsExistException, UserLoginEnoughLengthException, UserPasswordEnoughLengthException,
UserPasswordIsOneCharUpCaseException {
if(isLoginEnoughLength(user.getLogin()))
throw new UserLoginEnoughLengthException("Login must be minimum 5 and maximum 20 letters!");
if(isPasswordEnoughLength(user.getPassword()))
throw new UserPasswordEnoughLengthException("Password must be minimum 8 and maximum 20 letters!");
if(isPasswordOneCharUpperCase(user.getPassword()))
throw new UserPasswordIsOneCharUpCaseException("Password must have one uppercase letter!");
if (isUserAlreadyExist(user.getLogin()))
throw new UserLoginIsExistException("Login is exist!");
return true;
}
public boolean isValidateUpdateUserPassword(String newPassword) throws UserPasswordEnoughLengthException,
UserPasswordIsOneCharUpCaseException{
if(isPasswordEnoughLength(newPassword)) {
throw new UserPasswordEnoughLengthException("Password must be minimum 8 and maximum 20 letters!");
}
if(isPasswordOneCharUpperCase(newPassword)) {
throw new UserPasswordIsOneCharUpCaseException("Password must have one uppercase letter!");
}
return true;
}
private boolean isLoginEnoughLength(String login) {
return login.length() < LOGIN_MIN_LENGTH || login.length() > LOGIN_MAX_LENGTH;
}
private boolean isPasswordEnoughLength(String password) {
return password.length() < PASSWORD_MIN_LENGTH || password.length() > PASSWORD_MAX_LENGTH;
}
private boolean isPasswordOneCharUpperCase(String password) {
for(char checkUpperCase : password.toCharArray()) {
if(Character.isUpperCase(checkUpperCase)) {
return false;
}
}
return true;
}
private boolean isUserAlreadyExist(String login) {
List<User> users = null;
users = userDao.getAllUsers();
for(User user : users) {
if(user.getLogin().equals(login)) {
return true;
}
}
return false;
}
}
UI
public class UserImpl implements UserService {
private UserValidator userValidator = UserValidator.getInstance();
private UserDao userDao = UserDaoImpl.getInstance();
private static UserImpl instance = null;
public static UserImpl getInstance() {
if (instance == null) {
instance = new UserImpl();
}
return instance;
}
public boolean addUser(User user) {
try {
if (userValidator.isValidateAddUser(user)) {
userDao.addUser(user);
return true;
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
return false;
}
UI facade
public class UserFacadeImpl implements UserFacade {
private static UserService userService = UserImpl.getInstance();
private static UserFacadeImpl instance = null;
public static UserFacadeImpl getInstance() {
if(instance == null) {
instance = new UserFacadeImpl();
}
return instance;
}
public boolean registerUser(User user) {
return userService.addUser(user);
}
Register Controller
public class RegisterControler {
String login, password, email;
private static UserFacade userFacade = UserFacadeImpl.getInstance();
#FXML
TextField fieldLogin;
#FXML
TextField fieldPassword;
#FXML
TextField fieldEmail;
#FXML
Label labelValidator;
public boolean isRegister() {
login = fieldLogin.getText();
password = fieldPassword.getText();
email = fieldEmail.getText();
User user = new User(login, password, email);
if (userFacade.registerUser(user)) {
labelValidator.setText("Register Successfully!");
}
else {
}
return false;
}
public void buttonRegister() {
isRegister();
}
I have an issue with realm. I receive a custom object from an API. I assign this object to a POJO object using retrofit. Within this object I have an ArrayList of the ToDoItemobject which extends RealmObject.
I receive the data correctly with all attributes, everything gets correctly assigned. I run it through my synchronization algorithm and save it to realm in a writing transaction. But when retrieving the data after realm.commit(); the attributes of the objects are all 0 or null.
The method isManaged()is always false, even after the writing transaction, which I don't understand because in the official documentation is states that a POJO can be converted to a managed object using the copyToRealm method.
I already tried a number of things: creating the GetItemResponseClass as RealmObject, but not possible since it has to extend JSONObject to correctly receive the data from the API. I also tried to write the whole list directly to realm but the result was the same.
As a side note, it can be that my method syncPendingLists has some logic errors, but I couldn't debug it yet, since the attributes were always o and null. Thanks for any help.
Here my code from the Activity:
public class MainActivity extends AppCompatActivity{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Realm.init(this);
RealmConfiguration config = new RealmConfiguration.Builder().name("myrealm.realm").build();
Realm.setDefaultConfiguration(config);
realm = Realm.getDefaultInstance();
RealmResults<Counter> counterList = realm.where(Counter.class).findAll();
//setting up counterObject
if (counterList.isEmpty()) {
counterObject = new Counter();
COUNTER = counterObject.getCounter();
} else {
counterObject = counterList.get(0);
COUNTER = counterObject.getCounter();
}
initializeLists();
//Adding the Fragment
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.add(R.id.fragment_container, new DoneListFragment(), "DoneListFragment");
ft.add(R.id.fragment_container, new PendingListFragment(), "PendingListFragment");
ft.commit();
RetrofitClient retrofitClient = new RetrofitClient();
Retrofit retrofit = retrofitClient.getClient();
mAPIInterface = retrofit.create(ToDoistAPIInterface.class);
}
public void getRemoteItems() {
final ArrayList<ToDoItem> onlineItems = new ArrayList<ToDoItem>();
JSONArray array = new JSONArray();
array.put("items");
String auxMessage = array.toString();
mAPIInterface.getItems(RetrofitClient.TOKEN, "*", auxMessage).enqueue(new Callback<GetItemsResponseClass>() {
#Override
public void onResponse(Call<GetItemsResponseClass> call, Response<GetItemsResponseClass> response) {
GetItemsResponseClass itemsResponseClass = new GetItemsResponseClass();
itemsResponseClass = response.body();
remoteItemsList = itemsResponseClass.getItems();
boolean test = remoteItemsList.get(0).isManaged(); //returns false
boolean test1 = remoteItemsList.get(0).isValid(); //returns true refers to singleton RealmObject
syncPendingLists(pendingItemList, remoteItemsList);
}
#Override
public void onFailure(Call<GetItemsResponseClass> call, Throwable t) {
Snackbar.make(floatingButton, "Ups - Couldn't sync items, next time, I promise", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
private void initializeLists() {
RealmResults<ToDoItem> realmToDoItemPendingList = realm.where(ToDoItem.class).equalTo("checkedOffline", false).findAll();
initializingArrayListFromDB(realmToDoItemPendingList, pendingItemList);
RealmResults<ToDoItem> realmToDoItemDoneList = realm.where(ToDoItem.class).equalTo("checkedOffline", true).findAll();
initializingArrayListFromDB(realmToDoItemDoneList, doneItemList);
}
private void initializingArrayListFromDB(RealmResults<ToDoItem> realmToDoItemPendingList, ArrayList<ToDoItem> arrayList) {
int h;
for (h = 0; h < realmToDoItemPendingList.size(); h++) {
arrayList.add(realmToDoItemPendingList.get(h));
}
}
public void syncPendingLists(ArrayList<ToDoItem> offlinePendingList, ArrayList<ToDoItem> onlinePendingList) {
//is my sync algorithm, the important part is the for loop at the end of this method
boolean hasMatch = false;
boolean itemChanged = false;
Date offlineDate = null;
Date onlineDate = null;
if (!offlinePendingList.isEmpty()) {
for (ToDoItem item1 : offlinePendingList) {
if (item1.getId() < 10000) {
try {
createNewRemoteItem(item1);
} catch (JSONException e) {
e.printStackTrace();
}
} else {
for (int i = 0; i < onlinePendingList.size(); i++) {
if (item1.getId() == onlinePendingList.get(i).getId()) {
hasMatch = true;
onlinePendingList.remove(onlinePendingList.get(i));
//Compare Fields
if (!item1.getContent().equals(onlinePendingList.get(i).getContent())) {
itemChanged = true;
}
if (item1.getPriority() != onlinePendingList.get(i).getPriority()) {
itemChanged = true;
}
if (!item1.getDate_string().equals(onlinePendingList.get(i).getDate_string())) {
itemChanged = true;
}
if (itemChanged == true) {
//Format edit dates to date
DateFormat format = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH);
try {
offlineDate = format.parse(item1.getDateAdded());
} catch (ParseException e) {
e.printStackTrace();
}
try {
onlineDate = format.parse(onlinePendingList.get(i).getDateAdded());
} catch (ParseException e) {
e.printStackTrace();
}
//compare dates to see which was last edited
if (offlineDate.compareTo(onlineDate) > 0) {
try {
deleteRemoteItem(onlinePendingList.get(i), "item_delete");
createNewRemoteItem(item1);
} catch (JSONException e) {
e.printStackTrace();
}
} else if (offlineDate.compareTo(onlineDate) < 0) {
addOrUpdateToDB(item1);
}
}
}
if (!hasMatch) {
deleteObjectFromDB(item1);
}
}
}
}
}
for (ToDoItem onlineItem1 : onlinePendingList) {
boolean isManaged1 = onlineItem1.isManaged(); //returns false, which is ok since it is not yet in the realm db
onlineItem1.setLocalId(counterObject.getCounter());
addOrUpdateToDB(onlineItem1);
boolean asdf = onlineItem1.isManaged(); //it returns false, but it should return true
incrementCounter(counterObject);
}
initializeLists();
getPendingListFragment().refreshFragment();
}
private void addOrUpdateToDB(ToDoItem newItem) {
boolean test2= newItem.isManaged(); //returns false
realm.beginTransaction();
realm.copyToRealmOrUpdate(newItem);
//realm.copyToRealm(newItem); //I tried this method as well, but no difference
realm.commitTransaction();
boolean test3= newItem.isManaged(); //returns false, and here is the problem, it should return true, shouldn't it?
assignValuesToToDoItem(itemWithValues, newItem);
saveCounterToDB(counterObject);
}
}
Here my class code of ToDoItem:
public class ToDoItem extends RealmObject implements Parcelable {
public static final Creator<ToDoItem> CREATOR = new Creator<ToDoItem>() {
#Override
public ToDoItem createFromParcel(Parcel in) {
return new ToDoItem(in);
}
#Override
public ToDoItem[] newArray(int size) {
return new ToDoItem[size];
}
};
#PrimaryKey
private long localId;
private String content;
private boolean checkedOffline = false;
private int priority;
private String date_string;
private String temp_id;
private long id;
private String date_added;
public ToDoItem(String name) {
this.content = name;
}
public ToDoItem() {
}
protected ToDoItem(Parcel in) {
localId = in.readLong();
content = in.readString();
checkedOffline = in.readByte() != 0;
priority = in.readInt();
date_string = in.readString();
temp_id = in.readString();
id = in.readLong();
date_added=in.readString();
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public boolean isCheckedOffline() {
return checkedOffline;
}
public void setCheckedOffline(boolean checkedOffline) {
this.checkedOffline = checkedOffline;
}
public Long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public void setRemote_id(Long remote_id) {
this.id = remote_id;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public boolean isDone() {
return checkedOffline;
}
public String getDate_string() {
return date_string;
}
public void setDate_string(String date_string) {
this.date_string = date_string;
}
public long getLocalId() {
return this.localId;
}
public void setLocalId(long i) {
this.localId = i;
}
public String getTemp_id() {
return temp_id;
}
public void setTemp_id(String temp_id) {
this.temp_id = temp_id;
}
public String getDateAdded() {
return date_added;
}
public void setDateAdded(String dateAdded) {
this.date_added = dateAdded;
}
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(localId);
dest.writeString(content);
dest.writeByte((byte) (checkedOffline ? 1 : 0));
dest.writeInt((priority));
dest.writeString(date_string);
dest.writeString(temp_id);
dest.writeLong(id);
dest.writeString(date_added);
}
#Override
public String toString() {
return "localId: " + localId + "; content: " + content;
}
}
And here the code for the GetItemsResponseClass:
public class GetItemsResponseClass extends JSONObject {
private String sync_token;
#SerializedName("temp_id_mapping")
private HashMap<String, Long> temp_id_mapping;
private boolean full_sync;
#SerializedName("items")
private ArrayList<ToDoItem> items;
public GetItemsResponseClass(){
}
public String getSync_token() {
return sync_token;
}
public void setSync_token(String sync_token) {
this.sync_token = sync_token;
}
public HashMap<String, Long> getTemp_id_mapping() {
return temp_id_mapping;
}
public void setTemp_id_mapping(HashMap<String, Long> temp_id_mapping) {
this.temp_id_mapping = temp_id_mapping;
}
public boolean isFull_sync() {
return full_sync;
}
public void setFull_sync(boolean full_sync) {
this.full_sync = full_sync;
}
public ArrayList<ToDoItem> getItems() {
return items;
}
public void setItems(ArrayList<ToDoItem> items) {
this.items = items;
}
}
EDIT: Apparently it is a desired behavior that the object does not get saved with its attributes. Consequently to assign the values you have to use getters and setters. I added the following method, however even when debugging with a watch, as stated in the official documentation the values do not get assigned:
private void assignValuesToToDoItem(ToDoItem itemWithValues, ToDoItem newItem) {
realm.beginTransaction();
newItem.setContent(itemWithValues.getContent()); //the content variable stays null
newItem.setCheckedOffline(itemWithValues.isDone()); //stays false
newItem.setPriority(itemWithValues.getPriority());
newItem.setDate_string(itemWithValues.getDate_string());
newItem.setTemp_id(itemWithValues.getTemp_id());
newItem.setId(itemWithValues.getId());
newItem.setDate_added(itemWithValues.getDate_added());
realm.commitTransaction();
}
I added this line assignValuesToToDoItem(itemWithValues, newItem); in the main activity in the method private void addOrUpdateToDB(ToDoItem newItem) {...}
Same result...
I found out 2 very important things:
The attributes are saved, however in the debugging window they appear to be 0, false or null
Even putting a Debugging Watch does not show the correct values.
To see the real value how it is in the database you have to add a Watch and put the watch directly on the getters of the object. In my case I added a Watch and typed in "newItem.getContent()". With this line I got the title of my object. However just putting a Watch with "newItem" shows "null".
copyToRealm() and copyToRealmOrUpdate() returns the managed proxy as a return value of the function you're calling.
realm.copyToRealmOrUpdate(newItem);
realm.commitTransaction();
boolean test3= newItem.isManaged(); //returns false, and it should return false
Should be
newItem = realm.copyToRealmOrUpdate(newItem);
realm.commitTransaction();
boolean test3= newItem.isManaged(); //returns true
I wanted to retrieve found object or a null from a database.
In my ProjectFollowerImpl, for a method useFollowingProject I return a single instance that matches the query, or null if the query returns no results.
#Override
public ProjectFollower userFollowingProject(Integer userId, Integer projectId) {
return (ProjectFollower) session.createCriteria(classType)
.add(Restrictions.eq("user.id", userId))
.add(Restrictions.eq("project.id", projectId))
.uniqueResult();
}
Then in a tapestry page, I have following methods:
public ProjectFollower getUserFollowingProject() {
return projectFollowerDao.userFollowingProject(loggedInUser.getId(), project.getId());
}
#CommitAfter
void onActionFromFollowProject() {
ProjectFollower pf = getUserFollowingProject();
if (pf != null) {
projectFollowerDao.delete(pf.getId());
} else {
pf = new ProjectFollower();
pf.setProjectId(project);
pf.setUserId(loggedInUser);
projectFollowerDao.merge(pf);
}
}
However, tapestry throws null pointer exception, stack trace:
com.rile.issuetracker.pages.Tracker getUserFollowingProject() Tracker.java 75
com.rile.issuetracker.pages.Tracker advised$onActionFromFollowProject_6d8b9673baf() Tracker.java 80
So why is it a problem to return a null value for a object? What am I doing wrong ?
UPDATE:
public class Tracker {
#Property
#SessionState
private User loggedInUser;
#Property
#Inject
private ProjectDao projectDao;
#Property
private Project projectP1, project;
#Property
private List<Project> projectList;
#Property
#Inject
private ProjectFollowerDao projectFollowerDao;
#Property
#Inject
private TicketDao ticketDao;
#Property
private List<Ticket> ticketList;
#Property
private Ticket ticketP1;
#Property
#Inject
private TicketFollowerDao ticketFollowerDao;
#Property
private Util util = new Util();
public boolean getLoggedIn() {
return loggedInUser.getEmail() != null;
}
#PageLoaded
void onPageLoad() {
projectList = projectDao.loadAll();
ticketList = ticketDao.loadAll();
}
void onActivate(Integer contextValue) {
if (contextValue != null) {
project = projectDao.getByID(contextValue);
}
if (project != null) {
List ticketListByProjectID = ticketDao.getTicketsByProjectID(project.getId());
if (!ticketListByProjectID.isEmpty()) {
ticketList = ticketListByProjectID;
} else {
ticketList = null;
}
}
}
public ProjectFollower getUserFollowingProject() {
return projectFollowerDao.userFollowingProject(loggedInUser.getId(), project.getId());
}
#CommitAfter
void onActionFromFollowProject() {
ProjectFollower pf = getUserFollowingProject();
if (pf != null) {
projectFollowerDao.delete(pf.getId());
} else {
pf = new ProjectFollower();
pf.setProjectId(project);
pf.setUserId(loggedInUser);
projectFollowerDao.merge(pf);
}
}
public boolean getIsUserFollowingTicket() {
return ticketFollowerDao.isUserFollowingTicket(loggedInUser.getId(), ticketP1.getId());
}
#CommitAfter
void onActionFromFollowTicket() {}
public String getActiveFor(String parameter) {
if (parameter == null || parameter.isEmpty()) {
return null;
}
switch (parameter) {
case "userFollowingProject":
return getUserFollowingProject() != null ? "active" : "null";
case "userFollowingTicket":
return getIsUserFollowingTicket() ? "anchor-active" : "anchor-inactive";
default:
return null;
}
}
}
From the complete code, it looks like the best bet is that project is null, after checking complete class, we see that its not injected, and its value is only set in onActivate function, if contextValue is not null and projectDao.getByID(contextValue) returns a non-null value.
Could you please confirm that is happenning correctly before the call to onActionFromFollowProject
all guys
I am developing with Flex + java + hibernate in one project.
I am trying to add one more advanceddatagridcolumn in flex AdavanedDataGrid control.
Actually it work very well but only except I added column’s data.
I have no idea what should I do to make it out
I am telling work flow.
At first call select method in DeliveryService.class through the RemoteObject and then call
DeliveryMgr.class for call business work. After get return list type return value it pass to presentation class to setting all of the selected return value.
I can print trace log what I added column’s data in DeliveryPt.class but it cannot return to flex area.
Strange thing is I can check out value of what I want to show data in DeliveryPt.class but it does not show up in AdvanedDataGridColumn of Flex.
Thank you for reading in Advance.
DeliverService.java
public DeliveryService() {
}public List<DeliveryPt> selectMaterialForReReceiptDelivery(String referenceNo,String team,String buyerCode,Integer kind,String sessionId){
List<DeliveryPt> rtnList = new ArrayList<DeliveryPt>();
List<Delivery> tmpList = new ArrayList<Delivery>();
ApplicationContext ac = CommonResource.getAppcontext();
DeliveryMgr dmgr = (DeliveryMgr)ac.getBean("DeliveryMgr");
tmpList = dmgr.selectMaterialForReReceiptDelivery(referenceNo,team,buyerCode,kind,sessionId);
for (int i=0; i<tmpList.size(); i++){
DeliveryPt dp = new DeliveryPt(tmpList.get(i));
rtnList.add(dp);
}
return rtnList;
}
}
DeliveryPt.java
public class DeliveryPt {
//2011.02.23 New Added DeliverySlipNo to show in flex
public String DeliverySlipSlipNo;
public DeliveryPt(Delivery delivery) {
this.setDeliveryNo(delivery.getDeliveryNo());
this.ReIncomeFlag = delivery.getReIncomeFlag();
ApplicationContext ac = CommonResource.getAppcontext();
StockMgr smgr = (StockMgr)ac.getBean("StockMgr");
Stock stock = smgr.getStock(delivery.getStock_Id());
if (delivery.getBooking() != null){
this.setOrderType(delivery.getOrderType());
this.setSalesOrderNo(delivery.getSalesOrderNo());
this.setRemark(delivery.getRemark());
this.setReferenceNo(stock.getReferenceNo());
// 유저 참조값 시작.
if(delivery.getDeliveryUser() != null){
this.setDeliveryUserName(delivery.getDeliveryUser().getName());
}
if(delivery.getInsertUser() != null){
this.setInsertUserName(delivery.getInsertUser().getName());
}
if(delivery.getUpdateUser() != null){
this.setUpdateUserName(delivery.getUpdateUser().getName());
}
if(delivery.getExpiredUser() != null){
this.setExpiredUserName(delivery.getExpiredUser().getName());
}
if (delivery.getBooking() != null){
if(delivery.getBooking().getInsertUser() != null){
this.setBookingUserName(delivery.getBooking().getInsertUser().getName());
}
}
// 유저 참조값 끝.
// 각종 날짜 입력.
if (delivery.getDeliveryDate() != null){
this.setDeliveryDate(delivery.getDeliveryDate());
}
if (delivery.getExpiredDate() != null){
this.setExpiredDate(delivery.getExpiredDate());
}
if (delivery.getInsertDate() != null){
this.setInsertDate(delivery.getInsertDate());
}
if (delivery.getUpdateDate() != null){
this.setUpdateDate(delivery.getUpdateDate());
}
if (stock.getSizeLabel() != null){
this.SizeLabelId = stock.getSizeLabel().getId();
}
this.Kind_id = stock.getKind_id();
this.StockId = delivery.getStock_Id();
// assigned value to varilable
this.DeliverySlipSlipNo = delivery.getDeliverySlip_SlipNo();
if (stock.getColorMst() != null){
this.ColorCode = stock.getColorMst().getColorCode();
this.ColorName = stock.getColorMst().getColorName();
}
this.Color_Name = stock.getColor_Name();
if (stock.getBuyer() != null){
this.BuyerCode = stock.getBuyer().getCode();
this.BuyerName = stock.getBuyer().getCode();
}
this.Team = stock.getTeam();
this.CancelFlag = delivery.getCancelFlag();
}
public String getBookingUserId() {
return BookingUserId;
}
public void setBookingUserId(String bookingUserId) {
BookingUserId = bookingUserId;
}
public String getDeliveryUserId() {
return DeliveryUserId;
}
public void setDeliveryUserId(String deliveryUserId) {
DeliveryUserId = deliveryUserId;
}
public String getInsertUserId() {
return InsertUserId;
}
public void setInsertUserId(String insertUserId) {
InsertUserId = insertUserId;
}
public String getUpdateUserId() {
return UpdateUserId;
}
public void setUpdateUserId(String updateUserId) {
UpdateUserId = updateUserId;
}
public Integer getSizeLabelId() {
return SizeLabelId;
}
public void setSizeLabelId(Integer sizeLabelId) {
SizeLabelId = sizeLabelId;
}
public Integer getKind_id() {
return Kind_id;
}
public void setKind_id(Integer kind_id) {
Kind_id = kind_id;
}
public Integer getStockId() {
return StockId;
}
public void setStockId(Integer stockId) {
StockId = stockId;
}
//Getter and Setter
public String getDeliverySlipSlipNo() {
return DeliverySlipSlipNo;
}
public void setDeliverySlipSlipNo(String deliverySlipSlipNo) {
DeliverySlipSlipNo = deliverySlipSlipNo;
}
}
Delivery.java
#Entity
#Table(name="Delivery")
public class Delivery {
public Delivery(){} // Default Constructor
#Id #GeneratedValue(strategy=GenerationType.AUTO)
#Column(name="DeliveryNo")
private Integer DeliveryNo;//2011.02.25 Added
#Column(name="DeliverySlip_SlipNo",length=20)
private String DeliverySlip_SlipNo;
//Getters an Setters for DeliverySlip_SlipNo
public String getDeliverySlip_SlipNo() {
return DeliverySlip_SlipNo;
}
public void setDeliverySlip_SlipNo(String deliverySlip_SlipNo) {
DeliverySlip_SlipNo = deliverySlip_SlipNo;
}
Have you added the new column to the equivalent action script object mapped to the Java object?