Monday, June 11, 2012

Could not create the Java virtual machine in weblogic

Could not create the Java virtual machine in weblogic :


After installing SOA server 11.1.1.6  as managed server when i started admin server it was giving  following error

"Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. in weblogic"

It came because server did not able to reserve space in JVM for server.


Solution :
1-Go to  directory where you have installed domain.In my case domain name is soa_domain
  E:\Oracle\MiddlewareWeblogicServer\user_projects\domains\soa_domain\bin

2-Then open  setSOADomainEnv.cmd if operation system is window or  setSOADomainEnv.sh if you are using UNIX.

By default  it has following setting

set JAVA_OPTIONS=%JAVA_OPTIONS%
set DEFAULT_MEM_ARGS=-Xms512m -Xmx1024m
set PORT_MEM_ARGS=-Xms768m -Xmx1536m


3-Here PORT_MEM_ARGS has assigned wrong amount of memory.Replace with following code

set PORT_MEM_ARGS=-Xms512m -Xmx1024m

4-Start the server again .

Hope it will start successfully.


Thanks
Prateek

Saturday, June 9, 2012

Navigation in Unbounded and Bounded Task Flow

Navigation/Control Flow Rule in Unbounded and Bounded Task Flow:

Preamble : In this post i would like to explain how to use navigation rule in faces-config.xml and control flow rule in  adfc-config.xml.
Navigation Rule /Control Flow Rule is use to transfer control from one view activity to another activity. Following type of view activity combination are possible

1-jspx to jspx
2-jspx to bounded task flow(which has jspx)
3-jspx to bounded task flow (which has jsff)
4-jsff to jsff
5-bounded task flow to bounded task flow

Explanation
:In any Fusion Middleware  there should be one or many bounded and one or many unbounded task flow.
When you create any fusion middleware application by default there two unbounded task flow will created in project.

1-faces-config.xml
2-adfc-config.xml

Following point will explain the clear way to use navigation and control rule in task flow.

1-Navigation Rule in faces-cong.xml:

Let us start with faces-config.xml.The following table will explain what we can use or not in the faces-config.xml as view activity.

S.No. jspx  page Bounded task flow   jsff  page (As a separate unit )  jsff  page (Inside in Bounded task flow)
1- Yes NO NO NO

Here jsff /bounded task flow page  are belong to adf perhaps we can not use this in faces-config.xml .Although  you can drag and drop jsff pages but if you run the page it will give the following error.

And we can not drag and drop bounded task flow on faces-config.xml.

2-Control Flow Rule  in adf-config.xml: 

The following table explain the possibility of view activities.

S.No. jspx  page Bounded task flow  jsff  page (As a separate unit ) jsff page (Inside in Bounded task flow)
1- Yes Yes NO Yes

One things is conman in both that is we can not use individual jsff page.

In Java server faces we have navigation rule.but in adf we have  control flow which is same as navigation rule with more and more feature.
Example :Navigation rule in possible jspx to jspx but control rule is possible in jspx ,method and task flow to task flow .

1-Control Flow Rule in jspx to jspx  page :We can use navigation rule between jspx to jspx,


2-Control flow rule in jspx to bounded task :We have option to navigation  from jspx to bounded task flow.Moreover  bounded task flow further divided into following two part.Bounded task flow contains  either jspx or jsff at a time.But both are not allow same time.
1-Boudned task flow with jspx
2-Bounded task flow with jsff

i)Boudned task flow with jspx :you can use this  bounded with in faces-config.xml.It is work as usual.They is no magic behind this scenario.


ii)Bounded task flow with jsff:In any FMW application  frequently we will have this type of bounded task flow however one more importance thing which we need to remember that we can not direct used this type of bounded task flow  in adfc-config.xml .
If you will used then if will show you following error message on bounded task flow 


"An unbounded task flow refers to pages ,and therefore can not call bounded task flow "task-flow-definition" that refers to page
fragments "


