Thursday, May 24, 2012

ADF Table dependant list select one choice : Thing I learned being stupid final

It ended up the source of all my problems was an invalid long to string conversion while rendering my select items.

So if you are having endless hassles with a dependent select box in a table try this when you are rendering the lists to make sure you are not rendering a string and matching on long or int:
    public List convertItem(List dataItems) {
        ArrayList covertedList = new ArrayList();
        if (dataItems != null) {
            for (Site dataItem : dataItems) {
                SelectItem item = new SelectItem(new String(dataItem.getId()), dataItem.getDescription());
                covertedList.add(item);
            }

        }
        return covertedList;
    }

ADF forEach : Things I learned being stupid 3

The el lookup of #{row} will not work in a for each period - dont torture yourself.

Wednesday, May 23, 2012

ADF Dependant select items in a table: Things I learned being stupid


Hard hard thing to do - table of dependant select items that you can add new rows to. (backing bean driven)
(When you add a new row it keeps values from the previous row)

In my search for the answer I made an forEach act like a table - by using the f:attribute to pass through the current row - crazy but I hopw this helps someone sometime.

Stuff I learned
            <af:selectOneChoice label="#{labelBundle['choice_lbl']}"
                                id="soc1" value="#{row.choiceId}"
                                valueChangeListener="#{pageFlowScope.testBean.choiceValueChange}"
                                required="true"
                                autoSubmit="true" unselectedLabel="Choose...">
              <f:attribute name="currentRow" value="#{row}"/>
              <f:selectItems id="isItem" value="#{row.choiceList}"/>
            </af:selectOneChoice>

Notice the f:attribute - this can pass any value to the backing bean in this case the row. - very bad for performance though.

Refresh on the component you need on value change:
in your value change listener : refreshDependantComponent("soc 2", valueChangeEvent.getComponent());



    private void refreshDependantComponent(String idMatch, UIComponent uiComponent) {
        UIComponent parent = uiComponent.getParent();
        Iterator iter = parent.getFacetsAndChildren();
        while (iter.hasNext()) {
            UIComponent iterItem = iter.next();
            if (iterItem.getId() != null && iterItem.getId().startsWith(idMatch)) {
                AdfFacesContext.getCurrentInstance().addPartialTarget(iterItem);
            }
        }
    }


Real solutions: : http://itnewscast.com/applications/how-populate-different-select-list-content-table-row
Or dont use immediate="true"

Thanks Jeromy for sending this to me and thanks Frank for the post.

ADF Defaulting a backing bean driven select: Thing I learned being stupid 1

Jdeveloper 11.1.1.5

Ok,

I had a selectonechoice that was driven by a pojo data control and I just couldn't get its value defaulted.
The following is what I learned along the way and my unique solution:

Drag and drop the item onto the page as a single choice selectonechoice:
Add a variable to your page binding (open your page and click on the bindings tab - right click on variables under Executables - insert inside variables - select variable - Name:selectedItemValue Type: java.lang.Object

Then click on Page definition file and update the variable you just added and add these attributes DefaultValue="#{pageFlowScope.TestBean.id}" IsUpdateable="2".
NOTE: the bold bit pageFlowScope.TestBean.id must be the value you want to default to.

Or you can just paste the xml like such:



<variable Type="java.lang.Integer" Name="selectedItemValue" DefaultValue="#{pageFlowScope.TestBean.id}" IsUpdateable="2" />


Then update your list binding to something like this (you can get this done using the green plus button but I am too lazy to post how if you need to know ask):


    <list StaticList="false" IterBinding="variables"
          ListIter="listItemsIterator" NullValueFlag="start" id="selectedItemValueList">
      <AttrNames>
        <Item Value="selectedItemValue"/>
      </AttrNames>
      <ListAttrNames>
        <Item Value="id"/>
      </ListAttrNames>
      <ListDisplayAttrNames>
        <<tem Value="name"/>
      </ListDisplayAttrNames>
    </list>

NullValueFlag="start" - gives you an empty item

This be my select one choice.
          <af:selectOneChoice value="#{bindings.selectedItemValueList.inputValue}"
                              label="#{bindings.selectedItemValueList.label}"
                              id="soc1"
                              valuePassThru="true" autoSubmit="true"
                              clientComponent="true">
            <f:selectItems value="#{bindings.selectedItemValueList.items}" id="siI"/>
          </af:selectOneChoice>



Handy helpful EL:

1) #{bindings.selectedItemValueList.attribute} - this will give you the actual id of the select box selected item
2) #{bindings.selectedItemValueList.inputValue} = this will give you the index 0 based of the selected item
3) #{bindings.selectedItemValueList.selectedValue == null ? null : bindings.selectedItemValueList.selectedValue.dataProvider} - this gives you the actual underlying object used so you can get the label from here.

