I need to automatically set the value of my inputCalendar element to the current date yet still allow the user to click on the popup calendar to change the value if they wish. The code I am using is found below.
<t:inputCalendar id="dashDelivStartDateCal" monthYearRowClass="yearMonthHeader" weekRowClass="weekHeader" popupButtonStyleClass="standard_bold" currentDayCellClass="currentDayCell" value="#{orderStatusBacking.dashDelivStartDate}" renderAsPopup="true" popupDateFormat="MM/dd/yyyy" helpText="MM/DD/YYYY">
<h:message for="dashDelivStartDateCal" showDetail="true"></h:message>
</t:inputCalendar>
Thanks in advance for the help.
Just initialize the value behind value="#{orderStatusBacking.dashDelivStartDate}" with current date instead of (default) null. You can do this in the constructor of the bean.
public class OrderStatusBacking {
private Date dashDelivStartDate;
public OrderStatusBacking() {
dashDelivStartDate = new Date();
}
// ...
}
Related
my cscockpit is displaying let says"125.00PHP" in price value.
Is there any config parameter or impex to change to "PHP125.00"?
You need to customize the widget corresponding to this layout.
For the same, you need to extend de.hybris.platform.cscockpit.widgets.renderers.impl.BasketTotalsWidgetRendererand override renderOrderDetail method of AbstractOrderTotalsWidgetRenderer
You need to change the below code block as per your requirement
NumberFormat currencyInstance = (NumberFormat) getSessionService()
.executeInLocalView(
new SessionExecutionBody(cartCurrencyModel) {
public Object execute() {
AbstractOrderTotalsWidgetRenderer.this
.getCommonI18NService()
.setCurrentCurrency(
this.val$cartCurrencyModel);
return AbstractOrderTotalsWidgetRenderer.this
.getFormatFactory()
.createCurrencyFormat();
}
});
Using a DynamicViewPanel and a customizer bean to change the column that is a link. The column that is the first column in the view is being hidden via the bean using the setRendered() method and another column is made the link using the setDisplayAs("link") method. That works fine but the oncolumnclick event never fires. It appears that the event is tied to the original column and not the "new" link column.
Anyway to tie an event to the "new" link column? I need to set a scoped variable before navigating to the new XPage.
Howard
Got this to work using something like Maire suggested.
In the method, public void afterCreateColumn(FacesContext context, int index,
ColumnDef colDef, IControl column) {, I added this code to get the event from the column I was hiding:
//Hide the first column in this view
if(dynamicColumn.getColumnName().equalsIgnoreCase("$2")){
//dynamicColumn.setRendered(false);
dynamicColumn.setDisplayAs("hidden");
String type = dynamicColumn.getChildren().get(0).getClass().toString();
DebugToolbarBean.get().info("type is " + type);
event = (XspEventHandler) dynamicColumn.getChildren().get(0);
}
I also created an event variable to hold this:
com.ibm.xsp.component.xp.XspEventHandler event;
Then, where I made the column I wanted to be a link I added:
if (dynamicColumn.getColumnName().equalsIgnoreCase("OrderDate")){
//make it a link
dynamicColumn.setDisplayAs("link");
DebugToolbarBean.get().info("make OrderDate a link");
if (event != null){
dynamicColumn.getChildren().add(event);
DebugToolbarBean.get().info("adding event");
} else {
DebugToolbarBean.get().info("event is null");
}
}
I haven't tried this, but you could try moving the location of the xp:eventHandler in the control tree.
As in, the initial dynamically generated control tree is like:
xp:viewColumn id="column1" displayAs="link"
xp:eventHandler event="onclick"
xp:viewColumn id="column2" displayAs="text"
And your code is changing it to switch the displayAs values:
xp:viewColumn id="column1" displayAs="text"
xp:eventHandler event="onclick"
xp:viewColumn id="column2" displayAs="link"
but the xp:eventHandler would still listen for clicks on its ancestor column1.
You could move the eventHandler in the customizerBean, like so:
public void afterCreateColumns(FacesContext context, UIDynamicViewPanel panel) {
UIViewColumn col1 = (UIViewColumn) panel.getChildren().get(0);
UIViewColumn col2 = (UIViewColumn) panel.getChildren().get(1);
UIEventHandler eventHandler = (UIEventHandler) col1.getChildren().get(0);
// move the eventHandler to col2.
col2.getChildren().add(eventHandler);
}
[The code in ExtLib that creates the control tree structure is:
com.ibm.xsp.extlib.component.dynamicview.DominoDynamicColumnBuilder.createColumn(...) ]
I am using an ajax box which will fetch the list of object based the string provided in the box as follows:
<p:inputText id="zid" placeholder="Search" value="#{resourceListView.wanted}">
<p:ajax event="keyup" update=":form:abc"
listener="#{resourceListView.SearchResources}" />
</p:inputText>
SearchResources will fetch the objects based on the value of input box as follows:
public void SearchResources(String wanted) {
this.resources=resourceServiceImpl.listResources(wanted);
}
I was running the query in the DAO which was meant to return the object based on the search. But it didn't return anything. So I sysout the query and the query comes out as follows:
SELECT * FROM test.resourcemaster where Resource_ZID like '%javax.faces.event.AjaxBehaviorEvent[source=org.primefaces.component.inputtext.InputText#79d635]%' OR Employee_ID like '%javax.faces.event.AjaxBehaviorEvent[source=org.primefaces.component.inputtext.InputText#79d635]%' OR First_Name like '%javax.faces.event.AjaxBehaviorEvent[source=org.primefaces.component.inputtext.InputText#79d635]%' OR Last_Name like '%javax.faces.event.AjaxBehaviorEvent[source=org.primefaces.component.inputtext.InputText#79d635]%'
the query was supposed to be searching on the 'wanted'
Could anyone explain what is the problem.
Your SearchResources() method accepts one parameter, which you don't supply from page. That's why AjaxBehaviorEvent is passed to it (event.toString(), to be more precise), which is the default if you don't specify parameters in method call.
Try changing the ajax listener to listener="#{resourceListView.SearchResources(resourceListView.wanted)}"
Or, simply remove the parameter from the method, and use bean wariable wanted
public void SearchResources() {
this.resources = resourceServiceImpl.listResources(this.getWanted());
}
I am working on CRM 2011.
On Form_onLoad event I am presetting the value of a field.
mdg.PreSetField("address1_line1","Amsterdam");
but after clicking on save button my field address1_line1 is blank.
To check I put a alert on Form_onsave function.
alert("address =" + (Xrm.Page.getAttribute("address1_line1").getValue()));
In alert,I get the value of address1_line1 field but finally address1_line1 is blank.
mdg.PresetField function is as follows
mdg.PreSetField = function(attributeName, value) {
var attribute;
if (attributeName.setSubmitMode) {
attribute = attributeName;
}
else {
attribute = Xrm.Page.getAttribute(attributeName);
}
attribute.setSubmitMode('never');
attribute.setValue(value);
attribute.addOnChange(function() {
attribute.setSubmitMode('always');
});
};
I solved it..
in my custom mdg.PresetField function earlier code was
attribute.setSubmitMode('never');
I changed never to always and now it is working..
mdg.PreSetField("address1_line1","Amsterdam");
This code is not part of the CRM JavaScript API so I assume it's a custom library? Have you added this script to the list of webresources available on the form? Also make sure it comes before the script you are trying to use it in.
I'm using Grails scaffolding and would like to make a change in the default date during a create. Currently dates default to today's date. How would one default it to blank or no date?
Thanks,
Steve
You can do grails install-templates and customize template, used for rendering.
In $PROJECT/src/templates/scaffolding/renderEditor.template there is method renderDateEditor which should be customized to your needs.
This customization will be applied to all new scaffolding operations.
Whatever the default value in your domain object is will show up in the form on create.
class Test {
Date aDate
}
In that example the domain object has a non-nullable date, so the default value is a newly constructed date. If the domain object gets changed to:
class Test {
Date aDate
static constraints = {
aDate(nullable:true)
}
}
Then the default value for the date will be null and that's what will show up in the scaffolded create form.
If you want to set the default value explictly, just assign it with a domain object initializer:
class Test {
Date aDate = Date.parse("yyyy-MM-dd", "2010-01-01")
static constraints = {
aDate(nullable:true)
}
}