org.apache.commons.jelly.tags.interaction
Class AskTag

java.lang.Object
  extended by org.apache.commons.jelly.TagSupport
      extended by org.apache.commons.jelly.tags.interaction.AskTag
All Implemented Interfaces:
org.apache.commons.jelly.Tag

public class AskTag
extends org.apache.commons.jelly.TagSupport

Jelly Tag that asks the user a question, and puts his answer into a variable, with the attribute "answer". This variable may be reused further as any other Jelly variable.

Author:
St??phane Mor

Field Summary
private  java.lang.String answer
          The variable in which we will stock the user's input.
private  java.util.List completor
          A list of predefined commands for tab completion.
private static jline.History consoleHistory
          The history of previous user-inputs.
private  java.lang.String defaultInput
          The default value, if the user doesn't answer.
private static org.apache.commons.logging.Log logger
           
private  java.lang.String prompt
          The prompt to display before the user input.
private  java.lang.String question
          The question to ask to the user.
private  boolean useHistoryCompletor
          Whether to complete with previous completions as well.
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
AskTag()
           
 
Method Summary
 void doTag(org.apache.commons.jelly.XMLOutput output)
          Perform functionality provided by the tag.
 void setAnswer(java.lang.String answer)
          Sets the name of the variable that will hold the answer.
 void setCompletor(java.util.List list)
          Sets the list of predefined commands.
 void setDefault(java.lang.String defaultInput)
          Sets the default answer to the question.
 void setPrompt(java.lang.String prompt)
          Sets the prompt that will be displayed before the user's input.
 void setQuestion(java.lang.String question)
          Sets the question to ask to the user.
 void setUseHistoryCompletor(boolean should)
          Whether the completion should also happen on previously entered lines (default true).
 
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static org.apache.commons.logging.Log logger

consoleHistory

private static jline.History consoleHistory
The history of previous user-inputs.


question

private java.lang.String question
The question to ask to the user.


answer

private java.lang.String answer
The variable in which we will stock the user's input. This defaults to "interact.answer".


defaultInput

private java.lang.String defaultInput
The default value, if the user doesn't answer.


prompt

private java.lang.String prompt
The prompt to display before the user input.


completor

private java.util.List completor
A list of predefined commands for tab completion.


useHistoryCompletor

private boolean useHistoryCompletor
Whether to complete with previous completions as well.

Constructor Detail

AskTag

public AskTag()
Method Detail

setQuestion

public void setQuestion(java.lang.String question)
Sets the question to ask to the user. If a "default" attribute is present, it will appear inside [].

Parameters:
question - The question to ask to the user

setAnswer

public void setAnswer(java.lang.String answer)
Sets the name of the variable that will hold the answer. This defaults to "interact.answer".

Parameters:
answer - the name of the variable that will hold the answer

setDefault

public void setDefault(java.lang.String defaultInput)
Sets the default answer to the question. If it is present, it will appear inside [].

Parameters:
defaultInput - the default answer to the question

setPrompt

public void setPrompt(java.lang.String prompt)
Sets the prompt that will be displayed before the user's input.

Parameters:
prompt - the prompt that will be displayed before the user's input.

setCompletor

public void setCompletor(java.util.List list)
Sets the list of predefined commands.

Parameters:
list - the list of commands used for tab completion.

setUseHistoryCompletor

public void setUseHistoryCompletor(boolean should)
Whether the completion should also happen on previously entered lines (default true).

Parameters:
should - whether it should

doTag

public void doTag(org.apache.commons.jelly.XMLOutput output)
Perform functionality provided by the tag.

Parameters:
output - the place to write output