var popup = AdfPage.PAGE.findComponent("popupId");
if (popup.isPopupVisible() == true){
popup.hide();
}
Wednesday, December 8, 2010
How to invoke a JavaScript method from the managed bean
Jspx part
---------------
<f:view>
<af:document id="d1">
<![CDATA[
<script>
function greeter() {
alert("Hello..");
}
}
</script> ]]>
<af:form id="f1">
<af:commandButton text="commandButton 1" id="cb2"
partialSubmit="true"
action="#{ScriptCallerBean.cb2_action}"/>
</af:form>
</af:document>
</f:view>
managed bean coding
------------------------
import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
public void caller(){
ExtendedRenderKitService extRenderKitSrvc = Service.getRenderKitService(FacesContext.getCurrentInstance(),ExtendedRenderKitService.class);
extRenderKitSrvc.addScript(FacesContext.getCurrentInstance(),"window.greeter()");
}
---------------
<f:view>
<af:document id="d1">
<![CDATA[
<script>
function greeter() {
alert("Hello..");
}
}
</script> ]]>
<af:form id="f1">
<af:commandButton text="commandButton 1" id="cb2"
partialSubmit="true"
action="#{ScriptCallerBean.cb2_action}"/>
</af:form>
</af:document>
</f:view>
managed bean coding
------------------------
import javax.faces.context.FacesContext;
import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;
public void caller(){
ExtendedRenderKitService extRenderKitSrvc = Service.getRenderKitService(FacesContext.getCurrentInstance(),ExtendedRenderKitService.class);
extRenderKitSrvc.addScript(FacesContext.getCurrentInstance(),"window.greeter()");
}
Friday, November 26, 2010
How to export commandLink in the table into excel
Hi Friends,
Some of you may have this problem,The problem is While you are exporting collumn in the commandLink,in the excel sheet the commandLink collumn field will be empty.The reason is the export is only for components of type ValueHolder, which a command ink is not.
So I solve this problem by using an output text inside the commandLink,and in the outputText field property I use the value property,but in the text property of the commandLink is empty.
sample coding,
<af:commandLink actionListener="#{bindings.setCurrentRowWithKey.execute}"
text="" id="cl4" action="edit">
<af:outputText value="#{row.DocumentName}" id="ot2"/>
</af:commandLink>
Hi this will work in all versions of the JDeveloper,This is one of solution,I dont know whether this is a correct solution or not.If any alternative solution,please post your comments
Some of you may have this problem,The problem is While you are exporting collumn in the commandLink,in the excel sheet the commandLink collumn field will be empty.The reason is the export is only for components of type ValueHolder, which a command ink is not.
So I solve this problem by using an output text inside the commandLink,and in the outputText field property I use the value property,but in the text property of the commandLink is empty.
sample coding,
<af:commandLink actionListener="#{bindings.setCurrentRowWithKey.execute}"
text="" id="cl4" action="edit">
<af:outputText value="#{row.DocumentName}" id="ot2"/>
</af:commandLink>
Hi this will work in all versions of the JDeveloper,This is one of solution,I dont know whether this is a correct solution or not.If any alternative solution,please post your comments
Clearing Filter criteria in ADF Rich Table
Hi Friends,this is one of my use-case for removing the filter text in the table when clicking a command button.
I think you all like this scenario.
Logic is,
ADF table filter uses SearchRegion binding, which genearly uses a All Queriable Attributes Criteria. It will apply the criteria on the View object. So we need to clear the criteria on the view object.
The Solution is,
1.Bind a table in the Jspx to a managed bean,say summaryTable.
2.In the Jspx page,use a commandButton and in its Action property call a method in the managed bean for eg: clearFilters()
3.Type the following code in the method,
public String clearFilters(){
if (summaryTable != null){
FilterableQueryDescriptor queryDescriptor =
(FilterableQueryDescriptor)summaryTable.getFilterModel();
if (queryDescriptor != null && queryDescriptor.getFilterCriteria() != null){
queryDescriptor.getFilterCriteria().clear();
summaryTable.queueEvent(new QueryEvent(summaryTable,queryDescriptor));
}
else{
String message = "Have some problem in Clearing Filters. please try later";
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message));
}
}
return null;
}
Now you run your application,type some filter text and click in the Button which will clear the filter text.
This example I tried in JDeveloper 11.1.1.2.0 . I hope it will work in all the versions of JDeveloper.If any problem post your comments or mail to felixandrew3@gmail.com
I think you all like this scenario.
Logic is,
ADF table filter uses SearchRegion binding, which genearly uses a All Queriable Attributes Criteria. It will apply the criteria on the View object. So we need to clear the criteria on the view object.
The Solution is,
1.Bind a table in the Jspx to a managed bean,say summaryTable.
2.In the Jspx page,use a commandButton and in its Action property call a method in the managed bean for eg: clearFilters()
3.Type the following code in the method,
public String clearFilters(){
if (summaryTable != null){
FilterableQueryDescriptor queryDescriptor =
(FilterableQueryDescriptor)summaryTable.getFilterModel();
if (queryDescriptor != null && queryDescriptor.getFilterCriteria() != null){
queryDescriptor.getFilterCriteria().clear();
summaryTable.queueEvent(new QueryEvent(summaryTable,queryDescriptor));
}
else{
String message = "Have some problem in Clearing Filters. please try later";
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message));
}
}
return null;
}
Now you run your application,type some filter text and click in the Button which will clear the filter text.
This example I tried in JDeveloper 11.1.1.2.0 . I hope it will work in all the versions of JDeveloper.If any problem post your comments or mail to felixandrew3@gmail.com
Thursday, November 25, 2010
How to invoke popup component programmatically in ADF
Hi All,
Here is a sample solution for invoking the popup component from a method in the managed bean.
Solution.
1.Create a button in the Jspx page.
2.Create a popup componet inside the af|form (for eg:popup id=p1) and bind the popup to a managed bean with name popup
3.In the Action property of button,invoke a method in the managed bean( for eg.the method caller() )
In the backing bean code,
public String caller(){
showPopup(popup, null);
return null;
}
public static void showPopup(RichPopup popup, UIComponent component) {
FacesContext context = FacesContext.getCurrentInstance();
String alignId = (component==null) ? null : component.getClientId(context);
StringBuilder script = new StringBuilder();
script.append("var popup = AdfPage.PAGE.findComponent('").append("p1").append("'); ")
.append("if (!popup.isPopupVisible()) { ")
.append("var hints = {}; ");
if (alignId!=null) {
script.append("hints[AdfRichPopup.HINT_ALIGN_ID] = '").append(alignId).append("'; ")
.append("hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_START; ");
}
script.append("popup.show(hints);}");
ExtendedRenderKitService erks =
Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
erks.addScript(context, script.toString());
}
Hi, Onething note this works in JDeveloper 11.1.1.2.0 But I dont know how about in other version.I hope it will work in all versions,
If it dosn't works post your comment or mail to : felixandrew3@gmail.com . I will send you the sample code.
Here is a sample solution for invoking the popup component from a method in the managed bean.
Solution.
1.Create a button in the Jspx page.
2.Create a popup componet inside the af|form (for eg:popup id=p1) and bind the popup to a managed bean with name popup
3.In the Action property of button,invoke a method in the managed bean( for eg.the method caller() )
In the backing bean code,
public String caller(){
showPopup(popup, null);
return null;
}
public static void showPopup(RichPopup popup, UIComponent component) {
FacesContext context = FacesContext.getCurrentInstance();
String alignId = (component==null) ? null : component.getClientId(context);
StringBuilder script = new StringBuilder();
script.append("var popup = AdfPage.PAGE.findComponent('").append("p1").append("'); ")
.append("if (!popup.isPopupVisible()) { ")
.append("var hints = {}; ");
if (alignId!=null) {
script.append("hints[AdfRichPopup.HINT_ALIGN_ID] = '").append(alignId).append("'; ")
.append("hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_START; ");
}
script.append("popup.show(hints);}");
ExtendedRenderKitService erks =
Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
erks.addScript(context, script.toString());
}
Hi, Onething note this works in JDeveloper 11.1.1.2.0 But I dont know how about in other version.I hope it will work in all versions,
If it dosn't works post your comment or mail to : felixandrew3@gmail.com . I will send you the sample code.
Thursday, October 21, 2010
How to hide the spin bar in the carousel componet
thanks to Frank,
Use Skining to hide this spin bar in the carousel component,
In the css file,
af|carousel::spin-bar{
visibility: hidden;
}
af|carousel::spin-h-previous-icon-style{
visibility: hidden;
}
af|carousel::spin-h-next-icon-style{
visibility: hidden;
}
af|carousel::spin-info{
visibility: hidden;
}
Use Skining to hide this spin bar in the carousel component,
In the css file,
af|carousel::spin-bar{
visibility: hidden;
}
af|carousel::spin-h-previous-icon-style{
visibility: hidden;
}
af|carousel::spin-h-next-icon-style{
visibility: hidden;
}
af|carousel::spin-info{
visibility: hidden;
}
How to use the Carousel component in 2 seconds
1.Craete a .jspx file
2.Create a View Object DataControl
3.Drag and Drop the view object from the DataControl to the jspx page
2.Create a View Object DataControl
3.Drag and Drop the view object from the DataControl to the jspx page
Now Choose carousel from the following,
4.Choose carouselItem in the structure panel,and in the property inspecter of the carouselItem,for text attribute type #{item.employeeName} // give any attribute of the view object in the place of employeeName
5.Now run the application
Wednesday, October 6, 2010
ADF 11g: contextInfo Implementation
All component that we can add the contextInfo component to (column, commandLink,inputComboboxListOfValues, inputText, outputFormatted, outputText, selectOneChoice), have a facet called context.
for example,let us use a ContextInfo component for a InputTextBox that displays some info about that.
Steps,
1.Drag and drop a InputText component from the component palete
2.Inside the InputTextBox right-click and choose Insert-Inside InputBox--->Jsf-Core--->Facet and choose context from the dropdown list
3.Inside the Facet right-click and choose Insert-Inside Facet--->ContextInfo
4.Inside the ContextInfo right-click and choose Insert-Inside-ContextInfo--->Adf Faces--->show Popup behaviour
5.Drag and drop a Popup component in the AF:document in the structure panel,
6.In the show popup behaviour give the popup id for the popup component.
for example,let us use a ContextInfo component for a InputTextBox that displays some info about that.
Steps,
1.Drag and drop a InputText component from the component palete
2.Inside the InputTextBox right-click and choose Insert-Inside InputBox--->Jsf-Core--->Facet and choose context from the dropdown list
3.Inside the Facet right-click and choose Insert-Inside Facet--->ContextInfo
4.Inside the ContextInfo right-click and choose Insert-Inside-ContextInfo--->Adf Faces--->show Popup behaviour
5.Drag and drop a Popup component in the AF:document in the structure panel,
6.In the show popup behaviour give the popup id for the popup component.
Tuesday, September 28, 2010
AutoSuggestBehaviour in ADF
1.Create a text Box
2.Inside the text box drag and drop a autoSuggestBehaviour component
3.In the SuggestedItems create a managed bean for countrySuggester.getCountries
4.Now your Jsf will look like this,
<af:inputText label="Country" value="#{item.country}"
columns="20" id="it5">
<af:autoSuggestBehavior suggestedItems="#{countrySuggester.getCountries}"/>
</af:inputText>
5.In the countrySuggester class make it as this,
import java.util.ArrayList;
import java.util.List;
import javax.faces.model.SelectItem;
public class CountrySuggester {
private List<SelectItem> countries = new ArrayList<SelectItem>();
public CountrySuggester() {
super();
countries.add(new SelectItem("Belgium"));
countries.add(new SelectItem("Hungary"));
countries.add(new SelectItem("Bulgaria"));
countries.add(new SelectItem("India"));
countries.add(new SelectItem("Indonesia"));
countries.add(new SelectItem("United Kingdom"));
countries.add(new SelectItem("United States of America"));
countries.add(new SelectItem("Netherlands"));
countries.add(new SelectItem("Nepal"));
countries.add(new SelectItem("Namibia"));
}
public List<SelectItem> getCountries(String country) {
List<SelectItem> items = new ArrayList<SelectItem>();
for(SelectItem item:countries){
if (item.getLabel().startsWith(country)) {
items.add(item);
}
}
return items;
}
}
2.Inside the text box drag and drop a autoSuggestBehaviour component
3.In the SuggestedItems create a managed bean for countrySuggester.getCountries
4.Now your Jsf will look like this,
<af:inputText label="Country" value="#{item.country}"
columns="20" id="it5">
<af:autoSuggestBehavior suggestedItems="#{countrySuggester.getCountries}"/>
</af:inputText>
5.In the countrySuggester class make it as this,
import java.util.ArrayList;
import java.util.List;
import javax.faces.model.SelectItem;
public class CountrySuggester {
private List<SelectItem> countries = new ArrayList<SelectItem>();
public CountrySuggester() {
super();
countries.add(new SelectItem("Belgium"));
countries.add(new SelectItem("Hungary"));
countries.add(new SelectItem("Bulgaria"));
countries.add(new SelectItem("India"));
countries.add(new SelectItem("Indonesia"));
countries.add(new SelectItem("United Kingdom"));
countries.add(new SelectItem("United States of America"));
countries.add(new SelectItem("Netherlands"));
countries.add(new SelectItem("Nepal"));
countries.add(new SelectItem("Namibia"));
}
public List<SelectItem> getCountries(String country) {
List<SelectItem> items = new ArrayList<SelectItem>();
for(SelectItem item:countries){
if (item.getLabel().startsWith(country)) {
items.add(item);
}
}
return items;
}
}
Guidelines for ADF Beginners
See the following links which demonstrates the Step by Step procedure for using ADF11g components
1.http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/ria_application/developriaapplication_long.htm
2.http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/boundedtaskflow/bounded_task_flow.html
3.http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/adf_richclient/adfrichclient.htm
1.http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/ria_application/developriaapplication_long.htm
2.http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/boundedtaskflow/bounded_task_flow.html
3.http://st-curriculum.oracle.com/obe/jdev/obe11jdev/ps1/adf_richclient/adfrichclient.htm
Example for ADF FacesMessage
1.Create a Button component
2.In the Button Action proerty bind it to the managed bean
3.In the method type the following code.
FacesContext fc = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage("Hi this is your message");
fc.addMessage(null, message);
2.In the Button Action proerty bind it to the managed bean
3.In the method type the following code.
FacesContext fc = FacesContext.getCurrentInstance();
FacesMessage message = new FacesMessage("Hi this is your message");
fc.addMessage(null, message);
Subscribe to:
Posts (Atom)