Primefaces Schedule Error, save event changes the hour automatically to 12am - jsf

I'm using a primefaces schedule component in my aplication and i've detected a strange behaviour. When I select an event and push the "save button" the hour is reset to 12am. After much time investigating, turned to the Primefaces Showcase page for more info.
In the Showcase, schedule behaviour is the same. In the Schedule Editable Example http://www.primefaces.org/showcase/ui/data/schedule.xhtml, for example, select the event with the title "Champions League Match", which date is 28/04/2015 and the hour is from 8:00 to 11:00 and push save button. It automatically changes the hour to 12am. Is it the normal behaviour?????
Thanks.
EDITED: I'll add the code that i have in my aplication, that is the same or very similar to the showcase.
Creation of the event:
eventModel.addEvent(new DefaultScheduleEvent("Champions League Match", previousDay8Pm(), previousDay11Pm()));
Methods to set time frame:
private Date previousDay8Pm() {
Calendar t = (Calendar) today().clone();
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.DATE, t.get(Calendar.DATE) - 1);
t.set(Calendar.HOUR, 8);
return t.getTime();
}
private Date previousDay11Pm() {
Calendar t = (Calendar) today().clone();
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.DATE, t.get(Calendar.DATE) - 1);
t.set(Calendar.HOUR, 11);
return t.getTime();
}
Add method which is invoked when push "Save" button (only i'm trying to change event background to red, with setStyleClass):
public void addEvent(ActionEvent actionEvent) {
event.setStyleClass("emp1");
eventModel.updateEvent(event);
event = new DefaultScheduleEvent();
}

Because its just an example.
Add input text with time selector and add event on specific, While creating an event specify time frame like:
eventModel.addEvent(new DefaultScheduleEvent("Birthday Party", today1Pm(),todat6Pm());
where
private Date today1Pm() {
Calendar t = (Calendar) today().clone();
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.HOUR, 1);
return t.getTime();
}
private Date today6Pm() {
Calendar t = (Calendar) today().clone();
t.set(Calendar.AM_PM, Calendar.PM);
t.set(Calendar.HOUR, 6);
return t.getTime();
}
As for showcase yes you need some update to achieve it :)
Behavior of showcase, if you do not define any time frame and not set AllDay check event is added like eventModel.addEvent(event); which set default time to 12am and Yes it is normal!
Update
Use this method for add new event, startTime/endTime is your field which is set by form. I also paste the default constructor signature with snippet.
public void addEvent(ActionEvent actionEvent) {
if(event.getId() == null)
//DefaultScheduleEvent(String title, Date start, Date end, String styleClass) ;
eventModel.addEvent(new DefaultScheduleEvent(actionEvent.Title(), calculateTime(startTime), calculateTime(endTime),"emp1"));
else
eventModel.updateEvent(event);
}

Related

How can I save value of user-defined in the database without clicking the save button

I have created a user-defined field (Last Activity Date) on the Opportunities (CR304000) screen which is populated from the last Start Date of the activity on the Activities tab of the Opportunities screen (CR304000) on RowSelected as shown on screenshot one. When an activity is added for an opportunity, the user is not required to click the save button on the form of the opportunity, therefore the user-defined field I have added does not save the value to the database. I would like the value of the user-defined field to be saved to the database whenever an activity is added to the opportunity and the value of the user-defined field changes without having to click the save button on the opportunity form as I need to use it on a generic Inquiry.
Screenshot 1
Code Snippet:
protected void CROpportunity_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
var row = (PX.Objects.CR.CROpportunity)e.Row;
if (row == null)
{
return;
}
CRActivity cRActivity = PXSelect<CRActivity, Where<CRActivity.refNoteID, Equal<Required<PX.Objects.CR.CROpportunity.noteID>>>, OrderBy<Desc<CRActivity.startDate>>>.Select(Base, row.NoteID);
if (cRActivity == null)
{
return;
}
CROpportunityExt cROpportunityExt = row.GetExtension<CROpportunityExt>();
cROpportunityExt.UsrLastActivity = cRActivity.StartDate;
Base.Opportunity.SetValueExt<CROpportunityExt.usrLastActivity>(Base.Opportunity.Current, cROpportunityExt.UsrLastActivity);
Base.Save.SetPressed(true);
}
In my opinion, push the value to the opportunity instead from the CRActivityMaint graph in the CRActivity RowPersisted event instead of pulling it from the activity in CROpportunity RowSelected. It is not good practice to change values of DAC rows in the RowSelected event.
Your code would be as follows
In CRActivityMaintExt
In RowPersisted
if (!(e.Row?.EntityDescription?.ToLower().Contains("opportunity") ?? false)) return;
CROpportunity opportunity = SelectFrom<CROpportunity>.Where<CROpportunity.noteID.IsEqual<#P.asGuid>>.View.Readonly.Select(Base, e.Row.RefNoteID);
if (opportunity is null) return;
var oppExt = opportunity.GetExtension<YourExtension>();
oppExt.YourValue = e.Row.SomeValue;
Base.Caches<CROpportunity>().PersistUpdated(opportunity);

