I have a calendar which is working fine. it displays records on click and changes the colour to green or red. if records are available date will become red colored.
I don't want onclick I want calendar to displays date colours on
calendars onload event.** KIndly help. following is my code . I think problem with css, I guess
.postive-records .rf-cal-sel {
background-color: green;
}
.no-records .rf-cal-sel {
background-color: red;
}
<rich:calendar styleClass="#{eventMaster.eventMasterList!=null and eventMaster.eventMasterList.size()>0?'postive-records':'no-records'}" locale="EN"
id="searchDateCalendarcommon" popup="false"
showApplyButton="false" datePattern="dd/MM/yyyy"
value="#{eventMaster.eventSearchDate}" >
<rich:tooltip followMouse="false"
showDelay="100"
direction="topRight"
layout="block"
onmouseover="">
<h:outputText value="#{eventMaster.calendarTooltipText}"
style="color: red;font-size: 12px;"/>
</rich:tooltip>
<f:ajax event="change" listener="#{commonOutputContentBean.showEvents()}"
render="cmnoplayoutfrm searchDateCalendarcommon" />
</rich:calendar>
The calendar simply displays days in a month, it isn't linked to any data. Furthermore styleClass is applied to the entire calendar not to the cells. You need to provide a dataModel.
The datamodel has to implement org.richfaces.model.CalendarDataModel, and you also need to implement org.richfaces.model.CalendarDataModelItem for the days which is a plain object with getters and setters. The CalendarModel would be something like this:
public class MyCalendarModel implements CalendarDataModel {
private boolean hasEvents(Calendar calendar) {
// …
}
#Override
public CalendarDataModelItem[] getData(Date[] dateArray) {
CalendarDataModelItem[] modelItems = new MyCalendarModelItem[dateArray.length];
Calendar current = GregorianCalendar.getInstance();
Calendar today = GregorianCalendar.getInstance();
today.setTime(new Date());
CalendarModelItem modelItem;
for (int i = 0; i < dateArray.length; i++) {
current.setTime(dateArray[i]);
modelItem = new MyCalendarModelItem();
if (hasEvents(current)) {
modelItem.setStyleClass("postive-records");
} else {
modelItem.setStyleClass("no-records");
}
modelItems[i] = modelItem;
}
return modelItems;
}
#Override
public Object getToolTip(Date date) {
return null;
}
}
You can check the example in the showcase.
Related
I am trying to bind an ObservableCollection, which is filled in a Background thread, to a charting Control in the UI.
Therefore i have a static class "Core", which have a member "DataState". This DataState class owns the ObservableCollection "SensorData", which is filled in the aforementioned Background Task.
As there is no possibility to do UWP XAML Binding for static properties i wrote a wrapper class "DataWrapper" which is nonstatic and refers to the static Core.DataState.SensorData-object.
Here's some of my Code:
Core.cs:
public static partial class Core
{
private static DataState m_DataState;
public static DataState DataState
{
get
{
return m_DataState;
}
set
{
if (value != null)
{
m_DataState = value;
}
}
}
}
DataState.cs:
public class DataState
{
private ObservableCollection<SensorData> m_SensorData = new ObservableCollection<SensorData>();
public ObservableCollection<SensorData> SensorData
{
get
{
return m_SensorData;
}
set
{
if (value != null)
m_SensorData = value;
}
}
DataWrapper.cs:
public class DataWrapper
{
public ObservableCollection<SensorData> SensorData
{
get
{
return Core.DataState.SensorData;
}
}
}
XAML:
<Charting:LineSeries Name="MySeries" Title="Title" IndependentValuePath="X" DependentValuePath="Y" ItemsSource="{x:Bind DataWrapper.SensorData}"></Charting:LineSeries>
where X and Y are the variables contained in the SensorData-Object.
So, if i wait to Show the Charting-Control until there's some data in the ObservableCollection this data is nicely plotted into my Control. But after that recently added data is not plotted anymore.
Therefore i am looking for a way to route the PropertyChanged-Event from Core.DataState.SensorData somehow to DataWrapper.SensorData. Is there any possibility to do this?
Is the structure of this Problem clear to you? I think my descriptions sounds a bit confusing...
Thank you in advance for any help :-)
I try to update an input value in Angular 2, it works the first time the size value exceeds maxSize, but afterwords it does not work anymore. It seems like when I am setting this.size to some value the UI is not updated, am I overlooking something ?
HTML:
<input type="text" class="form-control" [value]="size" (input)="size = updateValue($event)">
Code:
export class BrushSizePicker {
#Input() minValue;
#Input() maxValue;
#Input() size;
increaseValue(event) {
this.size++;
this.checkValue();
}
decreaseValue(event) {
this.size--;
this.checkValue();
}
updateValue(event) {
this.size = parseInt(event.target.value);
this.checkValue();
return this.size;
}
private checkValue() {
if (this.size > this.maxValue) {
this.size = this.maxValue;
}
if (this.size < this.minValue) {
this.size = this.minValue;
}
}
EDIT:
I logged what happened: checkValue is called every time with the correct input, and it returns the correct value. But the new value is not set into the input field / value field
While it may not solve the problem, the way you have implemented the input event can be simplified. I would have written it like this, side-effect free functions:
updateValue(event) { // The method name with this change is a misnomer
return this.checkValue(parseInt(event.target.value));
}
private checkValue(item) {
if (item > this.maxValue) {
return this.maxValue;
}
else if (else < this.minValue) {
return this.maxValue;
}
return item;
}
I use primefaces 4.0 and i try to change the color of the event in Primefaces Lazy Schedule, so i have the following xhtml code
<style type="text/css">
.Ajout .fc-event-skin {
background: #00FF00;
}
.Livraison .fc-event-skin {
background:#DF013A;
</style>
<p:schedule value="#{scheduleController.lazyEventModel}" locale="fr" showWeekends="true" eventSelectListener="#{scheduleController.onEventSelect}" >
<p:ajax event="eventSelect" listener="#{scheduleController.onEventSelect}" update="eventDetails" oncomplete="PF('eventDialog').show()" />
</p:schedule>
<p:dialog widgetVar="eventDialog" header="Event Details" showEffect="clip" hideEffect="clip">
<h:panelGrid id="eventDetails" columns="2">
</h:panelGrid>
</p:dialog>
And this is the backing bean
public class ScheduleController implements Serializable {
private ScheduleModel lazyEventModel;
#Inject CalculDAO calculdao;
#Inject RibhDAO ribhdao;
public ScheduleController() {
lazyEventModel = new LazyScheduleModel() {
#Override
public void loadEvents(Date start, Date end) {
clear();
for(Calcul str: calculdao.DisplayCalculs())
{
Calendar cal = Calendar.getInstance();
Date random1 = getRandomDate1(str.getDate());
Date random2 = getRandomDate2(str.getDate());
addEvent(new DefaultScheduleEvent(""+str.getAjouteroulivr(),random1, random2,str.getAjouteroulivr()));
}
for(Ribh str: ribhdao.DisplayRibh())
{
Date random1 = getRandomDate1(str.getDate());
Date random2 = getRandomDate2(str.getDate());
addEvent(new DefaultScheduleEvent("Bénéfices Net du jour = "+str.getNet()+"dinars",random1, random2));
}
}
};
}
public Date getRandomDate1(Date base) {
Calendar date = Calendar.getInstance();
date.setTime(base);
return date.getTime();
}
public Date getRandomDate2(Date base) {
Calendar date = Calendar.getInstance();
date.setTime(base);
date.add(Calendar.MINUTE, 10);
return date.getTime();
}
/////
public void onEventSelect(SelectEvent selectEvent)
{ ScheduleEvent event = (ScheduleEvent) selectEvent.getObject();
//event. = (ScheduleEvent) ((SelectEvent) lazyEventModel).getObject();
}
////
public ScheduleModel getLazyEventModel()
{
return lazyEventModel;
}
}
The problem is that this code use to work fine with primefaces 3.3 JARS but when i switched to Primefaces 4.0, colors of events are no more displayed and events became kind of transparent ! what could be the problem with this code ??
PS: str.getAjouteroulivr() is a String that contains the Styleclass of the event it contains "Ajout" or "Livraison"
I had the same problem and solved it by using the following css:
.myclass .fc-event,
.myclass a,
.myclass .fc-event-inner{
background-color: red;
border-color: red;
color: white;
}
and then apply the styleClass in code:
event.setStyleClass("myclass");
Found out solution for Schedule event Apply this code:
Apply this style in front end
.event1 .fc-event-inner {
background: Red;
border-color: Yellow;
}
set this style class in schedule event
event.setStyleClass("event1");
Add this in your main.css
.event1{
background: Red !important;
border-color: Yellow !important;
}
Add <h:outputStyleSheet name="main.css" link="css"/> in the h:body of your xhtml.
Then in your controller class:
event.setStyleSheet("event1");
This code in working fine in my project.
Try out.......
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Text on an Image button in c# asp.net 3.5
I want a asp.net button with text on left and image on right
Here's one I wrote:
public class WebImageButton : LinkButton, IButtonControl
{
protected override void OnPreRender(EventArgs e)
{
if (!this.DesignMode)
{
// Apply the image
if (this.Image.Length > 0)
{
this.Style.Add("background-image", "url(" + this.Image + ")");
this.Style.Add("background-repeat", "no-repeat");
this.Style.Add("background-position", this.ImageHorizontalOffset + " " + this.ImageVerticalOffset);
}
}
base.OnPreRender(e);
}
[DescriptionAttribute("The path to the default image to be displayed.")]
public string Image
{
get
{
if (_image == null)
{
return string.Empty;
}
return _image;
}
set
{
_image = value;
}
}
private string _image;
[DescriptionAttribute("The unit to offset the image by horizontally.")]
public string ImageHorizontalOffset
{
get
{
return _imageHorizontalOffset;
}
set
{
_imageHorizontalOffset = value;
}
}
private string _imageHorizontalOffset = "0px";
[DescriptionAttribute("The unit to offset the image by vertically.")]
public string ImageVerticalOffset
{
get
{
return _imageVerticalOffset;
}
set
{
_imageVerticalOffset = value;
}
}
private string _imageVerticalOffset = "center";
}
Then the CSS that accompanies it:
.ImageButton
{
background:#666;
border:solid 1px #000;
color:#FFF;
font-size:10pt;
font-weight:bold;
padding:4px;
text-align:center;
cursor:hand;
}
And an example of its use:
<ctrl:WebImageButton ID="WebImageButton1" runat="server"
OnClick="WebImageButton1_Click" CssClass="ImageButton" Text="Click me"
ImageHorizontalOffset="4px" />
You could use CSS to apply the image to the background of the input element. Have a read up in the background-image CSS method:
http://www.w3schools.com/css/pr_background-image.asp
I'm not sure if there are any asp controls that allow you to do this (but I could be wrong). What you will want to fool around with is possibly divs and their onclick events. Then you can do something like onclick="Javascript:this.form.submit();". You will be able to size the div how you please and insert what you want (in your case text and an image).
Edit: Then in the css you could also add #mydiv:hover { cursor: pointer; } To get the hand icon when users move their cursor over the div.
But it looks like gage provided a link to someones solution :P Good luck
Can I somehow find out what was the change in the textfield? I would want to compare the old text with the new text ... the problem is, that I have multiple textAreas in a tab-editor, and all the textAreas are watched by one eventListener. I want to get a value calculated by the next formula:
globalChangeCount += thisTextArea.currentCharacterCount - thisTextArea.oldtCharacterCount
where the globalChangeCount is a value modified by all changes in any of the textAreas.
I am searching for these values through the event variable, but can't seam to find the old text of the textArea.
This may or may not be what you're looking to do:
package
{
import mx.controls.TextArea;
public class CountingTextArea extends TextArea
{
public var staleText : String = "";
[Bindable("textChanged")]
[NonCommittingChangeEvent("change")]
public function get charDiff() : int
{
var diff : int = staleText.length - text.length;
staleText = text;
return diff;
}
public function CountingTextArea()
{
super();
}
}
}
I made it so that you can use it as a source for binding. Instead of subscribing to the event on each TextArea, you can use:
function addWatchers():void
{
ChangeWatcher.watch(countingTextArea1, ["charDiff"], charDiffChangeHandler );
...
ChangeWatcher.watch(countingTextArea5, ["charDiff"], charDiffChangeHandler );
}
With the event handler somewhere too:
function charDiffChangeHandler( event : PropertyChangeEvent ) : void
{
trace(event.currentTarget.charDiff);
// or
trace(event.newValue);
}
You can use event.currentTarget to get a reference to the TextArea that fired the event, and use the focusIn event to execute a function to populate a variable with the old text value.
Maybe you should just subclass the TextArea and create an oldText field variable you update internally after all the external listeners have been notified.