For using this type of bounded task flow we require Region.So  Drag and drop this task flow as Region into jspx page and then can use this jspx in adfc-config.xml .

Till here i explained possible way to use control flow rule. But one vital part is still left that is control flow rule in bounded task flow to bounded task flow.

Again I am saying that in unbounded task we can use bounded task either the bounded task has jspx page inside or it is inside a jspx page as a region.

 Bounded task has one property called task flow return which automatic return control back to callee  task flow.But if you want to navigate from bounded task flow to any jspx page or other bounded task flow then in this case the task flow return activity name should be same as control flow rule between them.

Above task flow have one jspx page,two bounded task flow.The following point will depict task flow

i-The jspx page has one button which has GO as action.Click on button it will navigate to task-flow-defination1 (bounded task flow )and that has follow elements


ii-The page contains one Default activity which is a jspx  page and one task flow return.Here task flow return name is GO1 which is same as action value of command button which is inside in second page(jspx).Here if user click on command button of the second page it will go to task flow return and return to callee task flow where it will check ,is there any control flow with GO1 name if it is present then it will navigate to that page.Here it is present then it will navigate to task-flow-defination which is bounded task flow.

3-Control Flow Rule in Bounded Task Flow (task-flow-defination ):


S.No. jspx  page Bounded task flow   jsff  page (As a separate unit )  jsff  page (Inside in Bounded task flow)
1- Yes Yes Yes Yes

*Bounded task flow  also called as task-flow-defination.

*At a single time either jspx or jsff will present.
*Bounded task flow to Bounded task flow navigation is possible.
*Using task flow return  we can navigate from BTF to BTF
*Other things same as adfc-config.xml


Thanks
Prateek




Sunday, June 3, 2012

Multiple Faces-Config.xml file

Multiple faces-config.xml  file in Single Application:

It is possible to have more than one faces-config.xml in any java EE  web application or fusion web application .

By default newly created  Fusion web application has following configuration file -

1-one web.xml  file (Deployment descriptor)
    Part of any j2ee application.
2-one faces-config.xml (does not have any entry in web.xml file)
    Part of the jsf application
3-one adf-config.xml (does not have any entry either in web.xml or faces-config.xml file)
   Part of the adf application

In Any web based application there will only one web.xml file but may have more than one faces-config.xml and adf-config.xml file.

We observed following point when we  have created second faces-config.xml file in our application.

1-When we created one more faces-config.xml file in application then in this case newly created file entry will added into web.xml which have following code :


<context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config1.xml</param-value>
  </context-param>

If you crated on more faces-config.xml  then code will look like following code

<context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/faces-config1.xml,/WEB-INF/faces-config2.xml</param-value>
  </context-param>


It will add newly created faces-config,xml file entry comm separated in <param-value> tag.

*Previously when we have single faces-config.xml file there we did not have  entry in the web.xml .

2-If your web based application size is huge or it became very tough to maintains application  navigation rule(because of the confusion )  then in this case it is recommended to split your  faces-config.xml file  in two or more faces-config.xml.Even it also use full if your team size is big.One team  can has one individual faces-config.xml file(what they want they can do freely.but one thing they should have keep in mind before going to create the jsf navigation rule that is uniqueness of rule).

3-
Suppose if  we  have two faces-config.xml .One faces-config.xml contians two pages (page A and page B) with GO jsf Navigation rule.And in second faces-config.xml also contains two page (page A and page C)  with GO(which is same as in first config file) jsf Navigation rule.If you run the page A which has one command button which has GO as Action then in this case it will navigate to page B.


even  second faces-config has same jsf navigation rule but it will navigate to B.
Because it has given  priority to first faces-config.xml file not second faces-config.xml file .

4-Navigation rule searching approach :If the first faces-config.xml does not match the jsf navigation rule then in this case it will search in second faces-config.xml and  so on ... and if it's find navigate rule in the first faces-config (like third point )it will not going to search next faces-config.xml file.