Cannot resolve constructor when using TimePickerDialog.OnTimeSetListener

I am using the same method for my time picker as I am for my date picker. My date is working perfecty fine, but the time dialog keeps showing me an error. I have looked into similar issues, but nobody has been in a relatable situation.
This is the code for the time picker dialog:
timePickerDialog = new TimePickerDialog(AddReminderActivity.this,
new TimePickerDialog.OnTimeSetListener() {
#Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
Calendar calendar = Calendar.getInstance();
calendar.set(hourOfDay, minute);
SimpleDateFormat format = new SimpleDateFormat("hh:mm a");
String timeString = format.format(calendar.getTime());
r_time.setText((timeString));
}
}, mHour, mMinute);
timePickerDialog.show();
Here is also the error I keep getting:
Cannot resolve constructor 'TimePickerDialog(json.google_services.newreminderapp.AddReminderActivity, anonymous android.app.TimePickerDialog.OnTimeSetListener, int, int)'
Thank you.
After mMinute add true or false as another parameter. True - if you want 24 hour time, false if you want 12 hour time

is it possible to animate date or time picker to a particular time

currently i am working on Date picker and time picker, so one required comes out is that is it possible to animate(roll) date picker or time picker to a particular time as i am not able to find this on stackoverflow
is there something we can do in OnTimeChangedListener or OnDateChangedListener to achieve this
OnDateChangedListener mdatechange=new OnDateChangedListener() {
#Override
public void onDateChanged(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
// TODO Auto-generated method stub
//Logic for Animation
}
};
or if its possible with XML
please guide me

UICollectionview SelectItem programmatically not changing background

I have a UICollectionView with images. The user can select (multiselect) the images. When the user taps a single image, everything works fine. The SelectedBackgroundView is visible and on tap again, the normal image is visible.
But my problem is, I have a option for the user "Select all". In that i want to select all items programmatically. With following code:
for (int i = 0; i < CollectionView.NumberOfItemsInSection(0); i++)
{
var ip = NSIndexPath.FromItemSection(i, 0);
CollectionView.SelectItem(ip, false, UICollectionViewScrollPosition.None);
}
The following method returns the correct number for the selected items:
var number = CollectionView.GetIndexPathsForSelectedItems().Length;
But the UI is not changing to the SelectedBackgroundView.
Can anyone help me? Thanks.
Calling SelectItem does not cause the display to be updated; it just changes the Selected property of the UICollectionViewCell therefore updating the selected index set in the collection view.
What I do is override the Selected property of my UICollectionViewCell implementation and adjust the UI at that point:
public class MyCell : UICollectionViewCell
{
// ...
public override bool Selected
{
get { return base.Selected; }
set
{
base.Selected = value;
// change the state of the selected background
imageBackground.Image = LoadAnImage(value ? "BackgroundOn" : "BackgroundOff");
}
}
}
This way ensures that the UI is updated at all possible points when the selected state of the cell changes, either by user interaction or programmatically calling SelectItem or DeselectItem on the collection view.
I do not personally use the SelectedBackgroundView property on a cell (I do my own layering, most of the time), but you may have to manually bring that view to the front yourself in a similar Selected property override.

How to add calendar in lwuit TextField or comboBox

I am creating an application using lwuit. And i want to add calendar in comboBox. please give me an idea as soon as possible..
Do u mean that you want to add the selected date of calendar component at the end of combobox values or to show the selected date in textbox?
If so, then below code shows the selected date of calendar component in textbox:
Button cal = new Button("Calendar"); // button for calendar
cal.addActionListener(new ActionListener() { // define action for button
// action listener to show the calendar container
public void actionPerformed(ActionEvent ae) {
final Form calFrame = new Form();
final Calendar cal = new Calendar();
calFrame.setScrollable(true);
calFrame.setSmoothScrolling(true);
calFrame.setIsScrollVisible(true);
cal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
txtDate.setText(cal.getDate()); // textfield in which date should be set
mainForm.showBack(); // main form to show back after calender disappears
}
});
calFrame.addComponent(cal);
calFrame.show();
}
});
mainForm.addComponent(calButton); // add calendar button to main form
this code will add one calendar button to your main form and will display the selected date in textfield (here named txtDate).
If you want to add date in combo values, you can add the selected date in the vector or list of the combo component's vector.
If this is not what you want, kindly briefly explain what you want actually to do.

Resources