portal相关问题原因及解决方法

portal常见问题及解决方法

1.界面提示 index越界 -1

一般为数据集按索引取值或设值时,使用了ds.nameToIndex(“field”)方法获取字段索引,而数据集不存在要取出的字段,得到-1,报错数组越界。

2.检查节点权限失败pk is null

节点或者节点的上级没有在数据库中注册模块

3.提交单据报异常:sql parameter obejct cannot be null……

单据的提交方式,没有先保存。
引导用户先保存即可。

Dataset ds = this.getMasterDs();
		String primaryKey = ds.getPrimaryKeyField();
		if (primaryKey == null)
			throw new LfwRuntimeException("当前Dataset没有设置主键!");
		String pkValue = (String) ds.getValue(primaryKey);
		if (pkValue == null) {
			throw new LfwRuntimeException("请先保存数据,再提交");
		}

portal相关设置

1.设置输入框长度
<ModifyField id="memo">
	<Attributes>
	   <Attribute>
	      <Key>$maxLength</Key>
	      <Value>200</Value>
	    </Attribute>                    	
	</Attributes>                        
</ModifyField> 
2.设置字段默认值
<ModifyField defaultValue="N" id="ifsubmit"></ModifyField>
3.按钮内设置子按钮
<MenuItem i18nName="rollinout" id="rollinout" langDir="lfwbuttons" modifiers="2" showModel="1" text="转入/转出">
                <MenuItem i18nName="rollin" id="rollin" langDir="lfwbuttons" modifiers="2" showModel="1" text="转入">
                    <Events>
                        <Event async="true" methodName="onRollin" name="onclick" onserver="true">
                            <SubmitRule>
                            </SubmitRule>
                            <Params>
                                <Param>
                                    <Name>mouseEvent</Name>
                                    <Value>
                                    </Value>
                                    <Desc>                                        <![CDATA[nc.uap.lfw.core.event.MouseEvent]]>
                                    </Desc>
                                </Param>
                            </Params>
                            <Action>
                            </Action>
                        </Event>
                    </Events>
                </MenuItem>
                <MenuItem i18nName="rollout" id="rollout" langDir="lfwbuttons" modifiers="2" showModel="1" text="转出">
                    <Events>
                        <Event async="true" methodName="onRollout" name="onclick" onserver="true">
                            <SubmitRule>
                            </SubmitRule>
                            <Params>
                                <Param>
                                    <Name>mouseEvent</Name>
                                    <Value>
                                    </Value>
                                    <Desc>                                        <![CDATA[nc.uap.lfw.core.event.MouseEvent]]>
                                    </Desc>
                                </Param>
                            </Params>
                            <Action>
                            </Action>
                        </Event>
                    </Events>
                </MenuItem>
            </MenuItem>
4.前台页面字段 按钮设置

wd文件设置

 <Column autoExpand="false" //自动扩展 
 		 dataType="String" // 数据类型
 		 editable="true" //是否可以编辑
 		 editorType="StringText" //编辑类型
 		 field="pk_com_quota" //字段field
 		 fixedHeader="false" //是否固定页眉
 		 id="pk_com_quota" //字段id
 		 imageOnly="false"
 		 langDir="arm_complete" //多语资源 有时修改text没用时,可以修改这个多语的试试
 		 nullAble="false" //是否可以为空
 		 renderType="DefaultRender" //渲染类型 有很多种,具体可以参考别的wd文件及页面整理
 		 showCheckBox="true" //是否显示复选框
 		 sortable="true" //是否可排序
 		 sumCol="false"  
 		 text="主键" //前端显示名称
 		 textAlign="left" //字段显示位置
 		 visible="false" //字段是否显示
 		 width="120" //字段显示宽度
 		 >
 		 </Column>

后台文件pagemode设置示例

package nc.scap.abs.arm.shxy.pagemodel;

import java.util.Map;

