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;
    }
   }

1 thought on “get handle to the next and previous view of the train model

  1. xbvhev@gmail.com

    Hi,I log on to your blogs named “get handle to the next and previous view of the train model | They point the finger at me.. again!” daily.Your story-telling style is awesome, keep doing what you’re doing! And you can look our website about love spell.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s