For checking above behavior  i changed the jsf navigation rule GO to GO1 in  first faces-config.xml and  By the way page A command button still has same action (Go).


 So in this case  if you run the first page and click on command button it will first search in faces-config no navigation rule matched then it will search in the second faces-config.xml.In our case it will find the navigation rule in second faces-config.xml  so  it is navigate to Page C.

I will keep add new point if i will find any    :)

Thanks
Prateek


Friday, June 1, 2012

Disabling / Enabling all components of Panel Form Layout at single click

I have one business requirement where i need to make all the UI component of the form disable single click on the button.

Moreover panelFormLayout does not have any property call disable or readonly.

Although i know we can do this using bind each component on the backing and setting the readonly /disable  property true or  putting some condition  on readonly /disable ,but this is any how very tedious  because manually we need to put condition on each individual component .

But making this scenario automatic i have done following step ..

1-First i bound  the panelForm  element  to backing bean.
2-And getting all the child compoenet through following statement
List<UIComponent> uiComponentList = formClass.getChildren();
This will give us all the child element
3-Then i  loop  through all element and  checked  what is instance of component and after getting instance of the component i am setting disable property true.

Code for making disable are following
        List<UIComponent> uiComponentList = formClass.getChildren();
        for (UIComponent uiComponent : uiComponentList) {
            if (uiComponent instanceof RichInputText) {
                ((RichInputText)uiComponent).setDisabled(true);
            } else if (uiComponent instanceof RichSelectBooleanCheckbox) {
                ((RichSelectBooleanCheckbox)uiComponent).setDisabled(true);
            } else if (uiComponent instanceof RichSelectBooleanRadio) {
                ((RichSelectBooleanRadio)uiComponent).setDisabled(true);
            } else if (uiComponent instanceof RichSelectManyChoice) {
                ((RichSelectManyChoice)uiComponent).setDisabled(true);
            }

        }

Code for making enable are following

              List<UIComponent> uiComponentList = formClass.getChildren();
        for (UIComponent uiComponent : uiComponentList) {
            if (uiComponent instanceof RichInputText) {
                ((RichInputText)uiComponent).setDisabled(false);
            } else if (uiComponent instanceof RichSelectBooleanCheckbox) {
                ((RichSelectBooleanCheckbox)uiComponent).setDisabled(false);
            } else if (uiComponent instanceof RichSelectBooleanRadio) {
                ((RichSelectBooleanRadio)uiComponent).setDisabled(false);
            } else if (uiComponent instanceof RichSelectManyChoice) {
                ((RichSelectManyChoice)uiComponent).setDisabled(false);
            }

        }


*In this code you can add your codes as your requirement.


Jsf page code is following:
 
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1">
      <af:form id="f1">
        <af:panelFormLayout id="pfl1" inlineStyle="height:52px;">
          <af:commandButton text="Disable" id="cb1"
                            actionListener="#{backingBeanScope.classOne.commandButton}"/>
          <af:commandButton text="Enable" id="cb2"
                            actionListener="#{backingBeanScope.classOne.commandButtonEnable}"/>
        </af:panelFormLayout>
        <af:panelFormLayout id="pfl2"
                            binding="#{backingBeanScope.classOne.formClass}">
          <af:inputText label="Label 1" id="it1"/>
          <af:inputText label="Label 2" id="it2"
                       />
          <af:inputText label="Label 3" id="it3"/>
          <af:inputText label="Label 4" id="it4"/>
          <af:selectBooleanCheckbox text="selectBooleanCheckbox 1"
                                    label="Label 1" id="sbc1"/>
          <af:selectBooleanRadio text="selectBooleanRadio 1" label="Label 1"
                                 id="sbr1"/>
          <af:selectManyChoice label="Select" id="smc1">
            <af:selectItem label="A" value="A" id="si1"/>
            <af:selectItem label="B" value="B" id="si2"/>
          </af:selectManyChoice>
        </af:panelFormLayout>
      </af:form>
    </af:document>
  </f:view>
</jsp:root>

Thanks
Prateek