import nc.scap.abs.arm.complete.operate.CompleteOperate;
import nc.scap.abs.arm.shxy.operate.ShxyOperate;
import nc.scap.abs.util.Constants;
import nc.scap.asm.scale.constants.AsmConstants;
import nc.scap.fop.pub.pagemodel.CardWinPageModel;
import nc.scap.fop.pub.util.ProductDiffFactory;
import nc.scap.pub.util.CpCtrlUtil;
import nc.uap.lfw.core.comp.FormComp;
import nc.uap.lfw.core.comp.GridComp;
import nc.uap.lfw.core.comp.MenuItem;
import nc.uap.lfw.core.comp.MenubarComp;
import nc.uap.lfw.core.page.ViewComponents;

/**
 * nc.scap.abs.arm.shxy.pagemodel.ShxyCardPageModel
 * @author admin
 *
 */
public class ShxyCardPageModel extends CardWinPageModel {
	
	@Override
	protected void afterInitUIMetaStruct(String pro_action) {
		ViewComponents views = getPageMeta().getView("main").getViewComponents();
		ShxyOperate completeOperate = ProductDiffFactory.diffOperateWithKhtype(ShxyOperate.class);
		
		FormComp form = (FormComp)views.getComponent("arm_complete_form");
		String[] eles = completeOperate.cardVisiableFormEles();
		CpCtrlUtil.visiableFormEles(form, true, eles);

		GridComp grid = (GridComp)views.getComponent("arm_complete_quota_grid");
		//完成值显示字段
		String[] colms = completeOperate.cardVisiableColms(pro_action);
		CpCtrlUtil.gridColmVisiable(grid, colms,true);

		//可编辑字段
		String[] ecolms = completeOperate.cardCanEditableColms(pro_action);
		CpCtrlUtil.setGridGroupColEditable(grid, ecolms, true);
		
		//设置字段不能为空
		String[] nncolms = completeOperate.cardNotnullColms(pro_action);
		CpCtrlUtil.setGridColNullAble(grid,nncolms,false);
		
		//设置子表字段列名
		Map<String,String> rmcolmsmap = completeOperate.renameColms();
		CpCtrlUtil.renameGridCol(grid,rmcolmsmap);
		
		//隐藏子表指标属性字段
		colms = completeOperate.hideGirdQuotaProps(pro_action);
		CpCtrlUtil.visiableGridColms(grid,false,colms);
		
		//隐藏子表菜单
		String[] menus = completeOperate.cardHideGridMenu(pro_action);
		CpCtrlUtil.hideMenuBar(grid.getMenuBar(), menus);
	}
	
	@Override
	protected boolean isHideGridsButtons(String pro_action) {
		return Constants.DETAIL.equals(pro_action);
	}

	@Override
	protected void hideAllGridBtns(){
		String[] gridIds = this.getSlaveGridIds();
		if (gridIds == null || gridIds.length == 0) {
			return;
		}
		//详细信息查看的时候隐藏公共按钮
		String[] btns = new String[]{"arm_complete_quota_grid$cacl","arm_complete_quota_grid$HeaderBtn_Edit"};
		for (String gridId : gridIds) {
			// 隐藏子表的按钮
			GridComp grid = (GridComp) getPageMeta().getView("main")
					.getViewComponents().getComponent(gridId);
			if (grid == null||grid.getMenuBar()==null)
				continue;
			MenubarComp menuBar = grid.getMenuBar();
			for(String btn:btns){
				MenuItem item = menuBar.getItem(btn);
				if(item!=null){
					item.setVisible(false);
				}
			}
		}
	}
	@Override
	protected String[] getApproveHideBtns() {
		return new String[] { AsmConstants.SAVE,"resetdata" };
	}
	@Override
	protected String[] getSlaveGridIds() {
		return new String[]{"arm_complete_quota_grid"};
	}
}

portal前后台操作

