There are several performance issues that you should keep in mind while deploying XML parsing in a MIDP application:
Problem comes when you want to use rendered, actionListener and action attributes of < a:actionLink> with variable ‘r’.
Actually the problem is not of < a:actionLink> or of ‘r’ value but of the working process of jsf framework itself.
After rendered, JSF again checks the ‘r’ value and call for the action. And at that time it does not find the value of ‘r’ so fails to perform the action means ‘r’ is not available.
Solution:
To solve this problem you can wrap the < a:actionLink> with < a:booleanEvaluator> tag
and then there is no need to use rendered in < a:actionLink> because the condition can be checked in < a:booleanEvaluator>.
Sample code looks like this:-
< a:booleanEvaluator value=”#{r.myVariable == true/false}” id=”some-id”>
< a:actionLink value=”" id=”newid” image=”someImage.gif” action=”dialog:MyDialog” actionListener=”#{MyDialog.anyAction}” tooltip=”tooltip” showLink=”false”>
< f:param name=”paramName” value=”#{r.paramValue}”/>
< /a:actionLink>
< /a:booleanEvaluator>
Keep AlgoBlogging!!!
Scenario: you need to find noderef of a folder which contains a document of given node id
Solution:
1. First create the NodeRef for the given node id.
StoreRef storeRef = Repository.getStoreRef();
NodeRef documentNodeRef = new NodeRef(storeRef, documentId);Where documentId is the Node Id for which you are trying to get the parent folder NodeRef.
2. Now you would need to take help of “NodeService” to get the parent folder NodeRef. Suppose you have NodeService available in your bean (you can always get the NodeService from getNodeService() method of ServiceRegistry OR get if from session):
ChildAssociationRef childAssociationRef = this.nodeService.getPrimaryParent(documentNodeRef);
NodeRef documentParentNodeRef = childAssociationRef.getParentRef();
documentParentNodeRef is what you were looking for
Happy AlgoBlogging!!!
You can use an interface as a data type.Every object you assign to that reference variable must be an instance of the class that implements that interface.
interface MyInterface{
public int isLargerThan(Object o);
}
public class NumberTest implements MyInterface {
int number;
Length(int number) {
this. number = number;
}
public int isLargerThan(Object o) {
int thisNum = this. number;
int anotherNum = ((NumberTest)o). number;
if(thisNum > anotherNum)
System.out.println(thisNum +” is larger than ” + anotherNum);
}
}
public class MyTest {
public static void main(String[] args) {
NumberTest num1 = new NumberTest(100);
NumberTest num2 = new NumberTest(50);
NumberTest larger = (NumberTest)findLargest(num1,num2);
/*here num1 and num2 are 2 instances of class NumberTest which implements MyInterface interface so i can convert these objects in MyInterface type.
*/
System.out.println(”larger = ” + larger);
MyInterface myinterface1 = new NumberTest (12);
MyInterface myinterface2 = new NumberTest (32);
MyInterface myinterface = (MyInterface)findLargest(myinterface1, myinterface2);
System.out.println(”myinterface = ” + myinterface);
}
public static Object findLargest(Object object1, Object object2) {
MyInterface obj1 = (MyInterface)object1;
MyInterface obj2 = (MyInterface)object2;
if (obj1.isLargerThan(obj2) > 0)
return object1;
else
return object2;
}
}