Save Button
The save button I use because I need the object not just the object id



            <af:setPropertyListener from="#{bindings.selectedItemValueList.selectedValue == null ? null : bindings. selectedItemValueList .selectedValue.dataProvider}"
                                    to="#{pageFlowScope.listBean.currentValue.selectedItem}"
                                    type="action"/>
          </af:commandButton>




Random code

        Object expr = JsfUtil.resolveELExpression("#{bindings.selectedItemValueList}");
        if (expr instanceof FacesCtrlListBinding) {
            FacesCtrlListBinding list = (FacesCtrlListBinding)expr;
            UIComponent component = valueChangeEvent.getComponent();
            component.processUpdates(FacesContext.getCurrentInstance()); //do model updates for this comp
            DCDataRow row = (DCDataRow)list.getSelectedValue();
            ListItem i = (ListItem)().getDataProvider(); // get actual object via code
        }


Note
Create a list and change the binding xml for your list (ListOperMode attribute) from navigation to  setAttribute and see hoe things change

Tuesday, May 8, 2012

SoapUI start mocks on project load

I wanted to find where you can set all your mocks to load on start up of your project:

1) Double click on your project
2) Click on the Load Script tab
3) Place the below script in the Script section.

Press the play button to test





 The Script
for( ms in project.mockServiceList )
{
    // open window
    def dp = com.eviware.soapui.support.UISupport.showDesktopPanel( ms )

    // start mockservice
    ms.start()

    // minimize window
    com.eviware.soapui.SoapUI.desktop.minimize( dp )
}


Information found at soap ui forum:
http://www.soapui.org/forum/viewtopic.php?f=5&t=1138

ANT Jdeveloper what it really calls

I was wondering what Jdeveloper did in the background while running ant because I wanted to replicate exactly what was happening in JDev.

So I set the ant run task to debug and passed in an invalid argument ant the following was the output:

java -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl -Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl -classpath %ORACLE_HOME%\jdeveloper\jdev\lib\ojc.jar;%ORACLE_HOME%\jdeveloper\jdev\lib\ant-rt.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-antlr.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-apache-bcel.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-apache-bsf.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-apache-log4j.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-apache-oro.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-apache-regexp.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-apache-resolver.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-commons-logging.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-commons-net.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-jai.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-javamail.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-jdepend.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-jmf.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-jsch.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-junit.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-launcher.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-netrexx.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-nodeps.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-starteam.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-stylebook.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-swing.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-testutil.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-trax.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant-weblogic.jar;%ORACLE_HOME%\jdeveloper\ant\lib\ant.jar;%ORACLE_HOME%\jdeveloper\ant\lib\junit.jar;%ORACLE_HOME%\jdeveloper\ant\lib\xercesImpl.jar;%ORACLE_HOME%\jdeveloper\ant\lib\xml-apis.jar;%ORACLE_HOME%\jdk160_24\lib\tools.jar -Djdev.ant.port=54325 -Dant.home=%ORACLE_HOME%\jdeveloper\ant -XX:MaxPermSize=512M org.apache.tools.ant.Main -inputhandler oracle.jdevimpl.ant.runner.OutOfProcessInputHandler -f c:\test\theBuild.xml -Doracle.home=%ORACLE_HOME%\jdeveloper\ -Doracle_wl_home=%ORACLE_HOME%\wlserver_10.3 buildAll

Thursday, May 3, 2012

Using Soap UI to test services

I needed to test a screen that was backed by services and it was suggested that I use soapUI.
I haven't used soapUI for a while now and was surprised to see mock service functionality.

Mock Service (http://www.soapui.org/Service-Mocking/concept.html)


So first take the wsdl you have and generate a mock service using soap ui.
Create a new project: File Menu > Create new soapUI project.
Select the wsdl you will be working with.



Right click on the new Binding and select Generate MockService
Press ok twice.



Right click on the new Mock and select Start minimized.

Ok I like using the Query Match functionality it just works for my brain:
You can create as many mock responses as you like and edit the xml response as you wish.

You the add Query matches for each of your responses based on data passed in.
The xpath bit is the matching rules
The expected value is the value to match on in the incoming message
Last dropdown is the response you choose to return based on the above input





Important Soapy Example match

declare namespace v1='http://test.co.za/stuff/Messages/Test/V1';
declare namespace soapenv='http://schemas.xmlsoap.org/soap/envelope/';
//soapenv:Envelope/soapenv:Body/v1:GetTests/v1:TestId


Make sure the mock service is running.

Hook up to code
Now point your code (web service proxy pojo data control for me) to use the mock service url.

Example:


new TestService(new URL("http://127.0.0.1:8088/mockTestService", new QName("http://www.test.co.za/Test/V1","TestService")));


Run screen and test away.

http://www.soapui.org/

I am using 4.5.0