1.获取数据集方法
LfwView edit = AppLifeCycleContext.current().getWindowContext().getCurrentViewContext().getView();
Dataset masterDs = this.getMasterDs();//控制类中
Dataset ds = edit.getViewModels().getDataset(getMasterDsId());
Dataset detailds = edit.getViewModels().getDataset(IYearPlanConstants.DS_DETAIL_NAME);
Row row = ds.getSelectedRow();
2.前台提交数据ds按钮示范
<MenuItem id="del" modifiers="2" showModel="1" stateManager="nc.uap.lfw.core.bm.dft.Ss_StateManager" text="删除">
                <Events>
                    <Event async="true" methodName="onDelete" name="onclick" onserver="true">
                        <SubmitRule>
                            <Widget id="main">
                                <Dataset id="scappr_firmbase_b" type="ds_all_line">
                                </Dataset>
                                //<!--提交规则,ds_current_page当前页,ds_current_line当前行,ds_all_line所有行 -->
                            </Widget>
                        </SubmitRule>
                        <Action>
                        </Action>
                    </Event>
                </Events>
            </MenuItem>
3.常见数据集事件
<MdDataset>
 <Events>
                    <Event async="true" methodName="方法名自定义" name="onAfterRowSelect" onserver="true">
                        <SubmitRule>
                        </SubmitRule>
                        <Params>
                            <Param>
                                <Name>datasetEvent</Name>
                                <Value>
                                </Value>
                                <Desc>                                  
                                </Desc>
                            </Param>
                        </Params>
                        <Action>
                        </Action>
                    </Event>
                    <Event async="true" methodName="方法名自定义" name="onAfterDataChange" onserver="true">
                        <SubmitRule>
                        </SubmitRule>
                        <Params>
                            <Param>
                                <Name>datasetCellEvent</Name>
                                <Value>
                                </Value>
                                <Desc>                                    
                                </Desc>
                            </Param>
                        </Params>
                        <Action>
                        </Action>
                    </Event>
                </Events>
</MdDataset>
4.附件上传
public void onUpload(ScriptEvent mouseEvent) {
		ScapLogger.info("load");
		LfwView view = this.getCntView();
		 Dataset[] ds = this.getDetailDs(new String[]{"arm_complete_quota"});
		 
		// String billitem = getWfmBillItem();
		ExtAttribute att = view
				.getExtendAttribute(IGlobalConstants.ATTACH_BILL_ID);
		// if(billitem == null || billitem.equals("")) {
//		if (att == null || att.getValue() == null || att.getValue().equals("")
//				|| att.getValue().equals("null")) {
//			throw new RuntimeException("未选中单据或单据未保存,不能上传附件!");
//		}
		// }
		String primaryKeyValue =ds[0].getSelectedRow().getString(ds[0].nameToIndex("pk_com_quota"));

		AppLifeCycleContext.current().setParameter("billitem", primaryKeyValue);
		AppUtil.addAppAttr(LfwFileConstants.BILLTYPE, "shxybvo");
		AppUtil.addAppAttr(LfwFileConstants.SYSID,LfwFileConstants.SYSID_BAFILE);
		AppLifeCycleContext.current().setParameter(LfwFileConstants.BILLTYPE, "shxybvo");
		String fileext = (String) LfwRuntimeEnvironment.getWebContext()
				.getWebSession().getOriginalParameter(LfwFileConstants.FILEEXT);
		String filedesc = (String) LfwRuntimeEnvironment.getWebContext()
				.getWebSession()
				.getOriginalParameter(LfwFileConstants.FILEDESC);
		String sizelimit = (String) LfwRuntimeEnvironment.getWebContext()
				.getWebSession()
				.getOriginalParameter(LfwFileConstants.SIZE_LIMIT);//限制大小,你自己保存在会话里,或者去改底层
		String bamodule = (String) LfwRuntimeEnvironment.getWebContext()
				.getWebSession()
				.getOriginalParameter(LfwFileConstants.Par_Bamodule);
		// 附件参数
		Map<String, String> param = UploadFileHelper.BuildDefaultPamater("",
				primaryKeyValue, CommonObjectConstants.AttachFileType, "");
		param.put("usescanable", "true");
		param.put("state", String.valueOf(31));
		param.put(LfwFileConstants.SIZE_LIMIT, "500M");
		param.put("allSizeLimit", "1024M");
		String title = "附件";

		CmdInvoker.invoke(new UifAttachCmd(title, param));
	}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值