On 10/12/2011 05:54 AM, Gerritjan Koekkoek wrote:
sorry,
new error: (on line 171?)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769) at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698) at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891) at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690) at
java.lang.Thread.run(Thread.java:662) Caused by:
org.xwiki.velocity.XWikiVelocityException: Failed to evaluate content with id
[xwiki:CdlsatdPrivate.DjennaKoekkoek3_doc101] at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:205)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:161)
at
org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:118)
... 87 more Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation
of method 'get' in class java.util.Collections$EmptyList threw exception
java.lang.IndexOutOfBoundsException: Ind
ex: 0 at
xwiki:CdlsatdPrivate.DjennaKoekkoek3_doc101[line 171, column 32] at
org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:337)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:284) at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:252) at
org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:493) at
org.apache.velocity.runtime.parser.node.ASTMathNode.value(ASTMathNode.java:84) at
org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71) at
org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71) at
org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142)
at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336) at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:196)
... 89 more Caused by: java.lang.IndexOutO
fBoundsException: Index: 0 at java.util.Collections$EmptyList.get(Collections.java:2970)
at sun.reflect.GeneratedMethodAccessor11070.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at
java.lang.reflect.Method.invoke(Method.java:597) at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270) ... 97
more
complete code;
{{include document="CdlsatdCode.DisplayRestrictions"/}}
{{velocity filter="none"}}
{{html clean="false" wiki="true"}}
## This sheet will display and edit a Private Question
##
## The privat question is a object of class CdlsatdCode.CdLS_ATD_UserQuestionsClass
#set($class =
$doc.getObject("CdlsatdCode.CdLS_ATD_UserQuestionsClass").xWikiClass)
#set($userQuestionObj =
$doc.getObject("CdlsatdCode.CdLS_ATD_UserQuestionsClass"))
##
## Test if we are in this form based on request params
## We expect request in the following types
## ===================================================
## Create new privat question of user in group (users)
## params:
## -name = Valid username, without XWiki.
## -status = Valid from list codes, new question expect 'opt_un_answered'
## -generalize = Valid from class defenition (Yes|No), new question expect
'No', means the question can contain privacy sensitive data
## -cdls = Computed document name, should not exist already, we expect
[username]_doc[sequenceForUser]
## ====================================================
## Create new Global queury document (meaning it will be distributed to all moderators
for help on this question) (Language must be english)
## params:
##
##
#if($request)
We have request<br/>
#if($request.language)
#set($lang=$request.language)
#else
#set($lang=$context.language)
#end
## Parameters for request to create privat question for user...
#if($request.getParameter('name'))
We have parameters as expected
#set($nameAuthor = $request.getParameter('name'))
## Check for valid author against database
$userQuestionObj.set('name',$nameAuthor)
## $doc.set('name',$nameAuthor)
#if($request.getParameter('status'))
#set($statusQuestion = $request.getParameter('status'))
$userQuestionObj.set('status',$statusQuestion)
##$doc.set('status',$statusQuestion)
#end
#if($request.getParameter('generalize'))
#set($indicationGeneralize = $request.getParameter('generalize'))
$userQuestionObj.set('(generalize',$indicationGeneralize)
##$doc.set('status',$statusQuestion)
#end
#if($request.getParameter('cdls'))
## Why do we need this param, its already the document title?
##set($questionDocumentName = $request.getParameter('cdls'))
#end
#end
## Parameters of other requests
#end
## Build a list of possible status the question can have to populate dropdown
## dependant on the language it will take the list from CdlsatdCode.Translations
## the key values of list should, off course, not be translated
##
dd_status_question_v1=opt_un_answered,opt_answered,opt_in_progress,opt_more_info_required
##
## First get the translated meanings
#set($engList = $msg.get('dd_status_user_questions_en'))
#set($engStatusList=[])
#foreach( $op in $engList.split("[|,]"))
#set($temp2 = $engStatusList.add($op))
#end
## $engStatusList {{html}}<br/>{{/html}}
## Second get the list codes
#set($questionStatusComma = $msg.get('dd_status_question_v1'))
#set($statusList=[])
#foreach($keyStatusTxt in $questionStatusComma.split("[|,]"))
#set($temp3 = $statusList.add($keyStatusTxt))
#end
## $statusList {{html}}<br/>{{/html}}
##
## Get the status of the question, maybe this should only be done if document is NOT NEW
(in case of UPDATE DOC)
#set($userQnStatus = $userQuestionObj.getProperty('status').getValue())
##
## Evaluate the creation of a new question (or a modification)
#if($request.getParameter('success') == 'true')
## We have a slightly disturbing Rights implementation
## User is a client
## If you are not in User you are considered a Moderator (or question support person)
## But also these people should be allowed to post questions, currently they are not!
## better implementation would be; All approped people should be in User, some have
extra rights like Moderator or Global moderator
#if($xwiki.getUser().isUserInGroup("XWiki.User"))
{{info}}$msg.get('msg_success_question_posted'){{/info}}
#else
{{info}}$msg.get('msg_success'){{/info}}
#end
#end
##
## Setting of Error, Warning, Hint messages used by the
(% id="mandatory" style="display:none;" %)(((
{{error}}$msg.get('msg_err_mandatory'){{/error}}
)))
##
## When a PRIVAT question is created the name of the page should be unique
## All this code is not required when doc is created from request params
#set($public = '_FAQ')
#set($xWikiStr = "XWiki.")
#set($newObjStr = $context.user)
#set($username = $newObjStr.substring($xWikiStr.length(), $newObjStr.length()))
#set($ctxtUsr = '')
#if($doc.isNew())
#set($ctxtUsr = $context.user)
#else
#set($ctxtUsr = $doc.creator)
#end
$ctxtUsr {{html}}<br/>{{/html}}
#set($hql1=
"select doc.fullName
from XWikiDocument doc
, BaseObject obj
, StringProperty prop
where doc.fullName=obj.name
and obj.className='CdlsatdCode.CdLS_ATD_UserProfileClass'
and prop.id=obj.id
and prop.name='contextUsr'
and prop.value='$ctxtUsr'")
#set($users=$xwiki.search($hql1))
$users {{html}}<br/>{{/html}}
#set($usrName = "")
#set($usrMail = "")
#set($reqParamAuthor="")
#if($request.getParameter('author'))
#set($reqParamAuthor=$request.getParameter('author'))
#else
#if($doc.isNew())
#set($reqParamAuthor=$context.user)
#else
#set($reqParamAuthor=$doc.creator)
#end
#end
$reqParamAuthor {{html}}<br/>{{/html}}
##
#if($doc.isNew())
<input type="hidden" name="author" id="author"
value="$reqParamAuthor"/>
#set($userObj = $xwiki.XWikiUsers)
#set($usrName = $userObj.getProperty('first_name').getValue())
#set($lastName = $userObj.getProperty('last_name'))
#set($usrCntry = $userObj.getProperty('country'))
#set($usrMail = $userObj.getProperty('email').getValue())
#else
#set($hqlForXWikiUsers =
" , BaseObject obj
where doc.fullName=obj.name
and doc.fullName='$reqParamAuthor'
and obj.className='XWiki.XWikiUsers'
and obj.name<>'XWiki.XWikiUserTemplate'
")
## $hqlForXWikiUsers<br/>
#set($resultForUsers = $xwiki.searchDocuments($hqlForXWikiUsers))
#foreach($objDoc in $resultForUsers)
#set($docUser = $xwiki.getDocument($objDoc))
#set ($userObj = $docUser.getObject("XWiki.XWikiUsers"))
#set($usrName = $userObj.getProperty('first_name').getValue())
#set($usrMail = $userObj.getProperty('email').getValue())
#end
#end
#if($request.getParameter('global'))
$doc.set('subject',$request.getParameter('subject'))
$doc.set('topics',$request.getParameter('topics'))
$doc.set('question',$request.getParameter('question'))
$doc.set('status',$request.getParameter('status'))
#end
#set($countQuery =
"select count(doc)
from XWikiDocument as doc
where doc.creator='$context.user'
")
#set($resultCount = $xwiki.search($countQuery))
#set($docCount = ($resultCount.get(0) +1))
Line 171 is here, which means that the query doesn't work. Missing
programming rights?
Anyway, you should use the better suited countDocuments method (and the
parameterized version is even better):
#set($docCount = $xwiki.countDocuments('where doc.creator=?',
[$xcontext.user]) + 1)
Check if you really don't have programming rights:
$doc.hasProgrammingRights()
#set($part1 = $username)
#set($part2 = "_doc")
#set($part3 = $docCount)
#set($newDocName= $part1+$part2+$part3)
## Change class name to your class name
#if(!$doc.isNew()&&
$xwiki.getUser().isUserInGroup("XWiki.User")&& $context.user !=
$doc.creator)
* $msg.get('msg_permission_denied')
#else
<input type="hidden" name="success" id="success"
value=""/>
## Manic changes starts
#if(!$doc.isNew())
#set($newCreatorObjStr = $doc.creator)
#set($creatorName = $newCreatorObjStr.substring($xWikiStr.length(),
$newCreatorObjStr.length()))
#set($profilee = "_profile")
#set($creatorDocNameNew = $creatorName+$profilee)
#set($creatorCountQuery =
"select doc
from XWikiDocument as doc
where doc.name='$creatorDocNameNew'
")
#set($resultCreatorCount = $xwiki.search($creatorCountQuery ))
#if(!($xwiki.getUser().isUserInGroup("XWiki.User"))&&
!($doc.getValue('status') == 'opt_global_query_un_answered' ||
$doc.getValue('status') == 'opt_global_query_answered'))
#set($spaceName = "CdlsatdPrivate.")
#set($docFullName = $spaceName+$creatorDocNameNew)
<div id="docNotExistId" align="center"
style="display:none;">
#set($msgNoeExist = "User profile not available for the user
$creatorName.")
<span>{{error}}$msgNoeExist{{/error}}</span>
</div>
<div align="right">
<a onClick="openUserProfile($xwiki.exists($docFullName));"
href="*">
$msg.get('lbl_lnk_view_profile')
</a>
</div>
#end
#end
#if($context.action == 'inline')
$msg.get('lbl_lnk_post_qn')
#else
$msg.get('lbl_head_view_qn')
#end
##
##
<ul class="altRowForm">
#set($hasProps = false)
#set($mandatoryClassVar="")
#if($context.action=="inline")
#set($mandatoryClassVar="<span
class='redMandatory'>*</span>")
#end
#set($counter=0)
#foreach($prop in $class.properties)
#set($oddOrEven=$counter%2)
#set($noBackgroundClass="")
#if($oddOrEven==1)
#set($noBackgroundClass="noBackground")
#end
#if($velocityCount == 1)
#set($hasProps = true)
#end
#if(${prop.prettyName} == 'Answer')
#if($xwiki.getUser().isUserInGroup("XWiki.User"))
#if(!($doc.getValue('status') == 'opt_un_answered'))
<li class="$noBackgroundClass">
<label>$msg.get(${prop.prettyName})</label>
<span
class="labelValue">$doc.display($prop.getName(),'view')</span>
</li>
#end
#else
<li class="$noBackgroundClass">
<label>$msg.get(${prop.prettyName})</label>
<span
class="labelValue">$doc.display($prop.getName())</span>
</li>
#end
#elseif(${prop.prettyName} == 'Status')
#if($xwiki.getUser().isUserInGroup("XWiki.User"))
#if($doc.isNew())
#set($minusOne=$xwiki.parseInt("-1"))
#set($counter=$counter+$minusOne)
$doc.display($prop.getName(),'hidden')
#else
<li class="$noBackgroundClass">
<label>$msg.get(${prop.prettyName})</label>
<span
class="labelValue">$msg.get($doc.display($prop.getName(),'view'))</span>
</li>
#end
#else
<li class="$noBackgroundClass">
<label>$msg.get(${prop.prettyName})</label>
<span class="labelValue">
#if($context.action == 'inline')
<select name="CdlsatdCode.CdLS_ATD_UserQuestionsClass_0_status">
#if($request.getParameter('global'))
<option value="opt_global_query_un_answered"
selected="true">$msg.get('opt_global_query_un_answered')</option>
#elseif($userQnStatus.contains('global'))
<option value="opt_global_query_un_answered" #if($userQnStatus ==
'opt_global_query_un_answered') selected="true"
#end>$msg.get('opt_global_query_un_answered')</option>
<option value="opt_global_query_answered" #if($userQnStatus ==
'opt_global_query_answered') selected="true"
#end>$msg.get('opt_global_query_answered')</option>
#else
#foreach($statusListStr in $statusList)
<option value="$statusListStr" #if($userQnStatus==$statusListStr)
selected="true" #end>$msg.get($statusListStr)</option>
#end
#end
</select>
#else
$msg.get($doc.get('status'))
#end
</span>
</li>
#end
#elseif(${prop.prettyName} == 'Published to Public')
#if($doc.isNew())
$doc.display($prop.getName(),'hidden')
#else
#if($xwiki.getUser().isUserInGroup("XWiki.User"))
$doc.display($prop.getName(),'hidden')
#else
<li class="$noBackgroundClass">
<label>$msg.get(${prop.prettyName})</label>
<span
class="labelValue">$doc.display($prop.getName())</span>
</li>
#end
#end
#elseif(${prop.prettyName} == 'Name')
$doc.set($prop.getName(),$usrName)
<input type="hidden"
name="CdlsatdCode.CdLS_ATD_UserQuestionsClass_0_name"
value="$usrName"/>
<li class="$noBackgroundClass">
<label>$msg.get(${prop.prettyName})</label>
<span
class="labelValue">$doc.display($prop.getName(),'view')</span>
</li>
#elseif(${prop.prettyName} == 'E-mail')
$doc.set($prop.getName(),$usrMail)
<input type="hidden"
name="CdlsatdCode.CdLS_ATD_UserQuestionsClass_0_email"
value="$usrMail"/>
<li class="$noBackgroundClass">
<label>$msg.get(${prop.prettyName})</label>
<span class="labelValue">$doc.display($prop.getName(),
'view')</span><
/li>
#elseif(${prop.prettyName} == 'Subject')
#if($request.getParameter('global'))
<li class="$noBackgroundClass">
<label>$msg.get('Original Subject')</label>
<span class="labelValue">$doc.display($prop.getName(),
'view')</span>
</li>
#end
<li class="$noBackgroundClass">
<label>$msg.get(${prop.prettyName}) $mandatoryClassVar</label>
#if($xwiki.getUser().isUserInGroup("XWiki.User"))
<span
class="labelValue">$doc.display($prop.getName())</span>
#elseif($request.getParameter('global'))
<span class="labelValue"><input
id="CdlsatdCode.CdLS_ATD_UserQuestionsClass_0_subject"
name="CdlsatdCode.CdLS_ATD_UserQuestionsClass_0_subject"
value=""/></span>
#else
<span
class="labelValue">$doc.display($prop.getName(),'view')</span>
#end
</li>
#elseif(${prop.prettyName} == 'Question')
#if($request.getParameter('global'))
<li class="$noBackgroundClass">
<label>$msg.get('Original Question')</label>
<span class="labelValue">$doc.display($prop.getName(),
'view')</span>
</li>
#end
<li class="$noBackgroundClass">
<label>$msg.get(${prop.prettyName}) $mandatoryClassVar</label>
#if($xwiki.getUser().isUserInGroup("XWiki.User"))
<span
class="labelValue">$doc.display($prop.getName())</span>
#elseif($request.getParameter('global'))
<span class="labelValue">
<textarea id="CdlsatdCode.CdLS_ATD_UserQuestionsClass_0_question"
name="CdlsatdCode.CdLS_ATD_UserQuestionsClass_0_question" rows="5"
cols="40"></textarea>
</span>
#else
<span
class="labelValue">$doc.display($prop.getName(),'view')</span>
#end
</li>
#end
#set($counter=$counter+1)
#end
</ul>
#end
#if($context.action=="inline")
* $msg.get('cnt_mandatoy_msg')
#end
#if($request.getParameter('global'))
* Note:Please translate subject and question to English before posting the global query
<p/>
#end
#if($hasProps)
#end
##
## Publish the Personal Question to Public
#if(($doc.get('generalize') == 'No')&&
(($doc.getValue('status') == 'opt_answered') ||
($doc.getValue('status') == 'opt_global_query_answered')))
#if(!$xwiki.getUser().isUserInGroup("XWiki.User"))
<a href="*"
onclick='javascript:postPublic(document.postPublicForm);'
class="roundCornerLink"><span>$msg.get('lbl_btn_publich_public')</span></a>
<form name="postPublicForm" action="" method="post"
id="postPublicForm">
<input type="hidden" name="parent"
value="CdlsatdPublic.WebHome" />
<input type="hidden" name="template"
value="CdlsatdCode.CdLS_ATD_PublicFAQClassTemplate" />
<input type="hidden" name="gen" value="yes"/>
<input type="hidden" name="docname"
value="$doc.fullName"/>
<input type="hidden" name="question"
value="$doc.get('question')"/>
<input type="hidden" name="subject"
value="$doc.get('subject')"/>
#set($docAnsVal=$doc.get('answer'))
#set($docAnsVal=$xwiki.getXMLEncoded($docAnsVal))
<input type="hidden" name="answer" id="answer"
value="$docAnsVal"/>
<input type="hidden" name="language" value="en"/>
<input type="hidden" name="lang" value="en"/>
<input type="hidden" name="cdls1"
value="$doc.name$public" size="50"/>
<input type="hidden" name="author"
value="$reqParamAuthor"/>
</form>
<script>
function postPublic(form) {
form.action="../../inline/CdlsatdPublic/" + form.cdls1.value;
form.submit();
}
</script>
#end
#end
## Post a Global Query
#if((!$xwiki.getUser().isUserInGroup("XWiki.User"))&&
(!($request.getParameter('global')))&& !($doc.getValue('status')
== 'opt_answered' || $doc.getValue('status') ==
'opt_global_query_answered' || $doc.getValue('status') ==
'opt_global_query_un_answered'))
<form id="postGlobalForm" name="postGlobalForm"
action="" method="get">
<input type="hidden" name="parent"
value="CdlsatdPrivate.WebHome" />
<input type="hidden" name="template"
value="CdlsatdCode.CdLS_ATD_UserQuestionsClassTemplate" />
<input type="hidden" name="name" value=""/>
<input type="hidden" name="question"
value="$doc.get('question')"/>
<input type="hidden" name="subject"
value="$doc.get('subject')"/>
<input type="hidden" name="global" value="yes"/>
<input type="hidden" name="status"
value="opt_global_query_un_answered"/>
<input type="hidden" name="generalize"
value="No"/>
<input type="hidden" name="language" value="en"/>
###set($reqParamAuthor = $context.user)
<input type="hidden" name="author"
value="$context.user"/>
<input type="hidden" name="cdls"
value="$newDocName"/>
</form>
#if($context.action == "view")
<a href="*" class="roundCornerLink"
onclick='javascript:postGlobal();'><span>$msg.get('lbl_btn_post_global')</span></a>
#end
<script type="text/javascript">
function postGlobal() {
document.getElementById("postGlobalForm").action="../../inline/CdlsatdPrivate/"
+ document.getElementById("postGlobalForm").cdls.value;
document.getElementById("postGlobalForm").submit();
}
</script>
#end
## Public Version
#if(!$xwiki.getUser().isUserInGroup("XWiki.User"))
#if($doc.get('generalize') == 'Yes')
#set($newDocName=$doc.name+""+$public)
#set ($faqquery = ", BaseObject as obj,StringProperty as prop where
obj.name=doc.fullName and doc.name='$newDocName' and
obj.className='CdlsatdCode.CdLS_ATD_PublicFAQClass' and
obj.name<>'CdlsatdCode.CdLS_ATD_PublicFAQClassTemplate' and prop.id=obj.id
and prop.name='language' and prop.value='$lang' order by doc.date
desc")
#set($countList = $xwiki.searchDocuments($faqquery))
#if($countList.size()>0)
<a href="../../view/CdlsatdPublic/$doc.name$public"
class="roundCornerLink"><span>$msg.get('lbl_lnk_public_version')</span></a>
#end
#end
#end
## Edit Link for the personal Question
#if(($context.action != "inline")&& !$doc.isNew())
#if(!$xwiki.getUser().isUserInGroup("XWiki.User") || ($doc.creator ==
$context.user))
<a href
="$doc.getURL("inline","edit=yes&author=$reqParamAuthor")"
class="roundCornerLink"><span>$msg.get('lbl_btn_edit')</span></a>
#end
#end
<script>
function openUserProfile(isDocExist) {
if(isDocExist) {
window.open
("../../view/CdlsatdPrivate/$creatorDocNameNew?mode=view&popup=true",
"childFlagWindow","location=0,status=0,scrollbars=1,width=750,height=900,resizable=0");
} else {
document.getElementById("docNotExistId").style.display='block';
}
}
</script>
{{/html}}
{{/velocity}}
Op 12 okt. 2011, om 11:05 heeft Sergiu Dumitriu het volgende geschreven:
> On 10/11/2011 05:15 AM, Gerritjan Koekkoek wrote:
>> Hi
>>
>> We have a script developped in XWiki which does not function anymore?
>> Probably due to migration or rights...
>>
>> My problem is that the script is developed by a IT partner 3 years ago, in XWiki
1.6
>>
>> THere is a button in a screen showing a overview of pages with a button to create
a new page.
>> This button has the following link;
>>
http://www.cdlsworld.org/xwiki/bin/inline/CdlsatdPrivate/DjennaKoekkoek3_do…
>> ?Parent=CdlsatdPrivate.WebHome
>> &template=CdlsatdCode.CdLS_ATD_UserQuestionsClassTemplate
>> &name=Djenna
>> &status=opt_un_answered
>> &generalize=No
>> &cdls=DjennaKoekkoek3_doc105
>>
>> The errorcode is not helping me much...
>> Caused by: org.xwiki.velocity.XWikiVelocityException: Failed to evaluate content
with id [xwiki:CdlsatdPrivate.DjennaKoekkoek3_doc105]
>> at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:205)
>> at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:161)
>> at
org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:118)
>> ... 87 more
>> Caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of
method 'get' in class java.util.Collections$EmptyList threw exception
java.lang.IndexOutOfBoundsException: Index: 0 at
xwiki:CdlsatdPrivate.DjennaKoekkoek3_doc105[line 124, column 32]
>> at
org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:337)
>> at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:284)
>> at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:252)
>> at
org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:493)
>> at
org.apache.velocity.runtime.parser.node.ASTMathNode.value(ASTMathNode.java:84)
>> at
org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71)
>> at
org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71)
>> at
org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142)
>> at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
>> at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:196)
>> ... 89 more
>> Caused by: java.lang.IndexOutOfBoundsException: Index: 0
>> at java.util.Collections$EmptyList.get(Collections.java:2970)
>> at sun.reflect.GeneratedMethodAccessor11070.invoke(Unknown Source)
>> at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> The code around Line 12 (How should I find the linenumber; should I include with
counting the comments lines or only the lines with code?)
>>
>> ## This sheet will display and edit a Private Question
>> ##
>> ## Test the language to display the information
>> #if($request.language)
>> #set($lang=$request.language)
>> #else
>> #set($lang=$context.language)
>> #end
>> $lang {{html}}<br/>{{/html}}
>> ## Build a list of possible status the question can have to populate dropdown
>> ## dependant on the language it will take the list from CdlsatdCode.Translations
>> ## the key values of list should, off course, not be translated
>> ##
dd_status_question_v1=opt_un_answered,opt_answered,opt_in_progress,opt_more_info_required
>> ##
>> ## First get the translated meanings
>> #set($engList = $msg.get('dd_status_user_questions_en'))
>> #set($engStatusList=[])
>> #foreach( $op in $engList.split("[|,]"))
>> #set($temp2 = $engStatusList.add($op))
>> #end
>> $engStatusList {{html}}<br/>{{/html}}
>> ## Second get the list codes
>> #set($questionStatusComma = $msg.get('dd_status_question_v1'))
>> #set($statusList=[])
>> #foreach($keyStatusTxt in $questionStatusComma.split("[|,]"))
>> #set($temp3 = $statusList.add($keyStatusTxt))
>> #end
>> $statusList {{html}}<br/>{{/html}}
>> ##
>> ## The privat question is a object of class
CdlsatdCode.CdLS_ATD_UserQuestionsClass
>> #set($userQuestionObj =
$doc.getObject("CdlsatdCode.CdLS_ATD_UserQuestionsClass"))
>> ## Get the staus of the question
>> #set($userQnStatus = $userQuestionObj.getProperty('status').getValue())
>> ##
>> ## Evaluate the creation of a new question (or a modification)
>> #if($request.getParameter('success') == 'true')
>> ## We have a slightly disturbing Rights implementation
>> ## User is a client
>> ## If you are not in User you are considered a Moderator (or question support
person)
>> ## But also these people should be allowed to post questions, currently they
are not!
>> ## better implementation would be; All approped people should be in User, some
have extra rights like Moderator or Global moderator
>> #if($xwiki.getUser().isUserInGroup("XWiki.User"))
>> {{info}}{{html
clean="false"}}$msg.get('msg_success_question_posted'){{/html}}{{/info}}
>> #else
>> {{info}}{{html
clean="false"}}$msg.get('msg_success'){{/html}}{{/info}}
>> #end
>> #end
>
> The error says line 124, but there are only 48 lines of code here. So,
> the error is not here (and neither did I see a line that could trigger
> that error).
>
>> It looks like it find an empty object...
>>
>> This is exactly what I find, it looks like the code is creating a page with a
empty object,
>> but it fails to set values in the object, and after that I understand the error,
>>
>> What I do not inderstand where the code is that would set the values in the
object, I would expect it in the Template?
>> But maybe it is hidden in the code on the page where the button is in the
Form-area
>>
>> So maybe I should ask the question how I would do this in the new XWiki 2.7
(which we are running) If I should start all new
>> I would like to create a page with an object of which a few attributes are hidden
from the user (containing some ID and status information)
>> After the click the user should experience that he is on the newly created page
and filling in the remaining attributes of the object (a Question and Answer)
>>
>> Second, since the intention of the page/object is to start a workflow; 1) Create
a Question by a user (this step) -> 2) Accepting the Question by a moderator by
status change-> 4) Moderator answering the question by typing a answer-> User
accepting the answer and closing the case by changing the status
>> What is the best practise to put the code for each step in the workflow? At this
moment all the code is in the templatesheet of the page, making it difficult to maintain
and look for the code
>> Would you advise to put the code in the template or put code in velocity
macro's and have buttons in the sheet
>>
>> Help would be very much appreciated, both on finding the cause of the error and
on advise what is the best practise to do such USE-Case
>
--
Sergiu Dumitriu
http://purl.org/net/sergiu/