本文整理汇总了Java中com.liferay.portal.kernel.xml.Element.addText方法的典型用法代码示例。如果您正苦于以下问题:Java Element.addText方法的具体用法?Java Element.addText怎么用?Java Element.addText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.kernel.xml.Element
的用法示例。
在下文中一共展示了Element.addText方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResults
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public Element getResults(ActionRequest actionRequest, long questionId){
String answer= ParamUtil.getString(actionRequest, "question_"+questionId, "");
Element questionXML=SAXReaderUtil.createElement("question");
questionXML.addAttribute("id", Long.toString(questionId));
long currentQuestionId = ParamUtil.getLong(actionRequest, "currentQuestionId");
if (currentQuestionId == questionId) {
questionXML.addAttribute("current", "true");
}
Element answerXML=SAXReaderUtil.createElement("answer");
answerXML.addText(answer);
questionXML.add(answerXML);
return questionXML;
}
示例2: exportXML
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public Element exportXML(long questionId) {
XMLType="sort";
Element questionXML = super.exportXML(questionId);
try {
List<TestAnswer> answers = TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId);
for(TestAnswer answer:answers){
Element answerE = SAXReaderUtil.createElement("answer");
answerE.addAttribute("fraction", "100");
Element text = SAXReaderUtil.createElement("text");
text.addText(answer.getAnswer());
answerE.add(text);
questionXML.add(answerE);
}
} catch (SystemException e) {
e.printStackTrace();
}
return questionXML;
}
示例3: exportXML
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public Element exportXML(long questionId) {
XMLType = "draganddrop";
Element questionXML = super.exportXML(questionId);
try {
List<TestAnswer> answers = TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId);
for(TestAnswer answer:answers){
Element answerE = SAXReaderUtil.createElement("answer");
answerE.addAttribute("fraction", (answer.isIsCorrect())?"100":"0");
Element text = SAXReaderUtil.createElement("text");
text.addText(answer.getAnswer());
answerE.add(text);
Element feedback = SAXReaderUtil.createElement("feedback");
Element feedText = SAXReaderUtil.createElement("text");
feedText.addText(answer.getFeedbackCorrect());
feedback.add(feedText);
answerE.add(feedback);
questionXML.add(answerE);
}
} catch (SystemException e) {
e.printStackTrace();
}
return questionXML;
}
示例4: convertHashMapToString
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public String convertHashMapToString(HashMap<String, String> map, int typeId) throws IOException, SystemException{
Element resultadosXML=SAXReaderUtil.createElement(getNameLearningActivity(typeId));
Document resultadosXMLDoc=SAXReaderUtil.createDocument(resultadosXML);
Iterator<Entry<String, String>> it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, String> e = (Map.Entry<String, String>)it.next();
Element eleXML=SAXReaderUtil.createElement(String.valueOf(e.getKey()));
if(e.getKey().toString().contains("document")){
eleXML.addAttribute("id", String.valueOf(e.getValue()));
}else{
eleXML.addText(String.valueOf(e.getValue()));
}
resultadosXML.add(eleXML);
}
return resultadosXMLDoc.formattedString();
}
示例5: exportXML
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public Element exportXML(long questionId) {
XMLType="multichoice";
Element questionXML = super.exportXML(questionId);
try {
List<TestAnswer> answers = TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId);
for(TestAnswer answer:answers){
Element answerE = SAXReaderUtil.createElement("answer");
answerE.addAttribute("fraction", (answer.isIsCorrect())?"100":"0");
Element text = SAXReaderUtil.createElement("text");
text.addText(answer.getAnswer());
answerE.add(text);
Element feedback = SAXReaderUtil.createElement("feedback");
Element feedText = SAXReaderUtil.createElement("text");
feedText.addText(answer.getFeedbackCorrect());
feedback.add(feedText);
answerE.add(feedback);
questionXML.add(answerE);
}
Element single = SAXReaderUtil.createElement("single");
single.addText(XMLSingle);
questionXML.add(single);
} catch (SystemException e) {
e.printStackTrace();
}
return questionXML;
}
示例6: getResults
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
public Element getResults(ActionRequest actionRequest, long questionId){
List<TestAnswer> testAnswers = new ArrayList<TestAnswer>();
try {
testAnswers = TestAnswerLocalServiceUtil.getTestAnswersByQuestionId(questionId);
} catch (SystemException e) {
e.printStackTrace();
}
TestAnswer solution = null;
if(testAnswers!=null && testAnswers.size()>0)
solution = testAnswers.get(0);
String answer = "";
if(solution!=null){
int i = getQuestionSols(solution.getAnswer()).size();
for(int k=0; k<i; k++){
if(answer!="") answer+=",";
answer+= ParamUtil.getString(actionRequest, "question_"+questionId+"_"+k, "").replace(",", ""); //Quito la , de la respuesta del usaurio
}
}
Element questionXML=SAXReaderUtil.createElement("question");
questionXML.addAttribute("id", Long.toString(questionId));
long currentQuestionId = ParamUtil.getLong(actionRequest, "currentQuestionId");
if (currentQuestionId == questionId) {
questionXML.addAttribute("current", "true");
}
Element answerXML=SAXReaderUtil.createElement("answer");
answerXML.addText(answer);
questionXML.add(answerXML);
return questionXML;
}
示例7: setExtraContent
import com.liferay.portal.kernel.xml.Element; //导入方法依赖的package包/类
@Override
public String setExtraContent(UploadRequest uploadRequest,
PortletResponse portletResponse, LearningActivity learningActivity)
throws NumberFormatException, Exception {
ThemeDisplay themeDisplay = (ThemeDisplay) uploadRequest.getAttribute(WebKeys.THEME_DISPLAY);
String fichero = ParamUtil.getString(uploadRequest, "fichero", StringPool.FALSE);
String textoenr = ParamUtil.getString(uploadRequest, "textoenr", StringPool.FALSE);
String team = ParamUtil.getString(uploadRequest, "team","0");
long teamId = 0;
if(!team.equalsIgnoreCase("0")){
teamId = Long.parseLong(team);
}
Document document = null;
Element rootElement = null;
if((learningActivity.getExtracontent()==null)||(learningActivity.getExtracontent().trim().length()==0)){
document = SAXReaderUtil.createDocument();
rootElement = document.addElement("online");
}
else
{
document=SAXReaderUtil.read(learningActivity.getExtracontent());
rootElement =document.getRootElement();
}
Element ficheroXML=rootElement.element("fichero");
if(ficheroXML!=null)
{
ficheroXML.detach();
rootElement.remove(ficheroXML);
}
ficheroXML=SAXReaderUtil.createElement("fichero");
ficheroXML.addText(fichero);
rootElement.add(ficheroXML);
Element textoenrXML=rootElement.element("textoenr");
if(textoenrXML!=null)
{
textoenrXML.detach();
rootElement.remove(textoenrXML);
}
textoenrXML=SAXReaderUtil.createElement("textoenr");
textoenrXML.addText(textoenr);
rootElement.add(textoenrXML);
Element teamElement=rootElement.element("team");
if(teamElement!=null)
{
teamElement.detach();
rootElement.remove(teamElement);
}
if(teamId!=0){
teamElement = SAXReaderUtil.createElement("team");
teamElement.setText(Long.toString(teamId));
rootElement.add(teamElement);
}
learningActivity.setExtracontent(document.formattedString());
return null;
}