Forum Stats

  • 3,728,699 Users
  • 2,245,675 Discussions
  • 7,853,706 Comments

Discussions

Train - How to get index of current stop?

Alejandro Tovar Lanz
Alejandro Tovar Lanz Member Posts: 1,624 Bronze Trophy
edited July 2017 in JDeveloper and ADF

Hi,

Using JDeveloper 12.2.1.2.

Question, how to get the index of the current stop? I have a requirement to display a progress bar instead the train stops (as they are too many). So instead, I would like to display a progress bar. However, to create the model for the bar, I need to know where on the train the user is.

I am now frustrated as I don't want to hard code values (which I could) - perhaps I am missing something small but I don't understand why was so difficult to put what the current stop index was? I can get how many stops the train has though.

Regards

Tagged:
Alejandro Tovar Lanz

Answers

  • Florin Marcus
    Florin Marcus Member Posts: 553 Silver Badge
    edited July 2017

    To get the current tran stop, you can use something like this:
       
         ControllerContext controllerContext = ControllerContext.getInstance();

        ViewPortContext currentViewPortCtx = controllerContext.getCurrentViewPort();

        TaskFlowContext taskFlowCtx = currentViewPortCtx.getTaskFlowContext();

        TaskFlowTrainModel taskFlowTrainModel = taskFlowCtx.getTaskFlowTrainModel();

        TaskFlowTrainStopModel currentStop = taskFlowTrainModel.getCurrentStop();

  • Florin Marcus
    Florin Marcus Member Posts: 553 Silver Badge
    edited July 2017

    To get the current tran stop, you can use something like this:
       
         ControllerContext controllerContext = ControllerContext.getInstance();

        ViewPortContext currentViewPortCtx = controllerContext.getCurrentViewPort();

        TaskFlowContext taskFlowCtx = currentViewPortCtx.getTaskFlowContext();

        TaskFlowTrainModel taskFlowTrainModel = taskFlowCtx.getTaskFlowTrainModel();

        TaskFlowTrainStopModel currentStop = taskFlowTrainModel.getCurrentStop();

  • TPD-Opitz
    TPD-Opitz Member Posts: 2,465 Silver Trophy
    edited July 2017

    what have you tried so far?

    Could you please add a SSCCE?

    bye

    TPD

  • Alejandro Tovar Lanz
    Alejandro Tovar Lanz Member Posts: 1,624 Bronze Trophy
    edited July 2017

    Hi,

    This is what I have tried:

            MenuModel menuModel = ControllerContext.getInstance()

                                                   .getCurrentViewPort()

                                                   .getTaskFlowContext()

                                                   .getTrainModel();

            menuModel.getRowCount();

            menuModel.getRowIndex();

            menuModel.getFocusRowKey();

    RowCount gives me the number of stops.

    RowIndex returns -1 all the time.

    FocusRowKey does return the KEY for the current stop.

    @florinmarcus,

    Thanks, I have tried your code and see what is available but still, couldn't see how would I get the index from it.

  • TPD-Opitz
    TPD-Opitz Member Posts: 2,465 Silver Trophy
    edited July 2017

    What (other) methods does the MenuModel class offer?

    bye

    TPD

  • Florin Marcus
    Florin Marcus Member Posts: 553 Silver Badge
    edited July 2017

    I don’t think you have a straight method for this, but you can recursively use getNextStop() and getPreviousStop() from the current train stop (TaskFlowTrainStopModel) to determine your index.

        TaskFlowTrainStopModel currentStop =  taskFlowTrainModel.getCurrentStop();

        TaskFlowTrainStopModel nextStop = taskFlowTrainModel.getNextStop(currentStop);

        TaskFlowTrainStopModel prevStop = taskFlowTrainModel.getPreviousStop(currentStop);

    Alejandro Tovar Lanz
This discussion has been closed.