Monthly Archives: May 2011

blogging 4m my blackberry


First blog of mine 4m my blackberry curve

Advertisements

get handle to the next and previous view of the train model


Add the following jstl function library to the jsp:root tag

xmlns:fn=http://java.sun.com/jsp/jstl/functions

and proceed with

text="goto page# #{fn:substringAfter(controllerContext.currentViewPort.taskFlowContext.trainModel.next ,'@')}"
text="goto page# #{fn:substringAfter(controllerContext.currentViewPort.taskFlowContext.trainModel.previous ,'@')}"

some of the values that you can get related to trainModel previous and next actions are

#{controllerContext.currentViewPort.taskFlowContext.trainModel.goNext}
#{controllerContext.currentViewPort.taskFlowContext.trainModel.goPrevious}

Note: to get the display name from the trainstop you have to manually have the binding for next and previous strings added to the bean and evaluate the text manually like

public class Bean {
    TrainModel train;
    TrainStopModel trainStopModel;
String next;
  String previous;
    public Bean() {
      PageFlowStack stack = StateUtils.getCurrentViewPort().getPageFlowStack();
          if (stack.size() > 0)
          {
            train = stack.peek().getTrainModel();
          }
    }
  public static Object evaluateEL(String el) {
      FacesContext facesContext = FacesContext.getCurrentInstance();
      ELContext elContext = facesContext.getELContext();
      ExpressionFactory expressionFactory =
          facesContext.getApplication().getExpressionFactory();
      ValueExpression exp =
          expressionFactory.createValueExpression(elContext, el,
                                                  Object.class);

      return exp.getValue(elContext);
  }
    public void setNext(String next) {
        this.next = next;
    }

    public String getNext() {

      trainStopModel = train.getNextTrainStop(train.getCurrentTrainStop());
      this.next  = trainStopModel.getTextAndAccessKey();
        return next;
    }

    public void setPrevious(String previous) {
      this.previous = previous;
   }

    public String getPrevious() {
        if(train != null){
      trainStopModel = train.getPreviousTrainStop(train.getCurrentTrainStop());
          this.previous  = trainStopModel.getActivityId().getLocalActivityId();
        }
        return previous;
    }
   }