currently i facing an issues which need initialize my token as any value 1st. However the token values will change when a new values received. Below is my code:
<form>
<init>
<set token="CH1_CHW_FLOW">0</set>
</init>
</form>
<search id="header">
<query>index="rtindex" Label="CH1" Order="12" |eval Value=round(Value,3) |stats latest(Value) as Value by ID2 |rename ID2 as Label | untable Label field name | xyseries field Label name</query>
<earliest>#d</earliest>
<latest>now</latest>
<preview>
<set token="FLOW_LPS">$result.CH1_CHW_FLOW_LPS$</set>
<set token="FLOW">$result.CH1_CHW_FLOW$</set>
<set token="COOLING_LOAD">$result.CH1_COOLING_LOAD$</set>
<set token="EFF">$result.CH1_EFF$</set>
</preview>
<table id="Chiller_1" border="1px solid black">
<tr><th>HEADER Details </th><th>Values</th></tr>
<tr><td>CHWF (USGPM)</td><td>$CH1_CHW_FLOW$</td></tr>
<tr><td>FLOW (LPS)</td><td>$CH1_CHW_FLOW_LPS$</td></tr>
<tr><td>COOLING LOAD</td><td>$CH1_COOLING_LOAD$</td></tr>
<tr><td>KW/Ton</td><td>$CH1_EFF$</td></tr>
</table>
However due to unknow reason i fail to initialize the value as Zero. It show me
$result.CH1_CHW_FLOW$ instead of zero. Please advise. Thank you very much.
The way to resolve it used eval:
if(isnull($result.fieldname$),0,$result.fieldname$)
Related
I have created a table with name person and added a column 'phone_number' using liquibase changeset. But now I want to add a default value for it. but it did not work, so far I have tried this:
<addDefaultValue columnName="phone_number"
defaultValue="+923331234567"
tableName="person"/>
and
<changeSet author="haseeb" id="20160413123500">
<update tableName="person">
<column name="phone_number" type="varchar(255)" defaultValue="+923331234567"/>
</update>
</changeSet>
and
<changeSet author="haseeb" id="20160413123501">
<update tableName="person">
<column name="phone_number" type="varchar(255)" value="+923331234567"/>
</update>
Can anyone point out where I did wrong and also would adding default value will add value to previously added rows?
try this
<addDefaultValue columnName="phone_number"
defaultValue="+923331234567"
tableName="person" columnDataType="varchar(255)"/>
Try this:
<changeSet author="haseeb" id="20160413123501">
<modifyDataType
columnName="phone_number"
newDataType="varchar(255)"
defaultValue="+923331234567"
tableName="person"/>
<comment>Change default value</comment>
</changeSet>
This is worked for expression:
- addDefaultValue:
tableName: RT_STAGE
columnName: CREATED_DATE
defaultValueComputed: now()
and this for boolean:
- addDefaultValue:
tableName: RT_STAGE
columnName: FINAL
defaultValueBoolean: false
I have an xml persisted in database something as follows:
<root available-locales="en_US" default-locale="en_US">
<dynamic-element name="fdemo-redirect-url" repeatable="false" dataType="string" indexType="" required="false" showLabel="true" type="text" width="25">
<meta-data locale="en_US">
<entry name="label"><![CDATA[fdemo-redirect-url]]></entry>
</meta-data>
</dynamic-element>
<dynamic-element name="close_button" repeatable="false" dataType="document-library" indexType="" required="false" showLabel="true" type="ddm-documentlibrary" fieldNamespace="ddm">
<meta-data locale="en_US">
<entry name="label"><![CDATA[close_button]]></entry>
</meta-data>
</dynamic-element>
....
I need to write a query which should replace an hyphen in name attribute of dynamic-element tag whose dataType attribute is html. I ended up creating the following query. But this works only for one tag at a time. I do not want to loop it using a procedure. Is there a way to tweak this query in such a way that this works for multiple dynamic-element tags?
UPDATE table_name
SET xsd = UpdateXML(
xsd,
'//dynamic-element[5]/#name',
CONCAT(
'name="',
REPLACE(ExtractValue(xsd, '//dynamic-element[5]/#name'), '-', '_'),
'"'))
WHERE ExtractValue(xsd, '//dynamic-element[5]/#dataType') = 'html';
Here in this above query only 5th dynamic-element tag is handled for all the rows.
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(2012);
list.add(2013);
list.add(2014);
list.add(2015);
can we do same as above using struts2 tags. may be by using
<s:set name="myList" value={somedynamic values} />
actually I want to create a list of number of 10 years on JSP page using Struts2 tags.
Regarding to your question answer is yes,but that is not an good idea to create number of 10 years in jsp page.
However, this is using arrylist in dynamic way
<s:select label="Years" headerKey="-1" headerValue="Select Years" list="list" name="your desire name" />
in the place of list property you have to give arrayList variable in your case it is list
means,
<s:select ---- list="your array list variable" --------- />
and you have to define this action name in struts.xml
eg:
<action name="yourarrylistvariable" class="your class" method="your method">
<result name="success">your jsp page</result>
</action>
This is using arrylist in static way here you have to change the list value
<s:select label="Years" headerKey="-1" headerValue="Select Years"
list="#{'2000':'2000', '2013':'2013',.....}" name="your desire name" />
For More Info You can refer this link struts2 select
Sure you can, thanks to the OGNL you can create lists like so:
<s:set var="myList" value="{2012,2013,2014,2015}" />
See this link.
there are news titles.and user click on these titles.browser goes to the page which shoes the news of this title.i want to get data from database where id equals to elements id which is clicked.element gets id from database so i don't know id in advance.
<ui:repeat value="#{controller.sql.yenilikler}" var="list">
<a href="xeberShekil.xhtml" id="#{list.id}}">
#{list.basliq}
</a>
<br/>
</ui:repeat>
so i should
1.get the id of an element which is clicked
2.send this id into a variable in java class
3.send query which is get a data from database where id= the id of element
int id;
ResultSet rs= statement.executeQuery("select * from tableName where id="+id);
if an other algorithm propose please share.Tnx a lot
Pass values to managed bean using f:param, f:setPropertyActionListner or pass value directly using commandbutton's action="#{bean.someAction(value)}"
See JSF-2 Action Parameter for code snippets.
Edit to Code
Data table
<h:dataTable value="#{someManagedBean.categories}" var="cat">
<h:column>
<h:commandButton action="#{someManagedBean.edit(cat.id)}"
</h:column>
</h:dataTable>
Managed Bean
public void edit(id) {
doYourDBThing(id);
}
You can also use f:param and f:setPropertyActionListner. See the above link.
How to write dynamic struts <html:option>, I'm doing as below
<logic:iterate id="data" name="sendEmailForm" property="eventList">
<html:option value="<bean:write name="data" property="eventId"/>"/>
<bean:write name="data" property="title"/>
</html:option>
</logic:iterate>
but getting following error:
JSPG0069E: Unmatched end tag found while parsing jsp. Expecting
logic:iterate found html:option at [87,130]
is there another way to do so?
Thanks in advance.
<html:option property="title">
<html:optionsCollection name="sendEmailForm" label="title" value="eventId" />
<html:option>
html:option tag
property="?" whatever you want to set like if attribute is title and corresponding method (getTitle(), setTitle(String title) ) then property= "title"
html:optionsCollection tag
name = "?" whatever you have put in your request/session attribute
like (request Or session).setAttribute("sendEmailForm", ListArr);
then name="sendEamilForm"
listArr is array of object of bean ( may be formbean or simple pojofile/bean).
label ="?" what ever you want to show like if you have attribute 'title' and
corresponding setter(setTitle(String title)) and getter(getTitle()) method then
label="title"
value ="?" what ever you want to put as value in option. you call your getter method
corresponding attribute like if you have attribute eventId and method (
setEventId(String eventId) , getEventId() ) then value="eventId"
ok finally i found below for solution
<html:optionsCollection name="sendEmailForm" property="eventList" label="title" value="eventId" />